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, RemoteTabRecord, TabsDeviceType};
34pub use crate::store::{RemoteCommandStore, TabsStore};
35pub use error::{ApiResult, Error, Result, TabsApiError};
36use sync15::DeviceType;
37
38pub use crate::sync::engine::get_registered_sync_engine;
39
40pub use crate::sync::bridge::TabsBridgedEngine;
41pub use crate::sync::engine::TabsEngine;
42
43#[derive(Clone, Eq, PartialEq, Debug)]
44pub 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)]
51pub struct PendingCommand {
52    pub device_id: String,
53    pub command: RemoteCommand,
54    pub time_requested: Timestamp,
55    pub time_sent: Option<Timestamp>,
56}