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::{
34    ClientRemoteTabs, LocalTabsInfo, RemoteTabRecord, TabGroup, TabsDeviceType, Window, WindowType,
35};
36pub use crate::store::{RemoteCommandStore, TabsStore};
37pub use error::{ApiResult, Error, Result, TabsApiError};
38use sync15::DeviceType;
39
40pub use crate::sync::{get_registered_sync_engine, TabsBridgedEngine, TabsEngine};
41
42#[derive(Clone, Eq, PartialEq, Debug)]
43pub enum RemoteCommand {
44    CloseTab { url: String },
45    // eg, CloseInactive, ??
46}
47
48// Tabs that were requested to be closed on other clients
49#[derive(Clone, Eq, PartialEq, Debug)]
50pub struct PendingCommand {
51    pub device_id: String,
52    pub command: RemoteCommand,
53    pub time_requested: Timestamp,
54    pub time_sent: Option<Timestamp>,
55}