places/
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
8pub mod api;
9pub mod error;
10pub mod types;
11// Making these all pub for now while we flesh out the API.
12pub mod bookmark_sync;
13pub mod db;
14pub mod ffi;
15pub mod frecency;
16pub mod hash;
17pub mod history_sync;
18// match_impl is pub mostly for benchmarks (which have to run as a separate pseudo-crate).
19pub mod import;
20pub mod match_impl;
21pub mod observation;
22pub mod storage;
23#[cfg(test)]
24mod tests;
25mod util;
26
27pub use crate::api::apply_observation;
28#[cfg(test)]
29pub use crate::api::places_api::test;
30pub use crate::api::places_api::{get_registered_sync_engine, ConnectionType, PlacesApi};
31
32pub use crate::db::PlacesDb;
33pub use crate::error::*;
34pub use crate::observation::*;
35pub use crate::storage::PageInfo;
36pub use crate::storage::RowId;
37pub use crate::types::*;
38
39pub use ffi::*;
40
41#[cfg(all(feature = "glean-sym", any(target_os = "android", target_os = "ios")))]
42#[allow(clippy::all)] // Don't lint generated code.
43pub mod glean_metrics {
44    include!(concat!(env!("OUT_DIR"), "/glean_metrics.rs"));
45}
46
47uniffi::custom_type!(Guid, String, {
48    remote,
49    try_lift: |val| Ok(Guid::new(val.as_str())),
50    lower: |obj| obj.into(),
51});
52
53uniffi::custom_type!(Url, String, {
54    remote,
55    try_lift: |val| {
56        match Url::parse(val.as_str()) {
57            Ok(url) => Ok(url),
58            Err(e) => Err(PlacesApiError::UrlParseFailed {
59                reason: e.to_string(),
60            }
61            .into()),
62        }
63    },
64    lower: |obj| obj.into(),
65});
66
67uniffi::custom_type!(PlacesTimestamp, i64, {
68    remote,
69    try_lift: |val| Ok(PlacesTimestamp(val as u64)),
70    lower: |obj| obj.as_millis() as i64,
71});
72
73uniffi::custom_type!(VisitTransitionSet, i32, {
74    try_lift: |val| {
75        Ok(VisitTransitionSet::from_u16(val as u16).expect("Bug: Invalid VisitTransitionSet"))
76    },
77    lower: |obj| VisitTransitionSet::into_u16(obj) as i32,
78});
79
80uniffi::include_scaffolding!("places");