Debian Codegraph @

third_party/rust/tabs/src/lib.rs

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