diff --git a/.circleci/config.yml b/.circleci/config.yml index 2ea6d9ad94..5285658191 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -118,6 +118,14 @@ commands: name: Run Rust sample command: | cargo run -p sample + - run: + name: Run glean-sym sample + command: | + cd samples/glean-sym-test + python3 -m venv ${PWD}/venv + venv/bin/pip install "git+ssh://git@github.com/mozilla/glean_parser@push-lskqopuplvts#egg=glean-parser" + export GLEAN_PYTHON_VENV_DIR=${PWD}/venv + make run install-rustup: steps: diff --git a/Cargo.lock b/Cargo.lock index 344b205ab7..4061ceecba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,12 +8,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - [[package]] name = "android_log-sys" version = "0.2.0" @@ -245,11 +239,10 @@ checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" [[package]] name = "chrono" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" dependencies = [ - "android-tzdata", "iana-time-zone", "js-sys", "num-traits", @@ -611,6 +604,30 @@ dependencies = [ "zeitstempel", ] +[[package]] +name = "glean-sym" +version = "0.1.0" +dependencies = [ + "bytes", + "glean-sym-parser", + "libloading", + "once_cell", + "serde", + "uniffi", + "xshell", +] + +[[package]] +name = "glean-sym-parser" +version = "0.1.0" +dependencies = [ + "prettyplease", + "proc-macro2", + "quote", + "syn", + "weedle2", +] + [[package]] name = "glean-tests" version = "0.1.0" @@ -694,9 +711,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" -version = "0.1.63" +version = "0.1.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -833,6 +850,16 @@ version = "0.2.176" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58f929b4d672ea937a23a1ab494143d968337a5f47e56d0815df1e0890ddf174" +[[package]] +name = "libloading" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" +dependencies = [ + "cfg-if", + "windows-link", +] + [[package]] name = "linux-raw-sys" version = "0.4.10" @@ -1005,11 +1032,21 @@ dependencies = [ "termtree", ] +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -1036,9 +1073,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.38" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -1281,9 +1318,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "syn" -version = "2.0.98" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -1747,9 +1784,9 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-core" -version = "0.61.2" +version = "0.62.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" dependencies = [ "windows-implement", "windows-interface", @@ -1760,9 +1797,9 @@ dependencies = [ [[package]] name = "windows-implement" -version = "0.60.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", @@ -1771,9 +1808,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.59.1" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -1782,24 +1819,24 @@ dependencies = [ [[package]] name = "windows-link" -version = "0.1.3" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" [[package]] name = "windows-result" -version = "0.3.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" dependencies = [ "windows-link", ] [[package]] name = "windows-strings" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" dependencies = [ "windows-link", ] diff --git a/Cargo.toml b/Cargo.toml index 33e2d9b1e8..e800de2f83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,8 @@ members = [ "samples/rust", "samples/rapid-metrics", "tools/embedded-uniffi-bindgen", + "tools/glean-sym-parser", + "glean-core/glean-sym", ] default-members = [ diff --git a/deny.toml b/deny.toml index 99c8e96d03..4d1b160c59 100644 --- a/deny.toml +++ b/deny.toml @@ -1,11 +1,12 @@ [licenses] allow = [ - "MPL-2.0", "Apache-2.0", - "MIT", "BSD-2-Clause", - "Zlib", + "ISC", + "MIT", + "MPL-2.0", "Unicode-3.0", + "Zlib", ] [bans] diff --git a/glean-core/glean-sym/Cargo.toml b/glean-core/glean-sym/Cargo.toml new file mode 100644 index 0000000000..1abb7b041f --- /dev/null +++ b/glean-core/glean-sym/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "glean-sym" +version = "0.1.0" +authors = ["The Glean Team "] +description = "A Rust API on top of the Glean UniFFI C FFI" +repository = "https://github.com/mozilla/glean" +license = "MPL-2.0" +edition = "2024" + +[dependencies] +bytes = "1.11.1" +libloading = "0.9.0" +once_cell = "1.21.3" +serde = { version = "1.0.228", features = ["derive"] } +uniffi = "0.31.0" + +[dev-dependencies] +xshell = "0.2.7" +glean-sym-parser = { path = "../../tools/glean-sym-parser" } diff --git a/glean-core/glean-sym/src/lib.rs b/glean-core/glean-sym/src/lib.rs new file mode 100644 index 0000000000..583403ef6a --- /dev/null +++ b/glean-core/glean-sym/src/lib.rs @@ -0,0 +1,110 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::sync::LazyLock; + +#[doc(hidden)] +pub extern crate serde as __serde; + +#[doc(hidden)] +pub mod __serde_helper { + /// Deserialize value to a `Vec`. + /// + /// If the value was `null` return an empty vector. + pub fn vec_null<'de, D: serde::Deserializer<'de>, T: serde::Deserialize<'de>>( + d: D, + ) -> Result, D::Error> { + let res: Option> = serde::Deserialize::deserialize(d)?; + Ok(res.unwrap_or_default()) + } +} + +// Re-export types that are used by the glean_parser-generated code. +#[doc(hidden)] +pub mod __export { + pub use once_cell::sync::Lazy; +} + +// Based on https://searchfox.org/firefox-main/rev/6193f8fd1172486e3ce941b8de251b9d1a4dfa0b/toolkit/crashreporter/client/app/src/net/libcurl.rs#84 +macro_rules! library_binding { + ( $localname:ident members[$($members:tt)*] load[$($load:tt)*] fn $name:ident $args:tt $( -> $ret:ty )? ; $($rest:tt)* ) => { + library_binding! { + $localname + members[ + $($members)* + pub(crate) $name: libloading::Symbol<'static, unsafe extern "C" fn $args $(->$ret)?>, + ] + load[ + $($load)* + $name: unsafe { + let symbol = $localname.get::$ret)?>(stringify!($name).as_bytes()) + .map_err(|e| std::io::Error::new(std::io::ErrorKind::NotFound, e))?; + // All symbols refer to library, so `'static` lifetimes are safe (`library` + // will outlive them). + std::mem::transmute::<_, libloading::Symbol<'static, _>>(symbol) + }, + ] + $($rest)* + } + }; + ( $localname:ident members[$($members:tt)*] load[$($load:tt)*] ) => { + pub struct GleanSym { + $($members)* + _library: libloading::Library, + } + + impl GleanSym { + #[cfg(unix)] + pub fn load() -> std::io::Result { + let name = libloading::library_filename("xul"); + let library = match unsafe { libloading::Library::new(name) } { + Ok(lib) => Some(lib), + Err(_e) => None, + }; + // Try each of the libraries, debug-logging load failures. + let $localname = library.ok_or_else(|| { + std::io::Error::new(std::io::ErrorKind::NotFound, "failed to find glean library") + })?; + Ok(GleanSym { $($load)* _library: $localname }) + } + + #[cfg(not(unix))] + pub fn load() -> std::io::Result { + compile_error!("This crate is not implemented for Windows"); + } + } + }; + ( $($rest:tt)* ) => { + library_binding! { + library members[] load[] $($rest)* + } + } +} + +pub mod metrics; +pub mod types; +mod util; + +static GLEAN: LazyLock = LazyLock::new(|| metrics::GleanSym::load().unwrap()); + +// This boilerplate is usually generated by `uniffi::setup_scaffolding!()` +// along with all the extra FFI functions, like wrappers around Rust buffer allocation, async handling, etc. +// We don't want to export those, so we do only the minimal part to support what `glean-sym` calls when used in other +// crates. + +/// The crate-specific tag to implement traits. +#[doc(hidden)] +pub struct UniFfiTag; + +/// The namespace glean-sym FFI items are placed in. +/// Required by UniFFI to match up items. +const UNIFFI_META_CONST_NAMESPACE_GLEAN_SYM: ::uniffi::MetadataBuffer = + ::uniffi::MetadataBuffer::from_code(::uniffi::metadata::codes::NAMESPACE) + .concat_str("glean_sym") + .concat_str("glean_sym"); +#[doc(hidden)] +#[unsafe(no_mangle)] +pub static UNIFFI_META_NAMESPACE_GLEAN_SYM: [::std::primitive::u8; + UNIFFI_META_CONST_NAMESPACE_GLEAN_SYM.size] = + UNIFFI_META_CONST_NAMESPACE_GLEAN_SYM.into_array(); diff --git a/glean-core/glean-sym/src/metrics.rs b/glean-core/glean-sym/src/metrics.rs new file mode 100644 index 0000000000..a32784d22d --- /dev/null +++ b/glean-core/glean-sym/src/metrics.rs @@ -0,0 +1,2007 @@ +// DO NOT MODIFY! +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// This file is generated by tools/glean-sym-parser. +// Run `-p glean-sym-parser -- glean-core/src/glean.udl > glean-core/glean-sym/src/metrics.rs` +// to regenerate it. +// `glean-sym` tests ensure the vendored copy is unmodified. +// This can be verified by running `cargo test -p glean-sym`. +#![allow(clippy::all)] +#![cfg_attr(rustfmt, rustfmt_skip)] + +use crate::types::*; +use crate::util::*; + +#[derive(uniffi::Record)] +pub struct CounterMetric { + handle: u64, +} +impl CounterMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_countermetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl CounterMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_countermetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn add(&self, amount: i32) -> () { + unsafe { + let this = self.clone_handle(); + let amount = uniffi::FfiConverter::::lower(amount); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_countermetric_add)( + this, + amount.clone_for_ffi(), + &mut call_status, + ); + amount.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_countermetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_countermetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct TimespanMetric { + handle: u64, +} +impl TimespanMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_timespanmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl TimespanMetric { + pub fn new(meta: CommonMetricData, time_unit: TimeUnit) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let time_unit = uniffi::FfiConverter::::lower(time_unit); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_timespanmetric_new)( + meta.clone_for_ffi(), + time_unit.clone_for_ffi(), + &mut call_status, + ); + time_unit.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn start(&self) -> () { + unsafe { + let this = self.clone_handle(); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timespanmetric_start)( + this, + &mut call_status, + ); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn stop(&self) -> () { + unsafe { + let this = self.clone_handle(); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timespanmetric_stop)( + this, + &mut call_status, + ); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn cancel(&self) -> () { + unsafe { + let this = self.clone_handle(); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timespanmetric_cancel)( + this, + &mut call_status, + ); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn set_raw_nanos(&self, elapsed: i64) -> () { + unsafe { + let this = self.clone_handle(); + let elapsed = uniffi::FfiConverter::::lower(elapsed); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timespanmetric_set_raw_nanos)( + this, + elapsed.clone_for_ffi(), + &mut call_status, + ); + elapsed.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timespanmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timespanmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct BooleanMetric { + handle: u64, +} +impl BooleanMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_booleanmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl BooleanMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_booleanmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: i8) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_booleanmetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_booleanmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_booleanmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct StringMetric { + handle: u64, +} +impl StringMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_stringmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl StringMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_stringmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: String) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringmetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct StringListMetric { + handle: u64, +} +impl StringListMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_stringlistmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl StringListMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_stringlistmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn add(&self, value: String) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringlistmetric_add)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn set(&self, value: Vec) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringlistmetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option> { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringlistmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_stringlistmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct UrlMetric { + handle: u64, +} +impl UrlMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_urlmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl UrlMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_urlmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: String) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_urlmetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_urlmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_urlmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct UuidMetric { + handle: u64, +} +impl UuidMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_uuidmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl UuidMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_uuidmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: String) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_uuidmetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn generate_and_set(&self) -> String { + unsafe { + let this = self.clone_handle(); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_uuidmetric_generate_and_set)( + this, + &mut call_status, + ); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_uuidmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_uuidmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct QuantityMetric { + handle: u64, +} +impl QuantityMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_quantitymetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl QuantityMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_quantitymetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: i64) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_quantitymetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_quantitymetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_quantitymetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct TimingDistributionMetric { + handle: u64, +} +impl TimingDistributionMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_timingdistributionmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl TimingDistributionMetric { + pub fn new(meta: CommonMetricData, time_unit: TimeUnit) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let time_unit = uniffi::FfiConverter::::lower(time_unit); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_timingdistributionmetric_new)( + meta.clone_for_ffi(), + time_unit.clone_for_ffi(), + &mut call_status, + ); + time_unit.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn start(&self) -> TimerId { + unsafe { + let this = self.clone_handle(); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_start)( + this, + &mut call_status, + ); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn stop_and_accumulate(&self, timer_id: TimerId) -> () { + unsafe { + let this = self.clone_handle(); + let timer_id = uniffi::FfiConverter::::lower(timer_id); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_stop_and_accumulate)( + this, + timer_id.clone_for_ffi(), + &mut call_status, + ); + timer_id.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn cancel(&self, timer_id: TimerId) -> () { + unsafe { + let this = self.clone_handle(); + let timer_id = uniffi::FfiConverter::::lower(timer_id); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_cancel)( + this, + timer_id.clone_for_ffi(), + &mut call_status, + ); + timer_id.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn accumulate_samples(&self, samples: Vec) -> () { + unsafe { + let this = self.clone_handle(); + let samples = uniffi::FfiConverter::::lower(samples); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_accumulate_samples)( + this, + samples.clone_for_ffi(), + &mut call_status, + ); + samples.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn accumulate_single_sample(&self, sample: i64) -> () { + unsafe { + let this = self.clone_handle(); + let sample = uniffi::FfiConverter::::lower(sample); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_accumulate_single_sample)( + this, + sample.clone_for_ffi(), + &mut call_status, + ); + sample.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_timingdistributionmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct MemoryDistributionMetric { + handle: u64, +} +impl MemoryDistributionMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_memorydistributionmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl MemoryDistributionMetric { + pub fn new(meta: CommonMetricData, memory_unit: MemoryUnit) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let memory_unit = uniffi::FfiConverter::< + crate::UniFfiTag, + >::lower(memory_unit); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_memorydistributionmetric_new)( + meta.clone_for_ffi(), + memory_unit.clone_for_ffi(), + &mut call_status, + ); + memory_unit.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn accumulate(&self, sample: i64) -> () { + unsafe { + let this = self.clone_handle(); + let sample = uniffi::FfiConverter::::lower(sample); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_memorydistributionmetric_accumulate)( + this, + sample.clone_for_ffi(), + &mut call_status, + ); + sample.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn accumulate_samples(&self, samples: Vec) -> () { + unsafe { + let this = self.clone_handle(); + let samples = uniffi::FfiConverter::::lower(samples); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_memorydistributionmetric_accumulate_samples)( + this, + samples.clone_for_ffi(), + &mut call_status, + ); + samples.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_memorydistributionmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_memorydistributionmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct CustomDistributionMetric { + handle: u64, +} +impl CustomDistributionMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_customdistributionmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl CustomDistributionMetric { + pub fn new( + meta: CommonMetricData, + range_min: i64, + range_max: i64, + bucket_count: i64, + histogram_type: HistogramType, + ) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let range_min = uniffi::FfiConverter::::lower(range_min); + let range_max = uniffi::FfiConverter::::lower(range_max); + let bucket_count = uniffi::FfiConverter::< + crate::UniFfiTag, + >::lower(bucket_count); + let histogram_type = uniffi::FfiConverter::< + crate::UniFfiTag, + >::lower(histogram_type); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_customdistributionmetric_new)( + meta.clone_for_ffi(), + range_min.clone_for_ffi(), + range_max.clone_for_ffi(), + bucket_count.clone_for_ffi(), + histogram_type.clone_for_ffi(), + &mut call_status, + ); + histogram_type.destroy(); + bucket_count.destroy(); + range_max.destroy(); + range_min.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn accumulate_samples(&self, samples: Vec) -> () { + unsafe { + let this = self.clone_handle(); + let samples = uniffi::FfiConverter::::lower(samples); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_customdistributionmetric_accumulate_samples)( + this, + samples.clone_for_ffi(), + &mut call_status, + ); + samples.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn accumulate_single_sample(&self, sample: i64) -> () { + unsafe { + let this = self.clone_handle(); + let sample = uniffi::FfiConverter::::lower(sample); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_customdistributionmetric_accumulate_single_sample)( + this, + sample.clone_for_ffi(), + &mut call_status, + ); + sample.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_customdistributionmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_customdistributionmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct DatetimeMetric { + handle: u64, +} +impl DatetimeMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_datetimemetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl DatetimeMetric { + pub fn new(meta: CommonMetricData, time_unit: TimeUnit) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let time_unit = uniffi::FfiConverter::::lower(time_unit); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_datetimemetric_new)( + meta.clone_for_ffi(), + time_unit.clone_for_ffi(), + &mut call_status, + ); + time_unit.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: Option) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_datetimemetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_datetimemetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value_as_string(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_datetimemetric_test_get_value_as_string)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_datetimemetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct EventMetric { + handle: u64, +} +impl EventMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_eventmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl EventMetric { + pub fn new(meta: CommonMetricData, allowed_extra_keys: Vec) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let allowed_extra_keys = uniffi::FfiConverter::< + crate::UniFfiTag, + >::lower(allowed_extra_keys); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_eventmetric_new)( + meta.clone_for_ffi(), + allowed_extra_keys.clone_for_ffi(), + &mut call_status, + ); + allowed_extra_keys.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn record(&self, extra: ::std::collections::HashMap) -> () { + unsafe { + let this = self.clone_handle(); + let extra = uniffi::FfiConverter::::lower(extra); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_eventmetric_record)( + this, + extra.clone_for_ffi(), + &mut call_status, + ); + extra.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value( + &self, + ping_name: Option, + ) -> Option> { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_eventmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_eventmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct RateMetric { + handle: u64, +} +impl RateMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_ratemetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl RateMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_ratemetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn add_to_numerator(&self, amount: i32) -> () { + unsafe { + let this = self.clone_handle(); + let amount = uniffi::FfiConverter::::lower(amount); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_ratemetric_add_to_numerator)( + this, + amount.clone_for_ffi(), + &mut call_status, + ); + amount.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn add_to_denominator(&self, amount: i32) -> () { + unsafe { + let this = self.clone_handle(); + let amount = uniffi::FfiConverter::::lower(amount); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_ratemetric_add_to_denominator)( + this, + amount.clone_for_ffi(), + &mut call_status, + ); + amount.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_ratemetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_ratemetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct DenominatorMetric { + handle: u64, +} +impl DenominatorMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_denominatormetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl DenominatorMetric { + pub fn new(meta: CommonMetricData, numerators: Vec) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let numerators = uniffi::FfiConverter::::lower(numerators); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_denominatormetric_new)( + meta.clone_for_ffi(), + numerators.clone_for_ffi(), + &mut call_status, + ); + numerators.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn add(&self, amount: i32) -> () { + unsafe { + let this = self.clone_handle(); + let amount = uniffi::FfiConverter::::lower(amount); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_denominatormetric_add)( + this, + amount.clone_for_ffi(), + &mut call_status, + ); + amount.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_denominatormetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_denominatormetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct NumeratorMetric { + handle: u64, +} +impl NumeratorMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_numeratormetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl NumeratorMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_numeratormetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn add_to_numerator(&self, amount: i32) -> () { + unsafe { + let this = self.clone_handle(); + let amount = uniffi::FfiConverter::::lower(amount); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_numeratormetric_add_to_numerator)( + this, + amount.clone_for_ffi(), + &mut call_status, + ); + amount.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_numeratormetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_numeratormetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct TextMetric { + handle: u64, +} +impl TextMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_textmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl TextMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_textmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set(&self, value: String) -> () { + unsafe { + let this = self.clone_handle(); + let value = uniffi::FfiConverter::::lower(value); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_textmetric_set)( + this, + value.clone_for_ffi(), + &mut call_status, + ); + value.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_textmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_textmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct ObjectMetric { + handle: u64, +} +impl ObjectMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_objectmetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl ObjectMetric { + pub fn new(meta: CommonMetricData) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_objectmetric_new)( + meta.clone_for_ffi(), + &mut call_status, + ); + meta.destroy(); + Self { handle } + } + } + pub fn set_string(&self, object: String) -> () { + unsafe { + let this = self.clone_handle(); + let object = uniffi::FfiConverter::::lower(object); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_objectmetric_set_string)( + this, + object.clone_for_ffi(), + &mut call_status, + ); + object.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value(&self, ping_name: Option) -> Option { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_objectmetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_objectmetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn record_schema_error(&self) -> () { + unsafe { + let this = self.clone_handle(); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_objectmetric_record_schema_error)( + this, + &mut call_status, + ); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +#[derive(uniffi::Record)] +pub struct DualLabeledCounterMetric { + handle: u64, +} +impl DualLabeledCounterMetric { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute( + (crate::GLEAN + .uniffi_glean_core_fn_clone_duallabeledcountermetric)( + std::mem::transmute(self.handle), + &mut call_status, + ), + ) + } + } +} +impl DualLabeledCounterMetric { + pub fn new( + meta: CommonMetricData, + keys: Option>, + categories: Option>, + ) -> Self { + unsafe { + let meta = uniffi::FfiConverter::::lower(meta); + let keys = uniffi::FfiConverter::::lower(keys); + let categories = uniffi::FfiConverter::::lower(categories); + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN + .uniffi_glean_core_fn_constructor_duallabeledcountermetric_new)( + meta.clone_for_ffi(), + keys.clone_for_ffi(), + categories.clone_for_ffi(), + &mut call_status, + ); + categories.destroy(); + keys.destroy(); + meta.destroy(); + Self { handle } + } + } + pub fn get(&self, key: String, category: String) -> CounterMetric { + unsafe { + let this = self.clone_handle(); + let key = uniffi::FfiConverter::::lower(key); + let category = uniffi::FfiConverter::::lower(category); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_duallabeledcountermetric_get)( + this, + key.clone_for_ffi(), + category.clone_for_ffi(), + &mut call_status, + ); + category.destroy(); + key.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_value( + &self, + ping_name: Option, + ) -> Option< + ::std::collections::HashMap>, + > { + unsafe { + let this = self.clone_handle(); + let ping_name = uniffi::FfiConverter::::lower(ping_name); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_duallabeledcountermetric_test_get_value)( + this, + ping_name.clone_for_ffi(), + &mut call_status, + ); + ping_name.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 { + unsafe { + let this = self.clone_handle(); + let error = uniffi::FfiConverter::::lower(error); + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN + .uniffi_glean_core_fn_method_duallabeledcountermetric_test_get_num_recorded_errors)( + this, + error.clone_for_ffi(), + &mut call_status, + ); + error.destroy(); + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } +} +library_binding! { + fn ffi_glean_core_rustbuffer_from_bytes(bytes : ::uniffi::ForeignBytes, call_status : + & mut ::uniffi::RustCallStatus) -> ::uniffi::RustBuffer; fn + uniffi_glean_core_fn_clone_countermetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_countermetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_countermetric_add(handle : u64, amount : i32, call_status + : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_countermetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_countermetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_timespanmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_timespanmetric_new(meta : uniffi::RustBuffer, + time_unit : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> u64; + fn uniffi_glean_core_fn_method_timespanmetric_start(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_timespanmetric_stop(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_timespanmetric_cancel(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_timespanmetric_set_raw_nanos(handle : u64, elapsed : i64, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_timespanmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_timespanmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_booleanmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_booleanmetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_booleanmetric_set(handle : u64, value : i8, call_status : + & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_booleanmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_booleanmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_stringmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_stringmetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_stringmetric_set(handle : u64, value : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_stringmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_stringmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_stringlistmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_stringlistmetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_stringlistmetric_add(handle : u64, value : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_stringlistmetric_set(handle : u64, value : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_stringlistmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_stringlistmetric_test_get_num_recorded_errors(handle : + u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; fn uniffi_glean_core_fn_clone_urlmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_urlmetric_new(meta : uniffi::RustBuffer, call_status + : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_urlmetric_set(handle : u64, value : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_urlmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_urlmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_uuidmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_uuidmetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_uuidmetric_set(handle : u64, value : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_uuidmetric_generate_and_set(handle : u64, call_status : & + mut ::uniffi::RustCallStatus) -> uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_uuidmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_uuidmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_quantitymetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_quantitymetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_quantitymetric_set(handle : u64, value : i64, call_status + : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_quantitymetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_quantitymetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_timingdistributionmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_timingdistributionmetric_new(meta : + uniffi::RustBuffer, time_unit : uniffi::RustBuffer, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_timingdistributionmetric_start(handle : u64, call_status + : & mut ::uniffi::RustCallStatus) -> uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_timingdistributionmetric_stop_and_accumulate(handle : + u64, timer_id : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + (); fn uniffi_glean_core_fn_method_timingdistributionmetric_cancel(handle : u64, + timer_id : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); + fn uniffi_glean_core_fn_method_timingdistributionmetric_accumulate_samples(handle : + u64, samples : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + (); fn + uniffi_glean_core_fn_method_timingdistributionmetric_accumulate_single_sample(handle + : u64, sample : i64, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_timingdistributionmetric_test_get_value(handle : u64, + ping_name : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_timingdistributionmetric_test_get_num_recorded_errors(handle + : u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; fn uniffi_glean_core_fn_clone_memorydistributionmetric(handle : u64, call_status + : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_memorydistributionmetric_new(meta : + uniffi::RustBuffer, memory_unit : uniffi::RustBuffer, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_memorydistributionmetric_accumulate(handle : u64, sample + : i64, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_memorydistributionmetric_accumulate_samples(handle : u64, + samples : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_memorydistributionmetric_test_get_value(handle : u64, + ping_name : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_memorydistributionmetric_test_get_num_recorded_errors(handle + : u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; fn uniffi_glean_core_fn_clone_customdistributionmetric(handle : u64, call_status + : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_customdistributionmetric_new(meta : + uniffi::RustBuffer, range_min : i64, range_max : i64, bucket_count : i64, + histogram_type : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + u64; fn + uniffi_glean_core_fn_method_customdistributionmetric_accumulate_samples(handle : u64, + samples : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_customdistributionmetric_accumulate_single_sample(handle + : u64, sample : i64, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_customdistributionmetric_test_get_value(handle : u64, + ping_name : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_customdistributionmetric_test_get_num_recorded_errors(handle + : u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; fn uniffi_glean_core_fn_clone_datetimemetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_datetimemetric_new(meta : uniffi::RustBuffer, + time_unit : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> u64; + fn uniffi_glean_core_fn_method_datetimemetric_set(handle : u64, value : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_datetimemetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_datetimemetric_test_get_value_as_string(handle : u64, + ping_name : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_datetimemetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_eventmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_eventmetric_new(meta : uniffi::RustBuffer, + allowed_extra_keys : uniffi::RustBuffer, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_eventmetric_record(handle : u64, extra : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_eventmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_eventmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_ratemetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_ratemetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_ratemetric_add_to_numerator(handle : u64, amount : i32, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_ratemetric_add_to_denominator(handle : u64, amount : i32, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_ratemetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_ratemetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_denominatormetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_denominatormetric_new(meta : uniffi::RustBuffer, + numerators : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + u64; fn uniffi_glean_core_fn_method_denominatormetric_add(handle : u64, amount : i32, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_denominatormetric_test_get_value(handle : u64, ping_name + : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_denominatormetric_test_get_num_recorded_errors(handle : + u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; fn uniffi_glean_core_fn_clone_numeratormetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_numeratormetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_numeratormetric_add_to_numerator(handle : u64, amount : + i32, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_numeratormetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_numeratormetric_test_get_num_recorded_errors(handle : + u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; fn uniffi_glean_core_fn_clone_textmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_textmetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_textmetric_set(handle : u64, value : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_textmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_textmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_clone_objectmetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_objectmetric_new(meta : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_objectmetric_set_string(handle : u64, object : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_method_objectmetric_test_get_value(handle : u64, ping_name : + uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_objectmetric_test_get_num_recorded_errors(handle : u64, + error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> i32; fn + uniffi_glean_core_fn_method_objectmetric_record_schema_error(handle : u64, + call_status : & mut ::uniffi::RustCallStatus) -> (); fn + uniffi_glean_core_fn_clone_duallabeledcountermetric(handle : u64, call_status : & mut + ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_constructor_duallabeledcountermetric_new(meta : + uniffi::RustBuffer, keys : uniffi::RustBuffer, categories : uniffi::RustBuffer, + call_status : & mut ::uniffi::RustCallStatus) -> u64; fn + uniffi_glean_core_fn_method_duallabeledcountermetric_get(handle : u64, key : + uniffi::RustBuffer, category : uniffi::RustBuffer, call_status : & mut + ::uniffi::RustCallStatus) -> uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_duallabeledcountermetric_test_get_value(handle : u64, + ping_name : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + uniffi::RustBuffer; fn + uniffi_glean_core_fn_method_duallabeledcountermetric_test_get_num_recorded_errors(handle + : u64, error : uniffi::RustBuffer, call_status : & mut ::uniffi::RustCallStatus) -> + i32; +} + diff --git a/glean-core/glean-sym/src/types.rs b/glean-core/glean-sym/src/types.rs new file mode 100644 index 0000000000..33342ccb40 --- /dev/null +++ b/glean-core/glean-sym/src/types.rs @@ -0,0 +1,119 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#[derive(uniffi::Enum, Default)] +pub enum Lifetime { + #[default] + Ping, + Application, + User, +} + +#[derive(uniffi::Enum)] +pub enum DynamicLabelType { + Label(String), + KeyOnly(String), + CategoryOnly(String), + KeyAndCategory(String), +} + +#[derive(uniffi::Record, Default)] +pub struct CommonMetricData { + pub category: String, + pub name: String, + pub send_in_pings: Vec, + pub lifetime: Lifetime, + pub disabled: bool, + pub dynamic_label: Option, +} + +#[derive(uniffi::Record)] +pub struct Rate { + numerator: i32, + denominator: i32, +} + +pub type JsonValue = String; + +#[derive(uniffi::Record, Debug)] +pub struct RecordedEvent { + timestamp: u64, + category: String, + name: String, + extra: Option<::std::collections::HashMap>, +} + +#[derive(uniffi::Record)] +pub struct Datetime { + year: i32, + month: u32, + day: u32, + hour: u32, + minute: u32, + second: u32, + nanosecond: u32, + offset_seconds: i32, +} + +#[derive(uniffi::Record)] +pub struct DistributionData { + values: ::std::collections::HashMap, + sum: i64, + count: i64, +} + +#[derive(uniffi::Record)] +pub struct TimerId { + id: u64, +} + +#[derive(uniffi::Enum)] +pub enum ErrorType { + InvalidValue, + InvalidLabel, + InvalidState, + InvalidOverflow, +} + +#[derive(uniffi::Enum)] +#[repr(i32)] +pub enum TimeUnit { + /// Truncate to nanosecond precision. + Nanosecond, + /// Truncate to microsecond precision. + Microsecond, + /// Truncate to millisecond precision. + Millisecond, + /// Truncate to second precision. + Second, + /// Truncate to minute precision. + Minute, + /// Truncate to hour precision. + Hour, + /// Truncate to day precision. + Day, +} + +#[derive(uniffi::Enum)] +#[repr(i32)] // use i32 to be compatible with our JNA definition +pub enum MemoryUnit { + /// 1 byte + Byte, + /// 2^10 bytes + Kilobyte, + /// 2^20 bytes + Megabyte, + /// 2^30 bytes + Gigabyte, +} + +#[derive(uniffi::Enum)] +pub enum HistogramType { + /// A histogram with linear distributed buckets. + Linear, + /// A histogram with exponential distributed buckets. + Exponential, +} + +pub type CowString = std::borrow::Cow<'static, str>; diff --git a/glean-core/glean-sym/src/util.rs b/glean-core/glean-sym/src/util.rs new file mode 100644 index 0000000000..8ff3e3fc29 --- /dev/null +++ b/glean-core/glean-sym/src/util.rs @@ -0,0 +1,141 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::collections::HashMap; + +use uniffi::FfiConverter; +use uniffi::RustBuffer; + +use super::types; + +macro_rules! forward_ffi_converter { + ($ty:ty) => { + unsafe impl FfiConverter for $ty { + type FfiType = RustBuffer; + + fn lower(obj: Self) -> Self::FfiType { + uniffi::Lower::::lower(obj) + } + + fn try_lift(v: Self::FfiType) -> uniffi::Result { + uniffi::Lift::::try_lift(v) + } + + fn write(obj: Self, buf: &mut Vec) { + uniffi::Lower::::write(obj, buf) + } + + fn try_read(buf: &mut &[u8]) -> uniffi::Result { + uniffi::Lift::::try_read(buf) + } + + const TYPE_ID_META: uniffi::MetadataBuffer = uniffi::MetadataBuffer::from_code(0); + } + }; +} + +unsafe impl FfiConverter for () { + type FfiType = (); + + fn lower(_obj: Self) -> Self::FfiType {} + + fn try_lift(_v: Self::FfiType) -> uniffi::Result { + Ok(()) + } + + fn write(_obj: Self, _buf: &mut Vec) {} + + fn try_read(_buf: &mut &[u8]) -> uniffi::Result { + Ok(()) + } + + const TYPE_ID_META: uniffi::MetadataBuffer = uniffi::MetadataBuffer::from_code(0); +} + +unsafe impl FfiConverter for types::CowString { + type FfiType = >::FfiType; + fn lower(s: types::CowString) -> Self::FfiType { + >::lower(s.into_owned()) + } + fn try_lift(v: Self::FfiType) -> ::uniffi::Result { + let s = >::try_lift(v)?; + Ok(types::CowString::from(s)) + } + + fn write(s: types::CowString, buf: &mut Vec) { + >::write(s.into_owned(), buf); + } + + fn try_read(buf: &mut &[u8]) -> ::uniffi::Result { + let s = >::try_read(buf)?; + Ok(types::CowString::from(s)) + } + + const TYPE_ID_META: uniffi::MetadataBuffer = uniffi::MetadataBuffer::from_code(0); +} + +forward_ffi_converter!(Option); +forward_ffi_converter!(Vec); +forward_ffi_converter!(Vec); +forward_ffi_converter!(Vec); +forward_ffi_converter!(Option); +forward_ffi_converter!(Option); +forward_ffi_converter!(Option>); +forward_ffi_converter!(Option>); +forward_ffi_converter!(Option); +forward_ffi_converter!(Option>); +forward_ffi_converter!(HashMap); +forward_ffi_converter!(Option>>); +forward_ffi_converter!(Option); +forward_ffi_converter!(Option); +forward_ffi_converter!(Option); +uniffi::derive_ffi_traits!(local types::CowString); + +pub trait CloneFfiArg { + fn clone_for_ffi(&self) -> T; +} + +pub trait DestroyFfiArg { + fn destroy(self); +} + +macro_rules! impl_clone_ffi_arg_primitive { + ($($ty:ty),+) => { + $( + impl CloneFfiArg<$ty> for $ty { + fn clone_for_ffi(&self) -> $ty { + *self + } + } + + impl DestroyFfiArg for $ty { + fn destroy(self) { + /* left empty */ + } + } + )* + } +} + +impl_clone_ffi_arg_primitive!(i8, i32, i64); + +impl CloneFfiArg for RustBuffer { + fn clone_for_ffi(&self) -> RustBuffer { + // SAFETY: trust me, bro. + unsafe { + let bytes = uniffi::ForeignBytes::from_raw_parts( + self.data_pointer(), + self.len().try_into().unwrap(), + ); + let mut call_status = uniffi::RustCallStatus::default(); + (crate::GLEAN.ffi_glean_core_rustbuffer_from_bytes)(bytes, &mut call_status) + } + } +} + +impl DestroyFfiArg for RustBuffer { + fn destroy(self) { + _ = self.destroy_into_vec(); + } +} diff --git a/glean-core/glean-sym/tests/parser.rs b/glean-core/glean-sym/tests/parser.rs new file mode 100644 index 0000000000..67a32efc09 --- /dev/null +++ b/glean-core/glean-sym/tests/parser.rs @@ -0,0 +1,25 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::fs; + +use xshell::{Shell, cmd}; + +#[test] +fn generated_metrics_code_up_to_date() { + // Relative to `glean-sym` + let udl_file = "../src/glean.udl"; + let udl_src = fs::read_to_string(udl_file).expect("unable to read UDL file"); + + let output = glean_sym_parser::generate(&udl_src); + let dst_file = "src/metrics.rs"; + + fs::write(dst_file, output.as_bytes()).unwrap(); + + // Last but not least check if we modified the document. + let sh = Shell::new().unwrap(); + cmd!(sh, "git --no-pager diff --exit-code {dst_file}") + .run() + .unwrap(); +} diff --git a/samples/glean-sym-test/Cargo.lock b/samples/glean-sym-test/Cargo.lock new file mode 100644 index 0000000000..4dae076f9e --- /dev/null +++ b/samples/glean-sym-test/Cargo.lock @@ -0,0 +1,1972 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" +dependencies = [ + "memchr", +] + +[[package]] +name = "android_log-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85965b6739a430150bdd138e2374a98af0c3ee0d030b3bb7fc3bddff58d0102e" + +[[package]] +name = "android_logger" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037f3e1da32ddba7770530e69258b742c15ad67bdf90e5f6b35f4b6db9a60eb7" +dependencies = [ + "android_log-sys", + "env_logger 0.10.2", + "log", + "once_cell", +] + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" + +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + +[[package]] +name = "anyhow" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "askama" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75363874b771be265f4ffe307ca705ef6f3baa19011c149da8674a87f1b75c4" +dependencies = [ + "askama_derive", + "itoa", + "percent-encoding", + "serde", + "serde_json", +] + +[[package]] +name = "askama_derive" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "129397200fe83088e8a68407a8e2b1f826cf0086b21ccdb866a722c8bcd3a94f" +dependencies = [ + "askama_parser", + "basic-toml", + "memchr", + "proc-macro2", + "quote", + "rustc-hash", + "serde", + "serde_derive", + "syn", +] + +[[package]] +name = "askama_parser" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" +dependencies = [ + "memchr", + "serde", + "serde_derive", + "winnow 0.7.15", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "basic-toml" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba62675e8242a4c4e806d12f11d136e626e6c8361d6b829310732241652a178a" +dependencies = [ + "serde", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +dependencies = [ + "serde_core", +] + +[[package]] +name = "bumpalo" +version = "3.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" + +[[package]] +name = "bytes" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" + +[[package]] +name = "camino" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e629a66d692cb9ff1a1c664e41771b3dcaf961985a9774c0eb0bd1b51cf60a48" +dependencies = [ + "serde_core", +] + +[[package]] +name = "cargo-platform" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd5eb614ed4c27c5d706420e4320fbe3216ab31fa1c33cd8246ac36dae4479ba" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "cc" +version = "1.2.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43c5703da9466b66a946814e1adf53ea2c90f10063b86290cc9eb67ce3478a20" +dependencies = [ + "find-msvc-tools", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "chrono" +version = "0.4.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "dashmap" +version = "4.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" +dependencies = [ + "cfg-if", + "num_cpus", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "env_filter" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32e90c2accc4b07a8456ea0debdc2e7587bdd890680d71173a15d4ae604f6eef" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" +dependencies = [ + "log", +] + +[[package]] +name = "env_logger" +version = "0.11.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0621c04f2196ac3f488dd583365b9c09be011a4ab8b9f37248ffcc8f6198b56a" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "jiff", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fastrand" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" + +[[package]] +name = "fd-lock" +version = "4.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce92ff622d6dadf7349484f42c93271a0d49b7cc4d466a936405bacbe10aa78" +dependencies = [ + "cfg-if", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "find-msvc-tools" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" + +[[package]] +name = "flate2" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "843fba2746e448b37e26a819579957415c8cef339bf08564fe8b7ddbd959573c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs-err" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] + +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasip2", + "wasip3", +] + +[[package]] +name = "glean" +version = "67.2.0" +dependencies = [ + "crossbeam-channel", + "glean-core", + "inherent", + "log", + "once_cell", + "whatsys", + "wr_malloc_size_of", +] + +[[package]] +name = "glean-build" +version = "19.0.0" +dependencies = [ + "xshell-venv", +] + +[[package]] +name = "glean-core" +version = "67.2.0" +dependencies = [ + "android_logger", + "bincode", + "chrono", + "crossbeam-channel", + "flate2", + "log", + "malloc_size_of_derive", + "once_cell", + "oslog", + "rkv", + "serde", + "serde_json", + "thiserror", + "uniffi", + "uuid", + "wr_malloc_size_of", + "zeitstempel", +] + +[[package]] +name = "glean-sym" +version = "0.1.0" +dependencies = [ + "bytes", + "libloading", + "once_cell", + "serde", + "uniffi", +] + +[[package]] +name = "glob" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "goblin" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b363a30c165f666402fe6a3024d3bec7ebc898f96a4a23bd1c99f8dbf3f4f47" +dependencies = [ + "log", + "plain", + "scroll", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f467dd6dccf739c208452f8014c75c18bb8301b050ad1cfb27153803edb0f51" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2984d1cd16c883d7935b9e07e44071dca8d917fd52ecc02c04d5fa0b5a3f191c" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92219b62b3e2b4d88ac5119f8904c10f8f61bf7e95b640d25ba3075e6cac2c29" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c56e5ee99d6e3d33bd91c5d85458b6005a22140021cc324cea84dd0e72cff3b4" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da3be0ae77ea334f4da67c12f149704f19f81d1adf7c51cf482943e84a2bad38" + +[[package]] +name = "icu_properties" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bee3b67d0ea5c2cca5003417989af8996f8604e34fb9ddf96208a033901e70de" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bbb201e0c04f7b4b3e14382af113e17ba4f63e2c9d2ee626b720cbce54a14" + +[[package]] +name = "icu_provider" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "139c4cf31c8b5f33d7e199446eff9c1e02decfc2f0eec2c8d71f65befa45b421" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d466e9454f08e4a911e14806c24e16fba1b4c121d1ea474396f396069cf949d9" +dependencies = [ + "equivalent", + "hashbrown 0.17.0", + "serde", + "serde_core", +] + +[[package]] +name = "inherent" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c727f80bfa4a6c6e2508d2f05b6f4bfce242030bd88ed15ae5331c5b5d30fba7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jiff" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a3546dc96b6d42c5f24902af9e2538e82e39ad350b0c766eb3fbf2d8f3d8359" +dependencies = [ + "jiff-static", + "log", + "portable-atomic", + "portable-atomic-util", + "serde_core", +] + +[[package]] +name = "jiff-static" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "js-sys" +version = "0.3.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2964e92d1d9dc3364cae4d718d93f227e3abb088e747d92e0395bfdedf1c12ca" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "libc" +version = "0.2.185" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ff2c0fe9bc6cb6b14a0592c2ff4fa9ceb83eea9db979b0487cd054946a2b8f" + +[[package]] +name = "libloading" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92daf443525c4cce67b150400bc2316076100ce0b3686209eb8cf3c31612e6f0" + +[[package]] +name = "log" +version = "0.4.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" + +[[package]] +name = "malloc_size_of_derive" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f44db74bde26fdf427af23f1d146c211aed857c59e3be750cf2617f6b0b05c94" +dependencies = [ + "proc-macro2", + "syn", + "synstructure", +] + +[[package]] +name = "memchr" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + +[[package]] +name = "ordered-float" +version = "3.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1e1c390732d15f1d48471625cd92d154e66db2c56645e29a9cd26f4699f72dc" +dependencies = [ + "num-traits", +] + +[[package]] +name = "oslog" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8343ce955f18e7e68c0207dd0ea776ec453035685395ababd2ea651c569728b3" +dependencies = [ + "cc", + "dashmap", + "log", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "portable-atomic" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" + +[[package]] +name = "portable-atomic-util" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0103b1cef7ec0cf76490e969665504990193874ea05c85ff9bab8b911d0a0564" +dependencies = [ + "zerovec", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "regex" +version = "1.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" + +[[package]] +name = "rkv" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f67a9dbc634fcd36a2d1d800ca818065dcf71a1d907dc35130c2d1552c6e1dc" +dependencies = [ + "arrayref", + "bincode", + "bitflags", + "id-arena", + "lazy_static", + "log", + "malloc_size_of_derive", + "ordered-float", + "serde", + "serde_derive", + "thiserror", + "url", + "uuid", + "wr_malloc_size_of", +] + +[[package]] +name = "rustc-hash" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" + +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" + +[[package]] +name = "scroll" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ab8598aa408498679922eff7fa985c25d58a90771bd6be794434c5277eab1a6" +dependencies = [ + "scroll_derive", +] + +[[package]] +name = "scroll_derive" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1783eabc414609e28a5ba76aee5ddd52199f7107a0b24c2e9746a1ecc34a683d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +dependencies = [ + "serde", + "serde_core", +] + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6662b5879511e06e8999a8a235d848113e942c9124f211511b16466ee2995f26" +dependencies = [ + "serde_core", +] + +[[package]] +name = "services" +version = "0.1.0" +dependencies = [ + "env_logger 0.11.10", + "glean-build", + "glean-sym", + "log", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "simd-adler32" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "703d5c7ef118737c72f1af64ad2f6f8c5e1921f818cdcb97b8fe6fc69bf66214" + +[[package]] +name = "siphasher" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "smawk" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + +[[package]] +name = "textwrap" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" +dependencies = [ + "smawk", +] + +[[package]] +name = "thiserror" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8323304221c2a851516f22236c5722a72eaa19749016521d6dff0824447d96d" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "toml" +version = "0.9.12+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow 0.7.15", +] + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" +dependencies = [ + "winnow 1.0.1", +] + +[[package]] +name = "toml_writer" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" + +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "uniffi" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc5f2297ee5b893405bed1a6929faec4713a061df158ecf5198089f23910d470" +dependencies = [ + "anyhow", + "cargo_metadata", + "uniffi_bindgen", + "uniffi_build", + "uniffi_core", + "uniffi_macros", + "uniffi_pipeline", +] + +[[package]] +name = "uniffi_bindgen" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bc0c60a9607e7ab77a2ad47ec5530178015014839db25af7512447d2238016c" +dependencies = [ + "anyhow", + "askama", + "camino", + "cargo_metadata", + "fs-err", + "glob", + "goblin", + "heck", + "indexmap", + "once_cell", + "serde", + "tempfile", + "textwrap", + "toml", + "uniffi_internal_macros", + "uniffi_meta", + "uniffi_pipeline", + "uniffi_udl", +] + +[[package]] +name = "uniffi_build" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c39413c43b955e4aa8a4e2b34bbd1b6b5ff6bd85532b52f9eb92fbe88c14458" +dependencies = [ + "anyhow", + "camino", + "uniffi_bindgen", +] + +[[package]] +name = "uniffi_core" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77baf5d539fe2e1ad6805e942dbc5dbdeb2b83eb5f2b3a6535d422ca4b02a12f" +dependencies = [ + "anyhow", + "bytes", + "once_cell", + "static_assertions", +] + +[[package]] +name = "uniffi_internal_macros" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4b42137524f4be6400fcaca9d02c1d4ecb6ad917e4013c0b93235526d8396e5" +dependencies = [ + "anyhow", + "indexmap", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "uniffi_macros" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9273ec45330d8fe9a3701b7b983cea7a4e218503359831967cb95d26b873561" +dependencies = [ + "camino", + "fs-err", + "once_cell", + "proc-macro2", + "quote", + "serde", + "syn", + "toml", + "uniffi_meta", +] + +[[package]] +name = "uniffi_meta" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "431d2f443e7828a6c29d188de98b6771a6491ee98bba2d4372643bf93f988a18" +dependencies = [ + "anyhow", + "siphasher", + "uniffi_internal_macros", + "uniffi_pipeline", +] + +[[package]] +name = "uniffi_pipeline" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "761ef74f6175e15603d0424cc5f98854c5baccfe7bf4ccb08e5816f9ab8af689" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "tempfile", + "uniffi_internal_macros", +] + +[[package]] +name = "uniffi_udl" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68773ec0e1c067b6505a73bbf6a5782f31a7f9209333a0df97b87565c46bf370" +dependencies = [ + "anyhow", + "textwrap", + "uniffi_meta", + "weedle2", +] + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +dependencies = [ + "getrandom", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "wasip2" +version = "1.0.2+wasi-0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf938a0bacb0469e83c1e148908bd7d5a6010354cf4fb73279b7447422e3a89" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeff24f84126c0ec2db7a449f0c2ec963c6a49efe0698c4242929da037ca28ed" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d08065faf983b2b80a79fd87d8254c409281cf7de75fc4b773019824196c904" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.118" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd04d9e306f1907bd13c6361b5c6bfc7b3b3c095ed3f8a9246390f8dbdee129" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", +] + +[[package]] +name = "weedle2" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "998d2c24ec099a87daf9467808859f9d82b61f1d9c9701251aea037f514eae0e" +dependencies = [ + "nom", +] + +[[package]] +name = "whatsys" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "192bcd2925a9791ba474bc673938f8c59b8978b3f304ef2c50672156bacf943b" +dependencies = [ + "cc", + "cfg-if", + "libc", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09dac053f1cd375980747450bfc7250c264eaae0583872e845c0c7cd578872b5" + +[[package]] +name = "wit-bindgen" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "wr_malloc_size_of" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "482308b684f11723b200a32808094bb460b5ac4840903ccbcb78ad92a6354a1f" +dependencies = [ + "once_cell", +] + +[[package]] +name = "writeable" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" + +[[package]] +name = "xshell" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d" +dependencies = [ + "xshell-macros", +] + +[[package]] +name = "xshell-macros" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547" + +[[package]] +name = "xshell-venv" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7933fb25d6b9716ede532410214bbc9b0fd08aa7a7a499788ede2d2c23dc4b02" +dependencies = [ + "fd-lock", + "xshell", +] + +[[package]] +name = "xul" +version = "0.1.0" +dependencies = [ + "env_logger 0.11.10", + "flate2", + "glean", + "glean-build", + "log", + "serde_json", +] + +[[package]] +name = "yoke" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeitstempel" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f523a0d9326c4f3242ad3a9d306baa7fe4572fd532cc891cabecfb714c786c1e" +dependencies = [ + "cfg-if", + "libc", + "once_cell", + "winapi", +] + +[[package]] +name = "zerofrom" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69faa1f2a1ea75661980b013019ed6687ed0e83d069bc1114e2cc74c6c04c4df" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f9152d31db0792fa83f70fb2f83148effb5c1f5b8c7686c3459e361d9bc20bf" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90f911cbc359ab6af17377d242225f4d75119aec87ea711a880987b18cd7b239" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/samples/glean-sym-test/Cargo.toml b/samples/glean-sym-test/Cargo.toml new file mode 100644 index 0000000000..66292d398e --- /dev/null +++ b/samples/glean-sym-test/Cargo.toml @@ -0,0 +1,7 @@ +[workspace] +resolver = "2" + +members = [ + "xul", + "services", +] diff --git a/samples/glean-sym-test/Makefile b/samples/glean-sym-test/Makefile new file mode 100644 index 0000000000..934b69d250 --- /dev/null +++ b/samples/glean-sym-test/Makefile @@ -0,0 +1,18 @@ + UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Linux) + LIB_PATH_NAME = LD_LIBRARY_PATH +endif +ifeq ($(UNAME_S),Darwin) + LIB_PATH_NAME = DYLD_LIBRARY_PATH +endif + +.PHONY: help +help: + @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \ + sort | \ + awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: run +run: ## Run the sample app + cargo build + env $(LIB_PATH_NAME)=target/debug python3 app.py diff --git a/samples/glean-sym-test/README.md b/samples/glean-sym-test/README.md new file mode 100644 index 0000000000..e7b609e550 --- /dev/null +++ b/samples/glean-sym-test/README.md @@ -0,0 +1,34 @@ +# A minimal sample app using `glean-sym` + +## Run the sample app + +``` +make run +``` + +This runs `app.py`. +`app.py` has some self-checks to ensure things are working correctly. +If the run succeeds it's all working as expected. + +You can set `RUST_LOG=debug` to get log output. + +## What it does + +`app.py` acts as the surrounding application. +In the real world this would be Fenix, written in Kotlin. +It loads the `xul` lib and the `services` lib. + +The `xul` crate ships a dynamic library. +Inside it initializes Glean, records some metrics and submits a ping. +This is similar to what `libxul` (Gecko) does in the real world. +Because it depends on the Glean Rust SDK ("RLB") +it also does expose all the necessary symbols used by the other foreign language implementations. +Just what `glean-sym` needs. + +The `services` crate also ships a dynamic library. +It acts as the equivalent of `application-services` megazord library. +It does not depend on the Glean Rust SDK. +However it does depend on the `glean-sym` crate. +Under the hood this looks up the relevant symbols from a `xul` library, +which happens to be the one that initialized Glean properly before. +`services` then creates a metric and records a value into it. diff --git a/samples/glean-sym-test/app.py b/samples/glean-sym-test/app.py new file mode 100644 index 0000000000..ea0609a548 --- /dev/null +++ b/samples/glean-sym-test/app.py @@ -0,0 +1,51 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at https://mozilla.org/MPL/2.0/. + +import ctypes +import json +import os +import platform +import tempfile +from ctypes import cdll + + +def library_name(name): + suffix = "dylib" if platform.system() == "Darwin" else "so" + return f"lib{name}.{suffix}" + + +xul = cdll.LoadLibrary(library_name("xul")) +services = cdll.LoadLibrary(library_name("services")) + +with tempfile.TemporaryDirectory() as data_path: + startup_fn = xul.startup + startup_fn.argtypes = [ctypes.c_char_p] + startup_fn(str.encode(data_path)) + + services_record = services.record + services_record.argtypes = [ctypes.c_int32] + + amount = 31 + services_record(amount) + + xul.submit() + xul.shutdown() + + # Check that + # * We submitted one ping only + # * It's the `prototype` ping + # * It contains 2 metrics with the expected values + path = os.path.join(data_path, "sent_pings") + for root, dirs, files in os.walk(path): + assert len(files) == 1 + assert "prototype-" in files[0] + + sent_ping = os.path.join(path, files[0]) + data = open(sent_ping).read() + end_first_object = data.find("}") + payload = json.loads(data[end_first_object + 1 :]) + counter = payload["metrics"]["counter"] + + assert 1 == counter["test.metrics.sample_counter"] + assert amount == counter["dylib.counting"] diff --git a/samples/glean-sym-test/services/Cargo.toml b/samples/glean-sym-test/services/Cargo.toml new file mode 100644 index 0000000000..dbc7a00a34 --- /dev/null +++ b/samples/glean-sym-test/services/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "services" +version = "0.1.0" +edition = "2024" +license = "MPL-2.0" +publish = false + +[dependencies] +env_logger = "0.11.10" +glean-sym = { path = "../../../glean-core/glean-sym" } +log = "0.4.29" + +[build-dependencies] +glean-build = { path = "../../../glean-core/build" } + +[lib] +name = "services" +path = "lib.rs" +crate-type = ["cdylib"] diff --git a/samples/glean-sym-test/services/build.rs b/samples/glean-sym-test/services/build.rs new file mode 100644 index 0000000000..f1b50e4680 --- /dev/null +++ b/samples/glean-sym-test/services/build.rs @@ -0,0 +1,9 @@ +use glean_build::Builder; + +fn main() { + Builder::default() + .file("metrics.yaml") + .format("rust_sym") + .generate() + .expect("Error generating Glean Rust bindings"); +} diff --git a/samples/glean-sym-test/services/lib.rs b/samples/glean-sym-test/services/lib.rs new file mode 100644 index 0000000000..5edab84dff --- /dev/null +++ b/samples/glean-sym-test/services/lib.rs @@ -0,0 +1,18 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +#[allow(clippy::all)] // Don't lint generated code. +pub mod glean_metrics { + include!(concat!(env!("OUT_DIR"), "/glean_metrics.rs")); +} + +#[unsafe(no_mangle)] +unsafe extern "C" fn record(amount: i32) { + env_logger::init(); + log::info!("Record invoked"); + + log::info!("new LoginStore! Recording a metric"); + glean_metrics::dylib::counting.add(amount); + log::info!("Metric recorded."); +} diff --git a/samples/glean-sym-test/services/metrics.yaml b/samples/glean-sym-test/services/metrics.yaml new file mode 100644 index 0000000000..ae92d3d0ff --- /dev/null +++ b/samples/glean-sym-test/services/metrics.yaml @@ -0,0 +1,22 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +--- + +$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 + +dylib: + counting: + type: counter + description: | + Just testing counting + bugs: + - https://bugzilla.mozilla.org/123456789 + data_reviews: + - N/A + notification_emails: + - CHANGE-ME@example.com + expires: never + send_in_pings: + - prototype diff --git a/samples/glean-sym-test/xul/Cargo.toml b/samples/glean-sym-test/xul/Cargo.toml new file mode 100644 index 0000000000..5f78c2ad7b --- /dev/null +++ b/samples/glean-sym-test/xul/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "xul" +version = "0.1.0" +edition = "2024" +license = "MPL-2.0" +publish = false + +[dependencies] +env_logger = "0.11.10" +flate2 = "1.1.9" +glean = { path = "../../../glean-core/rlb" } +log = "0.4.29" +serde_json = "1.0.149" + +[build-dependencies] +glean-build = { path = "../../../glean-core/build" } + +[lib] +name = "xul" +path = "lib.rs" +crate-type = ["cdylib"] diff --git a/samples/glean-sym-test/xul/build.rs b/samples/glean-sym-test/xul/build.rs new file mode 100644 index 0000000000..8a17552ca4 --- /dev/null +++ b/samples/glean-sym-test/xul/build.rs @@ -0,0 +1,9 @@ +use glean_build::Builder; + +fn main() { + Builder::default() + .file("metrics.yaml") + .file("pings.yaml") + .generate() + .expect("Error generating Glean Rust bindings"); +} diff --git a/samples/glean-sym-test/xul/lib.rs b/samples/glean-sym-test/xul/lib.rs new file mode 100644 index 0000000000..b5975a5483 --- /dev/null +++ b/samples/glean-sym-test/xul/lib.rs @@ -0,0 +1,115 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::ffi::{CStr, c_char}; +use std::fs::File; +use std::io::{Read, Write}; +use std::path::PathBuf; + +use flate2::read::GzDecoder; +use glean::{ClientInfoMetrics, ConfigurationBuilder, net}; + +#[allow(clippy::all)] // Don't lint generated code. +pub mod glean_metrics { + include!(concat!(env!("OUT_DIR"), "/glean_metrics.rs")); +} + +#[derive(Debug)] +struct MovingUploader { + out_path: String, +} + +impl MovingUploader { + fn new(out_path: String) -> Self { + Self { out_path } + } +} + +impl net::PingUploader for MovingUploader { + fn upload(&self, upload_request: net::CapablePingUploadRequest) -> net::UploadResult { + let upload_request = upload_request.capable(|_| true).unwrap(); + let net::PingUploadRequest { + body, url, headers, .. + } = upload_request; + let mut gzip_decoder = GzDecoder::new(&body[..]); + let mut s = String::with_capacity(body.len()); + + let data = gzip_decoder + .read_to_string(&mut s) + .ok() + .map(|_| &s[..]) + .or_else(|| std::str::from_utf8(&body).ok()) + .unwrap(); + + let mut out_path = PathBuf::from(&self.out_path); + out_path.push("sent_pings"); + std::fs::create_dir_all(&out_path).unwrap(); + + let mut components = url.rsplit('/'); + let docid = components.next().unwrap(); + let _doc_version = components.next().unwrap(); + let doctype = components.next().unwrap(); + out_path.push(format!("{doctype}-{docid}.json")); + let mut fp = File::create(out_path).unwrap(); + + // pseudo-JSON, let's hope this works. + writeln!(fp, "{{").unwrap(); + writeln!(fp, " \"url\": {url:?},").unwrap(); + for (key, val) in headers { + writeln!(fp, " \"{key}\": \"{val}\",").unwrap(); + } + writeln!(fp, "}}").unwrap(); + + let data: serde_json::Value = serde_json::from_str(data).unwrap(); + let json = serde_json::to_string_pretty(&data).unwrap(); + writeln!(fp, "{json}").unwrap(); + + net::UploadResult::http_status(200) + } +} + +#[unsafe(no_mangle)] +unsafe extern "C" fn startup(path: *const c_char) { + env_logger::init(); + log::info!("Startup invoked"); + + let data_path = unsafe { + let path = CStr::from_ptr(path); + PathBuf::from(path.to_str().unwrap()) + }; + log::info!("Path: {}", data_path.display()); + + let uploader = MovingUploader::new(data_path.display().to_string()); + let cfg = ConfigurationBuilder::new(true, data_path, "glean.sym.sample") + .with_server_endpoint("invalid-test-host") + .with_use_core_mps(true) + .with_uploader(uploader) + .with_internal_pings(false) + .build(); + + let client_info = ClientInfoMetrics { + app_build: env!("CARGO_PKG_VERSION").to_string(), + app_display_version: env!("CARGO_PKG_VERSION").to_string(), + channel: None, + locale: None, + }; + + _ = &*glean_metrics::prototype; + glean::initialize(cfg, client_info); + + glean_metrics::test_metrics::sample_counter.add(1); +} + +#[unsafe(no_mangle)] +unsafe extern "C" fn submit() { + log::info!("Submit invoked"); + + glean_metrics::prototype.submit(None); +} + +#[unsafe(no_mangle)] +unsafe extern "C" fn shutdown() { + log::info!("Shutdown invoked"); + glean::shutdown(); +} diff --git a/samples/glean-sym-test/xul/metrics.yaml b/samples/glean-sym-test/xul/metrics.yaml new file mode 100644 index 0000000000..7bbeb736d1 --- /dev/null +++ b/samples/glean-sym-test/xul/metrics.yaml @@ -0,0 +1,22 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +--- + +$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0 + +test.metrics: + sample_counter: + type: counter + description: | + Just testing booleans + bugs: + - https://bugzilla.mozilla.org/123456789 + data_reviews: + - N/A + notification_emails: + - CHANGE-ME@example.com + expires: never + send_in_pings: + - prototype diff --git a/samples/glean-sym-test/xul/pings.yaml b/samples/glean-sym-test/xul/pings.yaml new file mode 100644 index 0000000000..106b3b7f8d --- /dev/null +++ b/samples/glean-sym-test/xul/pings.yaml @@ -0,0 +1,18 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +--- + +$schema: moz://mozilla.org/schemas/glean/pings/2-0-0 + +prototype: + description: | + A sample custom ping. + include_client_id: true + bugs: + - https://bugzilla.mozilla.org/123456789 + data_reviews: + - N/A + notification_emails: + - CHANGE-ME@example.com diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index efb37606f6..1042bcd8d8 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -433,6 +433,12 @@ who = "Jan-Erik Rediger " criteria = "safe-to-deploy" delta = "0.2.141 -> 0.2.146" +[[audits.libloading]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +version = "0.9.0" +notes = "The exposed functionality is inherently unsafe, but all such functions are correctly tagged as `unsafe` and requirements documented. It also includes extensive documentation about the choices made about differing platform APIs" + [[audits.log]] who = "Jan-Erik Rediger " criteria = "safe-to-deploy" @@ -516,6 +522,11 @@ criteria = "safe-to-deploy" delta = "1.0.63 -> 1.0.66" notes = "Removed special support for some really old Rust versions" +[[audits.proc-macro2]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +delta = "1.0.94 -> 1.0.106" + [[audits.quote]] who = "Jan-Erik Rediger " criteria = "safe-to-deploy" @@ -528,6 +539,11 @@ criteria = "safe-to-deploy" delta = "1.0.28 -> 1.0.31" notes = "Minimal changes and removal of the build.rs" +[[audits.quote]] +who = "Jan-Erik Rediger " +criteria = "safe-to-deploy" +delta = "1.0.40 -> 1.0.45" + [[audits.redox_syscall]] who = "Jan-Erik Rediger " criteria = "safe-to-deploy" diff --git a/supply-chain/config.toml b/supply-chain/config.toml index c41551eb22..04834b3dc4 100644 --- a/supply-chain/config.toml +++ b/supply-chain/config.toml @@ -88,10 +88,6 @@ criteria = "safe-to-deploy" version = "0.7.0" criteria = "safe-to-run" -[[exemptions.hermit-abi]] -version = "0.2.6" -criteria = "safe-to-deploy" - [[exemptions.humantime]] version = "2.1.0" criteria = "safe-to-deploy" @@ -152,6 +148,10 @@ criteria = "safe-to-run" version = "0.3.7" criteria = "safe-to-run" +[[exemptions.prettyplease]] +version = "0.2.37" +criteria = "safe-to-deploy" + [[exemptions.pulldown-cmark]] version = "0.13.0" criteria = "safe-to-run" diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 9b91ce80a7..36744f6fe2 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -78,8 +78,8 @@ user-login = "dtolnay" user-name = "David Tolnay" [[publisher.syn]] -version = "2.0.98" -when = "2025-02-02" +version = "2.0.117" +when = "2026-02-20" user-id = 3618 user-login = "dtolnay" user-name = "David Tolnay" @@ -217,43 +217,43 @@ user-id = 127697 user-login = "bendk" [[publisher.windows-core]] -version = "0.61.2" -when = "2025-05-19" +version = "0.62.2" +when = "2025-10-06" user-id = 64539 user-login = "kennykerr" user-name = "Kenny Kerr" [[publisher.windows-implement]] -version = "0.60.0" -when = "2025-03-18" +version = "0.60.2" +when = "2025-10-06" user-id = 64539 user-login = "kennykerr" user-name = "Kenny Kerr" [[publisher.windows-interface]] -version = "0.59.1" -when = "2025-03-18" +version = "0.59.3" +when = "2025-10-06" user-id = 64539 user-login = "kennykerr" user-name = "Kenny Kerr" [[publisher.windows-link]] -version = "0.1.3" -when = "2025-06-12" +version = "0.2.1" +when = "2025-10-06" user-id = 64539 user-login = "kennykerr" user-name = "Kenny Kerr" [[publisher.windows-result]] -version = "0.3.4" -when = "2025-05-19" +version = "0.4.1" +when = "2025-10-06" user-id = 64539 user-login = "kennykerr" user-name = "Kenny Kerr" [[publisher.windows-strings]] -version = "0.4.2" -when = "2025-05-19" +version = "0.5.1" +when = "2025-10-06" user-id = 64539 user-login = "kennykerr" user-name = "Kenny Kerr" @@ -490,6 +490,11 @@ criteria = "safe-to-deploy" delta = "0.4.1 -> 0.5.0" notes = "Minor changes for a `no_std` upgrade but otherwise everything looks as expected." +[[audits.bytecode-alliance.audits.hermit-abi]] +who = "Chris Fallin " +criteria = "safe-to-deploy" +version = "0.1.19" + [[audits.bytecode-alliance.audits.iana-time-zone-haiku]] who = "Dan Gohman " criteria = "safe-to-deploy" @@ -1438,6 +1443,13 @@ delta = "1.0.92 -> 1.0.93" notes = "No `unsafe`-related changes." aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT" +[[audits.google.audits.proc-macro2]] +who = "Daniel Cheng " +criteria = "safe-to-deploy" +delta = "1.0.93 -> 1.0.94" +notes = "Minor doc changes and clippy lint adjustments+fixes." +aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT" + [[audits.google.audits.quote]] who = "Lukasz Anforowicz " criteria = "safe-to-deploy" @@ -1471,6 +1483,23 @@ delta = "1.0.37 -> 1.0.38" notes = "Still no unsafe" aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT" +[[audits.google.audits.quote]] +who = "Daniel Cheng " +criteria = "safe-to-deploy" +delta = "1.0.38 -> 1.0.39" +notes = "Only minor changes for clippy lints and documentation." +aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT" + +[[audits.google.audits.quote]] +who = "Lukasz Anforowicz " +criteria = "safe-to-deploy" +delta = "1.0.39 -> 1.0.40" +notes = """ +The delta is just a simplification of how `tokens.extend(...)` call is made. +Still no `unsafe` anywhere. +""" +aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT" + [[audits.google.audits.regex-automata]] who = "Justin Green " criteria = "safe-to-run" @@ -1974,13 +2003,6 @@ start = "2025-03-18" end = "2026-03-25" aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" -[[audits.mozilla.audits.android-tzdata]] -who = "Mark Hammond " -criteria = "safe-to-deploy" -version = "0.1.1" -notes = "Small crate parsing a file. No unsafe code" -aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" - [[audits.mozilla.audits.android_logger]] who = "Jan-Erik Rediger " criteria = "safe-to-deploy" @@ -2126,6 +2148,12 @@ delta = "0.4.19 -> 0.4.40" notes = "Significant refactor of both implementation and dependencies." aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" +[[audits.mozilla.audits.chrono]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.4.41 -> 0.4.42" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + [[audits.mozilla.audits.crossbeam-channel]] who = "Glenn Watson " criteria = "safe-to-deploy" @@ -2247,12 +2275,24 @@ criteria = "safe-to-deploy" delta = "0.9.1 -> 0.10.0" aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" +[[audits.mozilla.audits.hermit-abi]] +who = "Mike Hommey " +criteria = "safe-to-deploy" +delta = "0.1.19 -> 0.2.6" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + [[audits.mozilla.audits.iana-time-zone]] who = "Mark Hammond " criteria = "safe-to-deploy" delta = "0.1.61 -> 0.1.63" aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" +[[audits.mozilla.audits.iana-time-zone]] +who = "Erich Gubler " +criteria = "safe-to-deploy" +delta = "0.1.63 -> 0.1.64" +aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml" + [[audits.mozilla.audits.lazy_static]] who = "Nika Layzell " criteria = "safe-to-deploy" diff --git a/tools/glean-sym-parser/Cargo.toml b/tools/glean-sym-parser/Cargo.toml new file mode 100644 index 0000000000..b0fd5b548c --- /dev/null +++ b/tools/glean-sym-parser/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "glean-sym-parser" +version = "0.1.0" +authors = ["The Glean Team "] +description = "A parser & compiler to generate the bare minimum to call UniFFI-generated code over FFI" +repository = "https://github.com/mozilla/glean" +license = "MPL-2.0" +edition = "2024" + +[dependencies] +prettyplease = "0.2.37" +proc-macro2 = "1.0.106" +quote = "1.0.45" +syn = "2.0.117" +weedle2 = "5.0.0" diff --git a/tools/glean-sym-parser/src/bin/generator.rs b/tools/glean-sym-parser/src/bin/generator.rs new file mode 100644 index 0000000000..8f2ba771cd --- /dev/null +++ b/tools/glean-sym-parser/src/bin/generator.rs @@ -0,0 +1,14 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::{env, fs}; + +fn main() { + let mut args = env::args().skip(1); + let udl_file = args.next().expect("need path to UDL file"); + let udl_src = fs::read_to_string(udl_file).expect("unable to read UDL file"); + + let output = glean_sym_parser::generate(&udl_src); + print!("{output}"); +} diff --git a/tools/glean-sym-parser/src/lib.rs b/tools/glean-sym-parser/src/lib.rs new file mode 100755 index 0000000000..71bede5552 --- /dev/null +++ b/tools/glean-sym-parser/src/lib.rs @@ -0,0 +1,203 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use std::fmt::Write; + +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use weedle::Definition::*; +use weedle::argument::Argument::{self, Single}; +use weedle::interface::InterfaceMember; + +use type_resolver::TypeResolver; + +mod type_resolver; + +const PREAMBLE: &str = r#"// DO NOT MODIFY! +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +// This file is generated by tools/glean-sym-parser. +// Run `-p glean-sym-parser -- glean-core/src/glean.udl > glean-core/glean-sym/src/metrics.rs` +// to regenerate it. +// `glean-sym` tests ensure the vendored copy is unmodified. +// This can be verified by running `cargo test -p glean-sym`. +#![allow(clippy::all)] +#![cfg_attr(rustfmt, rustfmt_skip)] + +use crate::types::*; +use crate::util::*; +"#; + +#[derive(Default)] +struct FnArgs { + arg_names: Vec, + fn_args: Vec, + extern_fn_args: Vec, + destroys: Vec, +} + +impl FnArgs { + fn from_args(args: &[Argument<'_>]) -> Self { + let mut this = Self::default(); + for arg in args { + let Single(arg) = arg else { continue }; + let arg_name = format_ident!("{}", arg.identifier.0); + let arg_type = arg.type_.type_.resolve(); + let extern_arg_type = arg.type_.type_.resolve_ffi(); + this.arg_names.push(quote! { #arg_name }); + this.fn_args.push(quote! { #arg_name: #arg_type }); + this.extern_fn_args + .push(quote! { #arg_name: #extern_arg_type }); + this.destroys.push(quote! { #arg_name.destroy(); }) + } + this.destroys.reverse(); + this + } + + fn consume( + self, + ) -> ( + Vec, + Vec, + Vec, + Vec, + ) { + ( + self.arg_names, + self.fn_args, + self.extern_fn_args, + self.destroys, + ) + } +} + +pub fn generate(content: &str) -> String { + let parsed = weedle::parse(content).unwrap(); + + let mut tokens = vec![]; + let mut bindings = vec![]; + + for elem in parsed { + let Interface(iface) = elem else { continue }; + let ident = iface.identifier; + if !ident.0.ends_with("Metric") { + continue; + } + + let structname = ident.0.to_lowercase().replace("_", ""); + let ident = format_ident!("{}", ident.0); + let extern_fn_ident = format_ident!("uniffi_glean_core_fn_clone_{}", structname); + tokens.push(quote! { + #[derive(uniffi::Record)] + pub struct #ident { + handle: u64 + } + + impl #ident { + unsafe fn clone_handle(&self) -> u64 { + unsafe { + let mut call_status = uniffi::RustCallStatus::default(); + std::mem::transmute((crate::GLEAN.#extern_fn_ident)(std::mem::transmute(self.handle), &mut call_status)) + } + } + } + }); + bindings.push(quote! { + fn #extern_fn_ident(handle: u64, call_status: &mut ::uniffi::RustCallStatus) -> u64; + }); + + let mut fns = vec![]; + let members = iface.members; + for member in members.body { + match member { + InterfaceMember::Constructor(ctor) => { + let extern_fn_ident = + format_ident!("uniffi_glean_core_fn_constructor_{}_new", structname); + let all_args = FnArgs::from_args(&ctor.args.body.list); + let (arg_names, fn_args, extern_fn_args, destroys) = all_args.consume(); + fns.push(quote! { + pub fn new(#(#fn_args,)*) -> Self { + unsafe { + #( + let #arg_names = uniffi::FfiConverter::::lower(#arg_names); + )* + let mut call_status = uniffi::RustCallStatus::default(); + let handle = (crate::GLEAN.#extern_fn_ident)(#(#arg_names.clone_for_ffi(),)* &mut call_status); + #( + #destroys + )* + Self { handle } + } + } + }); + bindings.push(quote! { + fn #extern_fn_ident(#(#extern_fn_args,)* call_status: &mut ::uniffi::RustCallStatus) -> u64; + }); + } + InterfaceMember::Operation(op) => { + let Some(ident) = op.identifier else { + panic!("no identifier for op!") + }; + let fn_ident = format_ident!("{}", ident.0); + let extern_fn_ident = + format_ident!("uniffi_glean_core_fn_method_{}_{}", structname, ident.0); + let ret_type = type_resolver::return_type(&op.return_type); + let extern_fn_ret_type = type_resolver::return_type_ffi(&op.return_type); + + let all_args = FnArgs::from_args(&op.args.body.list); + let (arg_names, fn_args, extern_fn_args, destroys) = all_args.consume(); + + fns.push(quote! { + pub fn #fn_ident(&self, #(#fn_args),*) #ret_type { + unsafe { + let this = self.clone_handle(); + #( + let #arg_names = uniffi::FfiConverter::::lower(#arg_names); + )* + let mut call_status = uniffi::RustCallStatus::default(); + let res = (crate::GLEAN.#extern_fn_ident)(this, #(#arg_names.clone_for_ffi(),)* &mut call_status); + #( + #destroys + )* + uniffi::FfiConverter::::try_lift(res).unwrap() + } + } + }); + bindings.push(quote! { + fn #extern_fn_ident(handle: u64, #(#extern_fn_args,)* call_status: &mut ::uniffi::RustCallStatus) #extern_fn_ret_type; + }); + } + _ => todo!(), + } + } + + tokens.push(quote! { + impl #ident { + #(#fns)* + } + }); + } + + tokens.push(quote! { + library_binding! { + fn ffi_glean_core_rustbuffer_from_bytes(bytes: ::uniffi::ForeignBytes, call_status: &mut ::uniffi::RustCallStatus) -> ::uniffi::RustBuffer; + #(#bindings)* + } + }); + + let mut code = String::new(); + for token in tokens { + writeln!(&mut code, "{token}").unwrap(); + } + + let mut output = String::new(); + writeln!(&mut output, "{PREAMBLE}").unwrap(); + let file = syn::parse_file(&code).unwrap(); + let code = prettyplease::unparse(&file); + writeln!(&mut output, "{code}").unwrap(); + + output +} diff --git a/tools/glean-sym-parser/src/type_resolver.rs b/tools/glean-sym-parser/src/type_resolver.rs new file mode 100644 index 0000000000..1ea7c4aa34 --- /dev/null +++ b/tools/glean-sym-parser/src/type_resolver.rs @@ -0,0 +1,282 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. + +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use weedle::types::ReturnType; + +fn resolve_builtin_type(name: &str) -> Option { + match name { + "string" => Some(quote! { String }), + "bytes" => Some(quote! { Vec }), + "u8" => Some(quote! { u8 }), + "i8" => Some(quote! { i8 }), + "u16" => Some(quote! { u16 }), + "i16" => Some(quote! { i16 }), + "u32" => Some(quote! { u32 }), + "i32" => Some(quote! { i32 }), + "u64" => Some(quote! { u64 }), + "i64" => Some(quote! { i64 }), + "f32" => Some(quote! { f32 }), + "f64" => Some(quote! { f64 }), + "void" => Some(quote! { () }), + _ => None, + } +} + +fn resolve_builtin_type_ffi(name: &str) -> Option { + match name { + "string" => Some(quote! { uniffi::RustBuffer }), + "bytes" => Some(quote! { uniffi::RustBuffer }), + "u8" => Some(quote! { u8 }), + "i8" => Some(quote! { i8 }), + "u16" => Some(quote! { u16 }), + "i16" => Some(quote! { i16 }), + "u32" => Some(quote! { u32 }), + "i32" => Some(quote! { i32 }), + "u64" => Some(quote! { u64 }), + "i64" => Some(quote! { i64 }), + "f32" => Some(quote! { f32 }), + "f64" => Some(quote! { f64 }), + "void" => Some(quote! { () }), + _ => None, + } +} + +pub trait TypeResolver { + fn resolve(&self) -> TokenStream; + + fn resolve_ffi(&self) -> TokenStream; +} + +impl TypeResolver for &weedle::types::Type<'_> { + fn resolve(&self) -> TokenStream { + (*self).resolve() + } + + fn resolve_ffi(&self) -> TokenStream { + (*self).resolve_ffi() + } +} + +impl TypeResolver for weedle::types::Type<'_> { + fn resolve(&self) -> TokenStream { + match self { + weedle::types::Type::Single(t) => match t { + weedle::types::SingleType::Any(_) => panic!("no support for `any` types"), + weedle::types::SingleType::NonAny(t) => t.resolve(), + }, + weedle::types::Type::Union(_) => panic!("no support for union types yet"), + } + } + + fn resolve_ffi(&self) -> TokenStream { + match self { + weedle::types::Type::Single(t) => match t { + weedle::types::SingleType::Any(_) => panic!("no support for `any` types"), + weedle::types::SingleType::NonAny(t) => t.resolve_ffi(), + }, + weedle::types::Type::Union(_) => panic!("no support for union types yet"), + } + } +} + +impl TypeResolver for weedle::types::NonAnyType<'_> { + fn resolve(&self) -> TokenStream { + match self { + weedle::types::NonAnyType::Boolean(t) => t.resolve(), + weedle::types::NonAnyType::Identifier(t) => t.resolve(), + weedle::types::NonAnyType::Integer(t) => t.resolve(), + weedle::types::NonAnyType::FloatingPoint(t) => t.resolve(), + weedle::types::NonAnyType::Sequence(t) => t.resolve(), + weedle::types::NonAnyType::RecordType(t) => t.resolve(), + _ => panic!("no support for type {:?}", self), + } + } + + fn resolve_ffi(&self) -> TokenStream { + match self { + weedle::types::NonAnyType::Boolean(t) => t.resolve_ffi(), + weedle::types::NonAnyType::Identifier(t) => t.resolve_ffi(), + weedle::types::NonAnyType::Integer(t) => t.resolve_ffi(), + weedle::types::NonAnyType::FloatingPoint(t) => t.resolve_ffi(), + weedle::types::NonAnyType::Sequence(t) => t.resolve_ffi(), + weedle::types::NonAnyType::RecordType(t) => t.resolve_ffi(), + _ => panic!("no support for type {:?}", self), + } + } +} + +impl TypeResolver for weedle::types::MayBeNull { + fn resolve(&self) -> TokenStream { + let type_ = self.type_.resolve(); + match self.q_mark { + None => type_, + Some(_) => { + quote! { Option<#type_> } + } + } + } + + fn resolve_ffi(&self) -> TokenStream { + let type_ = self.type_.resolve_ffi(); + match self.q_mark { + None => type_, + Some(_) => { + quote! { uniffi::RustBuffer } + } + } + } +} + +impl TypeResolver for weedle::types::IntegerType { + fn resolve(&self) -> TokenStream { + panic!( + "WebIDL integer types not implemented ({:?}); consider using u8, u16, u32 or u64", + self + ) + } + fn resolve_ffi(&self) -> TokenStream { + self.resolve() + } +} + +impl TypeResolver for weedle::types::FloatingPointType { + fn resolve(&self) -> TokenStream { + match self { + weedle::types::FloatingPointType::Float(t) => t.resolve(), + weedle::types::FloatingPointType::Double(t) => t.resolve(), + } + } + + fn resolve_ffi(&self) -> TokenStream { + match self { + weedle::types::FloatingPointType::Float(t) => t.resolve_ffi(), + weedle::types::FloatingPointType::Double(t) => t.resolve_ffi(), + } + } +} + +impl TypeResolver for weedle::types::SequenceType<'_> { + fn resolve(&self) -> TokenStream { + let t = self.generics.body.as_ref().resolve(); + quote! { Vec<#t> } + } + + fn resolve_ffi(&self) -> TokenStream { + quote! { uniffi::RustBuffer } + } +} + +impl TypeResolver for weedle::types::RecordKeyType<'_> { + fn resolve(&self) -> TokenStream { + use weedle::types::RecordKeyType::*; + match self { + Byte(_) | USV(_) => panic!( + "WebIDL Byte or USV string type not implemented ({self:?}); \ + consider using a string", + ), + DOM(_) => quote! { String }, + NonAny(t) => t.resolve(), + } + } + + fn resolve_ffi(&self) -> TokenStream { + use weedle::types::RecordKeyType::*; + match self { + Byte(_) | USV(_) => panic!( + "WebIDL Byte or USV string type not implemented ({self:?}); \ + consider using a string", + ), + DOM(_) => quote! { uniffi::RustBuffer }, + NonAny(t) => t.resolve_ffi(), + } + } +} + +impl TypeResolver for weedle::types::RecordType<'_> { + fn resolve(&self) -> TokenStream { + let key_type = self.generics.body.0.resolve(); + let value_type = self.generics.body.2.resolve(); + + quote! { ::std::collections::HashMap<#key_type, #value_type> } + } + + fn resolve_ffi(&self) -> TokenStream { + quote! { uniffi::RustBuffer } + } +} + +impl TypeResolver for weedle::common::Identifier<'_> { + fn resolve(&self) -> TokenStream { + match resolve_builtin_type(self.0) { + Some(type_) => type_, + None => { + let ident = format_ident!("{}", self.0); + quote! { #ident } + } + } + } + + fn resolve_ffi(&self) -> TokenStream { + match resolve_builtin_type_ffi(self.0) { + Some(type_) => type_, + None => { + quote! { uniffi::RustBuffer } + } + } + } +} + +impl TypeResolver for weedle::term::Boolean { + fn resolve(&self) -> TokenStream { + quote! { i8 } + } + + fn resolve_ffi(&self) -> TokenStream { + self.resolve() + } +} + +impl TypeResolver for weedle::types::FloatType { + fn resolve(&self) -> TokenStream { + if self.unrestricted.is_some() { + panic!("we don't support `unrestricted float`"); + } + quote! { f32 } + } + + fn resolve_ffi(&self) -> TokenStream { + self.resolve() + } +} + +impl TypeResolver for weedle::types::DoubleType { + fn resolve(&self) -> TokenStream { + if self.unrestricted.is_some() { + panic!("we don't support `unrestricted double`"); + } + quote! { f64 } + } + + fn resolve_ffi(&self) -> TokenStream { + quote! { bool } + } +} + +pub fn return_type(typ: &ReturnType) -> TokenStream { + let ReturnType::Type(typ) = typ else { + panic!("can't handle undefined return type") + }; + let ret = typ.resolve(); + quote! { -> #ret } +} + +pub fn return_type_ffi(typ: &ReturnType) -> TokenStream { + let ReturnType::Type(typ) = typ else { + panic!("can't handle undefined return type") + }; + let ret = typ.resolve_ffi(); + quote! { -> #ret } +}