Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
288 changes: 182 additions & 106 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ debug = true
lto = "thin"

[patch.crates-io]
# uniffi is using an experimental ffi based on 0.31.
uniffi = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "59b035078322fbc0a605cc3c784cc38214113450" }
uniffi_bindgen = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "59b035078322fbc0a605cc3c784cc38214113450" }
uniffi_pipeline = { git = "https://github.com/mozilla/uniffi-rs.git", rev = "59b035078322fbc0a605cc3c784cc38214113450" }
# dummy crates for m-c integration hacks.
mozilla-central-workspace-hack = { path = "monorepo-hacks/workspace-hack" }
mozbuild = { path = "monorepo-hacks/mozbuild" }
Expand Down
659 changes: 639 additions & 20 deletions DEPENDENCIES.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions components/ads-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ serde = "1"
serde_json = "1"
thiserror = "2"
once_cell = "1.5"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
url = { version = "2", features = ["serde"] }
url-macro = { path = "../support/url-macro" }
uuid = { version = "1.3", features = ["v4"] }
Expand All @@ -37,4 +37,4 @@ mockito = { version = "0.31", default-features = false }
viaduct-dev = { path = "../support/viaduct-dev" }

[build-dependencies]
uniffi = { version = "0.31", features = ["build"] }
uniffi = { version = "0.32", features = ["build"] }
4 changes: 2 additions & 2 deletions components/as-ohttp-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ exclude = ["/ios"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
thiserror = "2"
parking_lot = "0.12"
rusqlite = { version = "0.37.0", features = ["bundled"] }
bhttp = "0.7.2"
ohttp = { version = "0.7.2", default-features = false, features = ["client", "server", "app-svc", "external-sqlite"] }

[build-dependencies]
uniffi = { version = "0.31", features=["build"]}
uniffi = { version = "0.32", features=["build"]}
4 changes: 2 additions & 2 deletions components/autofill/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sync-guid = { path = "../support/guid", features = ["rusqlite_support", "random"
sync15 = { path = "../sync15", features = ["sync-engine"] }
thiserror = "2"
types = { path = "../support/types" }
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
url = { version = "2.2", features = ["serde"] }

[dev-dependencies]
Expand All @@ -33,4 +33,4 @@ nss-as = { path = "../support/rc_crypto/nss" }
error-support = { path = "../support/error", features=["testing"] }

[build-dependencies]
uniffi = { version = "0.31", features=["build"]}
uniffi = { version = "0.32", features=["build"]}
2 changes: 1 addition & 1 deletion components/breach-alerts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["sync-team@mozilla.com"]
license = "MPL-2.0"

[dependencies]
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
error-support = { path = "../support/error" }
interrupt-support = { path = "../support/interrupt" }
parking_lot = ">=0.11,<=0.12"
Expand Down
4 changes: 2 additions & 2 deletions components/context_id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
license = "MPL-2.0"

[build-dependencies]
uniffi = { version = "0.31", features=["build"]}
uniffi = { version = "0.32", features=["build"]}

[dependencies]
chrono = "0.4"
Expand All @@ -15,7 +15,7 @@ parking_lot = "0.12"
serde = "1"
serde_json = "1"
thiserror = "2"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
url = "2"
uuid = { version = "1.3", features = ["v4"]}
viaduct = { path = "../viaduct" }
Expand Down
4 changes: 2 additions & 2 deletions components/crashtest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exclude = ["/android", "/ios"]
[dependencies]
log = "0.4"
thiserror = "2"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }

[build-dependencies]
uniffi = { version = "0.31", features=["build"]}
uniffi = { version = "0.32", features=["build"]}
2 changes: 1 addition & 1 deletion components/example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "MPL-2.0"
[dependencies]
# UniFFI is a dependency for any shared Rust component, make the version match what the other
# components are using.
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
# app-services support crates that you probably want to use.
error-support = { path = "../support/error" }
interrupt-support = { path = "../support/interrupt" }
Expand Down
2 changes: 1 addition & 1 deletion components/filter_adult/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ error-support = { path = "../support/error" }
md-5 = "0.10"
regex = "1"
thiserror = "2"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }

[[bin]]
name = "import-site-list"
Expand Down
4 changes: 2 additions & 2 deletions components/fxa-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ error-support = { path = "../support/error" }
thiserror = "2"
anyhow = "1.0"
sync-guid = { path = "../support/guid", features = ["random"] }
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
payload-support = { path = "../support/payload" }
nss-as = { path = "../support/rc_crypto/nss" }

[build-dependencies]
uniffi = { version = "0.31", features = ["build"] }
uniffi = { version = "0.32", features = ["build"] }

[dev-dependencies]
viaduct-dev = { path = "../support/viaduct-dev"}
Expand Down
2 changes: 1 addition & 1 deletion components/init_rust_components/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ keydb = ["nss-as/keydb"]
ohttp = ["dep:viaduct", "viaduct/ohttp"]

[dependencies]
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
nss-as = { path = "../support/rc_crypto/nss" }
viaduct = { path = "../viaduct", optional = true }
4 changes: 2 additions & 2 deletions components/logins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ rusqlite = { version = "0.37.0", features = ["limits", "unlock_notify"] }
sync-guid = { path = "../support/guid", features = ["rusqlite_support", "random"] }
thiserror = "2"
anyhow = "1.0"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
async-trait = { version = "0.1", optional = true }
futures = { version = "0.3", optional = true, features = ["executor"] }

[build-dependencies]
uniffi = { version = "0.31", features = ["build"] }
uniffi = { version = "0.32", features = ["build"] }

[dev-dependencies]
error-support = { path = "../support/error", features = ["testing"] }
Expand Down
4 changes: 2 additions & 2 deletions components/merino/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
exclude = ["/android"]

[dependencies]
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
url = "2"
Expand All @@ -14,4 +14,4 @@ error-support = { path = "../support/error" }
thiserror = "2"

[build-dependencies]
uniffi = { version = "0.31", features = ["build"] }
uniffi = { version = "0.32", features = ["build"] }
4 changes: 2 additions & 2 deletions components/nimbus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ uuid = { version = "1.3", features = ["serde", "v4"]}
sha2 = "^0.10"
hex = "0.4"
once_cell = "1"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
chrono = { version = "0.4", features = ["serde"]}
icu_segmenter = "2"
error-support = { path = "../support/error" }
Expand All @@ -42,7 +42,7 @@ regex = { version = "1.9", optional = true }
firefox-versioning = { path = "../support/firefox-versioning", optional = true }

[build-dependencies]
uniffi = { version = "0.31", features = ["build"] }
uniffi = { version = "0.32", features = ["build"] }

[dev-dependencies]
error-support = { path = "../support/error", features = ["testing"] }
Expand Down
48 changes: 48 additions & 0 deletions components/nimbus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,53 @@ pub use evaluator::TargetingAttributes;

pub(crate) const SLUG_REPLACEMENT_PATTERN: &str = "{experiment}";

// Custom type definitions need to live in the root module while using UDL
// https://github.com/mozilla/uniffi-rs/issues/2968

#[cfg(feature = "stateful-uniffi-bindings")]
use json::JsonObject;

#[cfg(feature = "stateful-uniffi-bindings")]
uniffi::custom_type!(JsonObject, String, {
remote,
try_lift: |val| {
let json: serde_json::Value = serde_json::from_str(&val)?;

match json.as_object() {
Some(obj) => Ok(obj.clone()),
_ => Err(uniffi::deps::anyhow::anyhow!(
"Unexpected JSON-non-object in the bagging area"
)),
}
},
lower: |obj| serde_json::Value::Object(obj).to_string(),
});

#[cfg(feature = "stateful-uniffi-bindings")]
use json::PrefValue;

#[cfg(feature = "stateful-uniffi-bindings")]
uniffi::custom_type!(PrefValue, String, {
remote,
try_lift: |val| {
// Raw strings that are not valid JSON (e.g. pref values read directly from Gecko)
// should be treated as JSON string values.
let json: serde_json::Value = match serde_json::from_str(&val) {
Ok(json) => json,
Err(_) => serde_json::Value::String(val),
};
let is_valid_pref_type = json.is_string() || json.is_boolean()
|| (json.is_number() && !json.is_f64()) || json.is_null();
if is_valid_pref_type {
Ok(json)
} else {
Err(anyhow::anyhow!(format!("Value {} is not a string, boolean, number, or null, or is a float", json)))
}
},
lower: |val| {
val.to_string()
}
});

#[cfg(test)]
mod tests;
39 changes: 0 additions & 39 deletions components/nimbus/src/stateful/nimbus_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,44 +1086,5 @@ impl NimbusStringHelper {
}
}

#[cfg(feature = "stateful-uniffi-bindings")]
uniffi::custom_type!(JsonObject, String, {
remote,
try_lift: |val| {
let json: Value = serde_json::from_str(&val)?;

match json.as_object() {
Some(obj) => Ok(obj.clone()),
_ => Err(uniffi::deps::anyhow::anyhow!(
"Unexpected JSON-non-object in the bagging area"
)),
}
},
lower: |obj| serde_json::Value::Object(obj).to_string(),
});

#[cfg(feature = "stateful-uniffi-bindings")]
uniffi::custom_type!(PrefValue, String, {
remote,
try_lift: |val| {
// Raw strings that are not valid JSON (e.g. pref values read directly from Gecko)
// should be treated as JSON string values.
let json: Value = match serde_json::from_str(&val) {
Ok(json) => json,
Err(_) => Value::String(val),
};
let is_valid_pref_type = json.is_string() || json.is_boolean()
|| (json.is_number() && !json.is_f64()) || json.is_null();
if is_valid_pref_type {
Ok(json)
} else {
Err(anyhow::anyhow!(format!("Value {} is not a string, boolean, number, or null, or is a float", json)))
}
},
lower: |val| {
val.to_string()
}
});

#[cfg(feature = "stateful-uniffi-bindings")]
uniffi::include_scaffolding!("nimbus");
8 changes: 4 additions & 4 deletions components/places/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ error-support = { path = "../support/error" }
sync-guid = { path = "../support/guid", features = ["rusqlite_support", "random"]}
thiserror = "2"
anyhow = "1.0"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }

# glean-sym is only used on Android and iOS.
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
glean-sym = { git = "https://github.com/mozilla/glean", tag = "v68.0.0", optional = true }
glean-sym = { version = "70.0.0", optional = true }

[dev-dependencies]
error-support = { path = "../support/error", features = ["testing"] }
tempfile = "3.1"
sql-support = { path = "../support/sql" }

[build-dependencies]
uniffi = { version = "0.31", features=["build"]}
glean-build = { git = "https://github.com/mozilla/glean", tag = "v68.0.0" }
uniffi = { version = "0.32", features=["build"]}
glean-build = { git = "https://github.com/mozilla/glean", tag = "v70.0.0" }
33 changes: 0 additions & 33 deletions components/places/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,6 @@ pub type BookmarkFolder = crate::storage::bookmarks::fetch::Folder;
pub type BookmarkSeparator = crate::storage::bookmarks::fetch::Separator;
pub use crate::storage::bookmarks::fetch::BookmarkData;

uniffi::custom_type!(Url, String, {
remote,
try_lift: |val| {
match Url::parse(val.as_str()) {
Ok(url) => Ok(url),
Err(e) => Err(PlacesApiError::UrlParseFailed {
reason: e.to_string(),
}
.into()),
}
},
lower: |obj| obj.into(),
});

uniffi::custom_type!(PlacesTimestamp, i64, {
remote,
try_lift: |val| Ok(PlacesTimestamp(val as u64)),
lower: |obj| obj.as_millis() as i64,
});

uniffi::custom_type!(VisitTransitionSet, i32, {
try_lift: |val| {
Ok(VisitTransitionSet::from_u16(val as u16).expect("Bug: Invalid VisitTransitionSet"))
},
lower: |obj| VisitTransitionSet::into_u16(obj) as i32,
});

uniffi::custom_type!(Guid, String, {
remote,
try_lift: |val| Ok(Guid::new(val.as_str())),
lower: |obj| obj.into(),
});

// Check for multiple write connections open at the same time
//
// One potential cause of #5040 is that Fenix is somehow opening multiiple write connections to
Expand Down
36 changes: 36 additions & 0 deletions components/places/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,40 @@ pub mod glean_metrics {
include!(concat!(env!("OUT_DIR"), "/glean_metrics.rs"));
}

// Custom type definitions need to live in the root module while using UDL
// https://github.com/mozilla/uniffi-rs/issues/2968
//
uniffi::custom_type!(Url, String, {
remote,
try_lift: |val| {
match Url::parse(val.as_str()) {
Ok(url) => Ok(url),
Err(e) => Err(PlacesApiError::UrlParseFailed {
reason: e.to_string(),
}
.into()),
}
},
lower: |obj| obj.into(),
});

uniffi::custom_type!(PlacesTimestamp, i64, {
remote,
try_lift: |val| Ok(PlacesTimestamp(val as u64)),
lower: |obj| obj.as_millis() as i64,
});

uniffi::custom_type!(VisitTransitionSet, i32, {
try_lift: |val| {
Ok(VisitTransitionSet::from_u16(val as u16).expect("Bug: Invalid VisitTransitionSet"))
},
lower: |obj| VisitTransitionSet::into_u16(obj) as i32,
});

uniffi::custom_type!(Guid, String, {
remote,
try_lift: |val| Ok(Guid::new(val.as_str())),
lower: |obj| obj.into(),
});

uniffi::include_scaffolding!("places");
4 changes: 2 additions & 2 deletions components/push/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ error-support = { path = "../support/error" }
sql-support = { path = "../support/sql" }
rc_crypto = { path = "../support/rc_crypto", features = ["ece"] }
thiserror = "2"
uniffi = { version = "0.31" }
uniffi = { version = "0.32" }
types = { path = "../support/types" }

[build-dependencies]
uniffi = { version = "0.31", features = ["build"] }
uniffi = { version = "0.32", features = ["build"] }

[dev-dependencies]
error-support = { path = "../support/error", features = ["testing"] }
Expand Down
Loading
Loading