Skip to content

Commit

Permalink
Update toml dependency to latest version
Browse files Browse the repository at this point in the history
I am in the process of vendoring UniFFI in AOSP, which means that I
have to make it play nice with the existing crates found here:

  https://cs.android.com/android/platform/superproject/+/main:external/rust/crates/

Android tries to only vendor each crate in a single version, so it
would be helpful for me if the toml dependency could be updated.
  • Loading branch information
mgeisler committed Mar 21, 2024
1 parent 23e478c commit ef0de29
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 8 deletions.
69 changes: 67 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion uniffi_bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ heck = "0.4"
once_cell = "1.12"
paste = "1.0"
serde = { version = "1", features = ["derive"] }
toml = "0.5"
toml = "0.8"
uniffi_meta = { path = "../uniffi_meta", version = "=0.26.1" }
uniffi_testing = { path = "../uniffi_testing", version = "=0.26.1" }
uniffi_udl = { path = "../uniffi_udl", version = "=0.26.1" }
Expand Down
5 changes: 3 additions & 2 deletions uniffi_bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,9 @@ fn crate_name_from_cargo_toml(udl_file: &Utf8Path) -> Result<String> {
let file = guess_crate_root(udl_file)?.join("Cargo.toml");
let cargo_toml_bytes =
fs::read(file).context("Can't find Cargo.toml to determine the crate name")?;

let cargo_toml = toml::from_slice::<CargoToml>(&cargo_toml_bytes)?;
let cargo_toml_string =
String::from_utf8(cargo_toml_bytes).context("Could not UTF-8 decode Cargo.toml")?;
let cargo_toml = toml::from_str::<CargoToml>(&cargo_toml_string)?;

let lib_crate_name = cargo_toml
.lib
Expand Down
2 changes: 1 addition & 1 deletion uniffi_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ proc-macro2 = "1.0"
quote = "1.0"
serde = { version = "1.0.136", features = ["derive"] }
syn = { version = "2.0", features = ["full", "visit-mut"] }
toml = "0.5.9"
toml = "0.8"
uniffi_build = { path = "../uniffi_build", version = "=0.26.1", optional = true }
uniffi_meta = { path = "../uniffi_meta", version = "=0.26.1" }

Expand Down
5 changes: 3 additions & 2 deletions uniffi_macros/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ pub fn mod_path() -> syn::Result<String> {
static LIB_CRATE_MOD_PATH: Lazy<Result<String, String>> = Lazy::new(|| {
let file = manifest_path()?;
let cargo_toml_bytes = fs::read(file).map_err(|e| e.to_string())?;

let cargo_toml = toml::from_slice::<CargoToml>(&cargo_toml_bytes)
let cargo_toml_string = String::from_utf8(cargo_toml_bytes)
.map_err(|e| format!("Could not UTF-8 decode `Cargo.toml`: {e}"))?;
let cargo_toml = toml::from_str::<CargoToml>(&cargo_toml_string)
.map_err(|e| format!("Failed to parse `Cargo.toml`: {e}"))?;

let lib_crate_name = cargo_toml
Expand Down

0 comments on commit ef0de29

Please sign in to comment.