webext_storage/
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
8mod api;
9mod db;
10pub mod error;
11mod ffi;
12mod migration;
13mod schema;
14pub mod store;
15mod sync;
16
17pub use migration::MigrationInfo;
18
19// We publish some constants from non-public modules.
20pub use sync::STORAGE_VERSION;
21
22pub use api::SYNC_MAX_ITEMS;
23pub use api::SYNC_QUOTA_BYTES;
24pub use api::SYNC_QUOTA_BYTES_PER_ITEM;
25
26pub use crate::error::{QuotaReason, WebExtStorageApiError};
27pub use crate::store::WebExtStorageStore;
28pub use crate::sync::{bridge::WebExtStorageBridgedEngine, SyncedExtensionChange};
29pub use api::UsageInfo;
30pub use api::{StorageChanges, StorageValueChange};
31
32uniffi::include_scaffolding!("webext-storage");
33
34use serde_json::Value as JsonValue;
35
36uniffi::custom_type!(JsonValue, String, {
37    remote,
38    try_lift: |val| Ok(serde_json::from_str(val.as_str()).unwrap()),
39    lower: |obj| obj.to_string(),
40});
41
42// Our UDL uses a `Guid` type.
43use sync_guid::Guid;
44uniffi::custom_type!(Guid, String, {
45    remote,
46    try_lift: |val| Ok(Guid::new(val.as_str())),
47    lower: |obj| obj.into()
48});