1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
45pub mod close_tabs;
6mod keys;
7pub mod send_tab;
89pub use close_tabs::CloseTabsPayload;
10pub use send_tab::SendTabPayload;
1112pub(crate) use keys::{
13 decrypt_command, encrypt_command, get_public_keys, PrivateCommandKeys, PublicCommandKeys,
14};
1516use super::device::Device;
17use crate::{Error, Result};
1819// Currently public for use by example crates, but should be made private eventually.
20#[derive(Clone, Debug)]
21pub enum IncomingDeviceCommand {
22 TabReceived {
23 sender: Option<Device>,
24 payload: SendTabPayload,
25 },
26 TabsClosed {
27 sender: Option<Device>,
28 payload: CloseTabsPayload,
29 },
30}
3132impl TryFrom<IncomingDeviceCommand> for crate::IncomingDeviceCommand {
33type Error = Error;
34fn try_from(cmd: IncomingDeviceCommand) -> Result<Self> {
35Ok(match cmd {
36 IncomingDeviceCommand::TabReceived { sender, payload } => {
37crate::IncomingDeviceCommand::TabReceived {
38 sender: sender.map(crate::Device::try_from).transpose()?,
39 payload: payload.into(),
40 }
41 }
42 IncomingDeviceCommand::TabsClosed { sender, payload } => {
43crate::IncomingDeviceCommand::TabsClosed {
44 sender: sender.map(crate::Device::try_from).transpose()?,
45 payload: payload.into(),
46 }
47 }
48 })
49 }
50}