tabs/
lib.rs

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/. */
4
5#![allow(unknown_lints)]
6#![warn(rust_2018_idioms)]
7
8#[macro_use]
9pub mod error;
10mod schema;
11mod storage;
12mod store;
13mod sync;
14
15pub use types::Timestamp;
16
17uniffi::custom_type!(Timestamp, i64, {
18    remote,
19    try_lift: |val| Ok(Self(val as u64)),
20    lower: |obj| obj.as_millis() as i64,
21});
22
23uniffi::include_scaffolding!("tabs");
24
25// Our UDL uses a `Guid` type.
26use sync_guid::Guid as TabsGuid;
27uniffi::custom_type!(TabsGuid, String, {
28    remote,
29    try_lift: |val| Ok(TabsGuid::new(val.as_str())),
30    lower: |obj| obj.into(),
31});
32
33pub use crate::storage::{ClientRemoteTabs, LocalTabsInfo, RemoteTabRecord, TabsDeviceType};
34pub use crate::store::{RemoteCommandStore, TabsStore};
35pub use error::{ApiResult, Error, Result, TabsApiError};
36use sync15::DeviceType;
37
38pub use crate::sync::{get_registered_sync_engine, TabsBridgedEngine, TabsEngine};
39
40#[derive(Clone, Eq, PartialEq, Debug)]
41pub enum RemoteCommand {
42    CloseTab { url: String },
43    // eg, CloseInactive, ??
44}
45
46// Tabs that were requested to be closed on other clients
47#[derive(Clone, Eq, PartialEq, Debug)]
48pub struct PendingCommand {
49    pub device_id: String,
50    pub command: RemoteCommand,
51    pub time_requested: Timestamp,
52    pub time_sent: Option<Timestamp>,
53}