Bug 1805809 - Update uniffi to 0.21.1 for more determinism across platforms. r=janerik,supply-chain-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D164896
This commit is contained in:
Mike Hommey 2022-12-19 22:52:29 +00:00
Родитель ce6cd37bc7
Коммит 18d0f30768
29 изменённых файлов: 484 добавлений и 221 удалений

34
Cargo.lock сгенерированный
Просмотреть файл

@ -5777,9 +5777,9 @@ checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]] [[package]]
name = "uniffi" name = "uniffi"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f54af5ada67d1173457a99a7bb44a7917f63e7466764cb4714865c7a6678b830" checksum = "b983553c0d1ad73547c65fa0c399aa800bee4a70ad330198e1c7a523212da5ee"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes 1.2.1", "bytes 1.2.1",
@ -5887,9 +5887,7 @@ dependencies = [
[[package]] [[package]]
name = "uniffi_bindgen" name = "uniffi_bindgen"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12cc4af3c0180c7e86c4a3acf2b6587af04ba2567b1e948993df10f421796621"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"askama", "askama",
@ -5910,9 +5908,9 @@ dependencies = [
[[package]] [[package]]
name = "uniffi_build" name = "uniffi_build"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "510287c368a9386eb731ebe824a6fc6c82a105e20d020af1aa20519c1c1561db" checksum = "d035e50433ee3d52ab0dcdcf3b9b26f2cc2ec39294b3c07d95865a518709455f"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"camino", "camino",
@ -5920,10 +5918,20 @@ dependencies = [
] ]
[[package]] [[package]]
name = "uniffi_macros" name = "uniffi_checksum_derive"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8604503caa2cbcf271578dc51ca236d40e3b22e1514ffa2e638e2c39f6ad10" checksum = "78b6e16d46caf942016997af8bbdf4b163bf8ae3deb0b667d9643de7b7ffd4c9"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "uniffi_macros"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c96a574677566f83ea8458dac1dd7792fd63e7c3f9dbcd865f0e8d6f8057b127"
dependencies = [ dependencies = [
"bincode", "bincode",
"camino", "camino",
@ -5940,11 +5948,13 @@ dependencies = [
[[package]] [[package]]
name = "uniffi_meta" name = "uniffi_meta"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd9417cc653937681436b93838d8c5f97a5b8c58697813982ee8810bd1dc3b57" checksum = "729835442da829c9b6f7c111c76cf87b2498e129101203bec94f0c39a3296a38"
dependencies = [ dependencies = [
"serde", "serde",
"siphasher",
"uniffi_checksum_derive",
] ]
[[package]] [[package]]

Просмотреть файл

@ -182,8 +182,12 @@ path = "third_party/rust/mio-0.6.23"
# duplicate crates. # duplicate crates.
[patch."https://github.com/mozilla/uniffi-rs.git"] [patch."https://github.com/mozilla/uniffi-rs.git"]
uniffi = "=0.21.0" uniffi = "=0.21.1"
uniffi_bindgen = "=0.21.0" #uniffi_bindgen = "=0.21.1"
uniffi_build = "=0.21.0" uniffi_build = "=0.21.1"
uniffi_macros = "=0.21.0" uniffi_macros = "=0.21.1"
weedle2 = "=4.0.0" weedle2 = "=4.0.0"
# Patched to use uniffi_version = 0.21.0 for checksums.
[patch.crates-io.uniffi_bindgen]
path = "third_party/rust/uniffi_bindgen"

Просмотреть файл

@ -1537,6 +1537,12 @@ criteria = "safe-to-deploy"
delta = "0.20.0 -> 0.21.0" delta = "0.20.0 -> 0.21.0"
notes = "Maintained by the Glean and Application Services team." notes = "Maintained by the Glean and Application Services team."
[[audits.uniffi]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.21.0 -> 0.21.1"
notes = "No changes."
[[audits.uniffi_bindgen]] [[audits.uniffi_bindgen]]
who = "Travis Long <tlong@mozilla.com>" who = "Travis Long <tlong@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@ -1560,6 +1566,12 @@ criteria = "safe-to-deploy"
delta = "0.20.0 -> 0.21.0" delta = "0.20.0 -> 0.21.0"
notes = "Maintained by the Glean and Application Services team." notes = "Maintained by the Glean and Application Services team."
[[audits.uniffi_bindgen]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.21.0 -> 0.21.1"
notes = "I authored the changes in this version."
[[audits.uniffi_build]] [[audits.uniffi_build]]
who = "Travis Long <tlong@mozilla.com>" who = "Travis Long <tlong@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@ -1583,6 +1595,18 @@ criteria = "safe-to-deploy"
delta = "0.20.0 -> 0.21.0" delta = "0.20.0 -> 0.21.0"
notes = "Maintained by the Glean and Application Services team." notes = "Maintained by the Glean and Application Services team."
[[audits.uniffi_build]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.21.0 -> 0.21.1"
notes = "No changes."
[[audits.uniffi_checksum_derive]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
version = "0.21.1"
notes = "I authored this crate."
[[audits.uniffi_macros]] [[audits.uniffi_macros]]
who = "Travis Long <tlong@mozilla.com>" who = "Travis Long <tlong@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@ -1606,6 +1630,12 @@ criteria = "safe-to-deploy"
delta = "0.20.0 -> 0.21.0" delta = "0.20.0 -> 0.21.0"
notes = "Maintained by the Glean and Application Services team." notes = "Maintained by the Glean and Application Services team."
[[audits.uniffi_macros]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.21.0 -> 0.21.1"
notes = "No changes."
[[audits.uniffi_meta]] [[audits.uniffi_meta]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>" who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"
@ -1623,6 +1653,12 @@ criteria = "safe-to-deploy"
delta = "0.20.0 -> 0.21.0" delta = "0.20.0 -> 0.21.0"
notes = "Maintained by the Glean and Application Services team." notes = "Maintained by the Glean and Application Services team."
[[audits.uniffi_meta]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.21.0 -> 0.21.1"
notes = "I authored the changes in this version."
[[audits.void]] [[audits.void]]
who = "Bobby Holley <bobbyholley@gmail.com>" who = "Bobby Holley <bobbyholley@gmail.com>"
criteria = "safe-to-deploy" criteria = "safe-to-deploy"

Просмотреть файл

@ -158,6 +158,10 @@ notes = "This is a first-party crate which is entirely unrelated to the crates.i
audit-as-crates-io = false audit-as-crates-io = false
notes = "This is a first-party crate, maintained by the appservices team, which is entirely unrelated to the crates.io package of the same name." notes = "This is a first-party crate, maintained by the appservices team, which is entirely unrelated to the crates.io package of the same name."
[policy.uniffi_bindgen]
audit-as-crates-io = false
notes = "This is a first-party crate, normally vendored, but currently patched in-tree until next update."
[policy.viaduct] [policy.viaduct]
audit-as-crates-io = false audit-as-crates-io = false
notes = "This is a first-party crate, maintained by the appservices team, which is entirely unrelated to the crates.io package of the same name." notes = "This is a first-party crate, maintained by the appservices team, which is entirely unrelated to the crates.io package of the same name."

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"b7bde8b1b6bb7e1420c9c486d7562d1639fbb82a2b6459b8b3b7d15f002377d3","release.toml":"a6602545cd6eb46e44d89ce946d7954957ac00f1c955de54c736fa2cb560b1df","src/ffi/ffidefault.rs":"c7ab752fffed17c3fabb60e818ad1d093482f95dd0bdeae6871287695c583e48","src/ffi/foreignbytes.rs":"37061e2da7135576abccb86fe27b4fefc054586a040f2ca81fe9858d5649e887","src/ffi/foreigncallbacks.rs":"c0974920313ac81dd4bb28a51dd9e9ef50c8ea6d965f0bfdde58c661a4ca719f","src/ffi/mod.rs":"3fb3b74607066e0052fc91168e9473dbf82dbae562f85c33774a7f5f6b350616","src/ffi/rustbuffer.rs":"b773637d9e4651b80cd16f7a02ed75846d02ce0a9e32b718ce644cdba3a83cdd","src/ffi/rustcalls.rs":"4a85a90b0d46974ab9e80e403a1cddaa252337b227e1a672bb6fdbbca5a66259","src/lib.rs":"83614739f8c0c939b217755cfde169a85608a52ea197f63f7850e5765e2c5f97","src/panichook.rs":"9f49c7994a8e5489c1105c488bb3f8c5571bc5f813e7be90441eca15da5c9851","src/testing.rs":"f287d682a8f27465838b2aba91993c635a4dcd281d802dc12c7c75794324123f","tests/ui/proc_macro_arc.rs":"d766dffee3fe6a93522d40f44a7f15592db141fd674034fa5f016e06f510e87b","tests/ui/proc_macro_arc.stderr":"9e7d098abdd47f249ff62fe0a2ee0f8b96282ec5a3be0c48a778baab4624180f","tests/ui/version_mismatch.rs":"16ea359e5853517ee0d0704c015ae8c825533109fbefd715130d0f4a51f15898","tests/ui/version_mismatch.stderr":"aadbd8f3847f5663022d8dd75d6afa3b25dfc8abccd30b386a681f98587d4ceb"},"package":"f54af5ada67d1173457a99a7bb44a7917f63e7466764cb4714865c7a6678b830"} {"files":{"Cargo.toml":"40a5376941ee93f7d3d013862731eaced1121c852bd4df4affe1cd65bf9b68be","release.toml":"a6602545cd6eb46e44d89ce946d7954957ac00f1c955de54c736fa2cb560b1df","src/ffi/ffidefault.rs":"c7ab752fffed17c3fabb60e818ad1d093482f95dd0bdeae6871287695c583e48","src/ffi/foreignbytes.rs":"37061e2da7135576abccb86fe27b4fefc054586a040f2ca81fe9858d5649e887","src/ffi/foreigncallbacks.rs":"c0974920313ac81dd4bb28a51dd9e9ef50c8ea6d965f0bfdde58c661a4ca719f","src/ffi/mod.rs":"3fb3b74607066e0052fc91168e9473dbf82dbae562f85c33774a7f5f6b350616","src/ffi/rustbuffer.rs":"b773637d9e4651b80cd16f7a02ed75846d02ce0a9e32b718ce644cdba3a83cdd","src/ffi/rustcalls.rs":"4a85a90b0d46974ab9e80e403a1cddaa252337b227e1a672bb6fdbbca5a66259","src/lib.rs":"83614739f8c0c939b217755cfde169a85608a52ea197f63f7850e5765e2c5f97","src/panichook.rs":"9f49c7994a8e5489c1105c488bb3f8c5571bc5f813e7be90441eca15da5c9851","src/testing.rs":"f287d682a8f27465838b2aba91993c635a4dcd281d802dc12c7c75794324123f","tests/ui/proc_macro_arc.rs":"d766dffee3fe6a93522d40f44a7f15592db141fd674034fa5f016e06f510e87b","tests/ui/proc_macro_arc.stderr":"9e7d098abdd47f249ff62fe0a2ee0f8b96282ec5a3be0c48a778baab4624180f","tests/ui/version_mismatch.rs":"16ea359e5853517ee0d0704c015ae8c825533109fbefd715130d0f4a51f15898","tests/ui/version_mismatch.stderr":"aadbd8f3847f5663022d8dd75d6afa3b25dfc8abccd30b386a681f98587d4ceb"},"package":"b983553c0d1ad73547c65fa0c399aa800bee4a70ad330198e1c7a523212da5ee"}

7
third_party/rust/uniffi/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package] [package]
edition = "2021" edition = "2021"
name = "uniffi" name = "uniffi"
version = "0.21.0" version = "0.21.1"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"] authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust (runtime support code)" description = "a multi-language bindings generator for rust (runtime support code)"
homepage = "https://mozilla.github.io/uniffi-rs" homepage = "https://mozilla.github.io/uniffi-rs"
@ -23,7 +23,6 @@ keywords = [
] ]
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/mozilla/uniffi-rs" repository = "https://github.com/mozilla/uniffi-rs"
resolver = "2"
[dependencies.anyhow] [dependencies.anyhow]
version = "1" version = "1"
@ -50,11 +49,11 @@ version = "1.0"
version = "1.1.0" version = "1.1.0"
[dependencies.uniffi_bindgen] [dependencies.uniffi_bindgen]
version = "=0.21.0" version = "=0.21.1"
optional = true optional = true
[dependencies.uniffi_macros] [dependencies.uniffi_macros]
version = "=0.21.0" version = "=0.21.1"
[dev-dependencies.trybuild] [dev-dependencies.trybuild]
version = "1" version = "1"

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

86
third_party/rust/uniffi_bindgen/Cargo.lock сгенерированный поставляемый
Просмотреть файл

@ -4,9 +4,9 @@ version = 3
[[package]] [[package]]
name = "anyhow" name = "anyhow"
version = "1.0.65" version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
[[package]] [[package]]
name = "askama" name = "askama"
@ -99,9 +99,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.2.22" version = "3.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86447ad904c7fb335a790c9d7fe3d0d971dc523b8ccd1561a520de9a85302750" checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -138,9 +138,9 @@ dependencies = [
[[package]] [[package]]
name = "fs-err" name = "fs-err"
version = "2.8.1" version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64db3e262960f0662f43a6366788d5f10f7f244b8f7d7d987f560baf5ded5c50" checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541"
[[package]] [[package]]
name = "goblin" name = "goblin"
@ -176,9 +176,9 @@ dependencies = [
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "1.9.1" version = "1.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"hashbrown", "hashbrown",
@ -192,9 +192,9 @@ checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.135" version = "0.2.138"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
[[package]] [[package]]
name = "log" name = "log"
@ -245,21 +245,21 @@ dependencies = [
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.15.0" version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]] [[package]]
name = "os_str_bytes" name = "os_str_bytes"
version = "6.3.0" version = "6.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
[[package]] [[package]]
name = "paste" name = "paste"
version = "1.0.9" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" checksum = "cf1c2c742266c2f1041c914ba65355a83ae8747b05f208319784083583494b4b"
[[package]] [[package]]
name = "plain" name = "plain"
@ -293,9 +293,9 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.46" version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b" checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -337,18 +337,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.145" version = "1.0.150"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" checksum = "e326c9ec8042f1b5da33252c8a37e9ffbd2c9bef0155215b6e6c80c790e05f91"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.145" version = "1.0.150"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" checksum = "42a3df25b0713732468deadad63ab9da1f1fd75a48a15024b50363f128db627e"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -357,15 +357,21 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.86" version = "1.0.89"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
"serde", "serde",
] ]
[[package]]
name = "siphasher"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -374,9 +380,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.102" version = "1.0.105"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -394,15 +400,15 @@ dependencies = [
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.15.1" version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "949517c0cf1bf4ee812e2e07e08ab448e3ae0d23472aee8a06c985f0c8815b16" checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.5.9" version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f"
dependencies = [ dependencies = [
"serde", "serde",
] ]
@ -424,7 +430,7 @@ checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]] [[package]]
name = "uniffi_bindgen" name = "uniffi_bindgen"
version = "0.21.0" version = "0.21.1"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"askama", "askama",
@ -444,12 +450,24 @@ dependencies = [
] ]
[[package]] [[package]]
name = "uniffi_meta" name = "uniffi_checksum_derive"
version = "0.21.0" version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd9417cc653937681436b93838d8c5f97a5b8c58697813982ee8810bd1dc3b57" checksum = "78b6e16d46caf942016997af8bbdf4b163bf8ae3deb0b667d9643de7b7ffd4c9"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "uniffi_meta"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "729835442da829c9b6f7c111c76cf87b2498e129101203bec94f0c39a3296a38"
dependencies = [ dependencies = [
"serde", "serde",
"siphasher",
"uniffi_checksum_derive",
] ]
[[package]] [[package]]

5
third_party/rust/uniffi_bindgen/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package] [package]
edition = "2021" edition = "2021"
name = "uniffi_bindgen" name = "uniffi_bindgen"
version = "0.21.0" version = "0.21.1"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"] authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust (codegen and cli tooling)" description = "a multi-language bindings generator for rust (codegen and cli tooling)"
homepage = "https://mozilla.github.io/uniffi-rs" homepage = "https://mozilla.github.io/uniffi-rs"
@ -23,7 +23,6 @@ keywords = [
] ]
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/mozilla/uniffi-rs" repository = "https://github.com/mozilla/uniffi-rs"
resolver = "2"
[[bin]] [[bin]]
name = "uniffi-bindgen" name = "uniffi-bindgen"
@ -76,7 +75,7 @@ version = "1.0.80"
version = "0.5" version = "0.5"
[dependencies.uniffi_meta] [dependencies.uniffi_meta]
version = "=0.21.0" version = "=0.21.1"
[dependencies.weedle2] [dependencies.weedle2]
version = "4.0.0" version = "4.0.0"

Просмотреть файл

@ -15,13 +15,14 @@
//! if we grow significantly more complicated attribute handling. //! if we grow significantly more complicated attribute handling.
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
/// Represents an attribute parsed from UDL, like `[ByRef]` or `[Throws]`. /// Represents an attribute parsed from UDL, like `[ByRef]` or `[Throws]`.
/// ///
/// This is a convenience enum for parsing UDL attributes and erroring out if we encounter /// This is a convenience enum for parsing UDL attributes and erroring out if we encounter
/// any unsupported ones. These don't convert directly into parts of a `ComponentInterface`, but /// any unsupported ones. These don't convert directly into parts of a `ComponentInterface`, but
/// may influence the properties of things like functions and arguments. /// may influence the properties of things like functions and arguments.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub(super) enum Attribute { pub(super) enum Attribute {
ByRef, ByRef,
Enum, Enum,
@ -119,7 +120,7 @@ where
/// Attributes that can be attached to an `enum` definition in the UDL. /// Attributes that can be attached to an `enum` definition in the UDL.
/// There's only one case here: using `[Error]` to mark an enum as an error class. /// There's only one case here: using `[Error]` to mark an enum as an error class.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct EnumAttributes(Vec<Attribute>); pub(super) struct EnumAttributes(Vec<Attribute>);
impl EnumAttributes { impl EnumAttributes {
@ -155,7 +156,7 @@ impl<T: TryInto<EnumAttributes, Error = anyhow::Error>> TryFrom<Option<T>> for E
/// ///
/// This supports the `[Throws=ErrorName]` attribute for functions that /// This supports the `[Throws=ErrorName]` attribute for functions that
/// can produce an error. /// can produce an error.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct FunctionAttributes(Vec<Attribute>); pub(super) struct FunctionAttributes(Vec<Attribute>);
impl FunctionAttributes { impl FunctionAttributes {
@ -198,7 +199,7 @@ impl<T: TryInto<FunctionAttributes, Error = anyhow::Error>> TryFrom<Option<T>>
/// ///
/// This supports the `[ByRef]` attribute for arguments that should be passed /// This supports the `[ByRef]` attribute for arguments that should be passed
/// by reference in the generated Rust scaffolding. /// by reference in the generated Rust scaffolding.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct ArgumentAttributes(Vec<Attribute>); pub(super) struct ArgumentAttributes(Vec<Attribute>);
impl ArgumentAttributes { impl ArgumentAttributes {
@ -233,7 +234,7 @@ impl<T: TryInto<ArgumentAttributes, Error = anyhow::Error>> TryFrom<Option<T>>
} }
/// Represents UDL attributes that might appear on an `interface` definition. /// Represents UDL attributes that might appear on an `interface` definition.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct InterfaceAttributes(Vec<Attribute>); pub(super) struct InterfaceAttributes(Vec<Attribute>);
impl InterfaceAttributes { impl InterfaceAttributes {
@ -287,7 +288,7 @@ impl<T: TryInto<InterfaceAttributes, Error = anyhow::Error>> TryFrom<Option<T>>
/// ///
/// This supports the `[Throws=ErrorName]` attribute for constructors that can produce /// This supports the `[Throws=ErrorName]` attribute for constructors that can produce
/// an error, and the `[Name=MethodName]` for non-default constructors. /// an error, and the `[Name=MethodName]` for non-default constructors.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct ConstructorAttributes(Vec<Attribute>); pub(super) struct ConstructorAttributes(Vec<Attribute>);
impl ConstructorAttributes { impl ConstructorAttributes {
@ -326,7 +327,7 @@ impl TryFrom<&weedle::attribute::ExtendedAttributeList<'_>> for ConstructorAttri
/// ///
/// This supports the `[Throws=ErrorName]` attribute for methods that can produce /// This supports the `[Throws=ErrorName]` attribute for methods that can produce
/// an error, and the `[Self=ByArc]` attribute for methods that take `Arc<Self>` as receiver. /// an error, and the `[Self=ByArc]` attribute for methods that take `Arc<Self>` as receiver.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct MethodAttributes(Vec<Attribute>); pub(super) struct MethodAttributes(Vec<Attribute>);
impl MethodAttributes { impl MethodAttributes {
@ -375,7 +376,7 @@ impl<T: TryInto<MethodAttributes, Error = anyhow::Error>> TryFrom<Option<T>> for
/// Actually we only support one of these right now, `[Self=ByArc]`. /// Actually we only support one of these right now, `[Self=ByArc]`.
/// We might add more in future, e.g. a `[Self=ByRef]` if there are cases /// We might add more in future, e.g. a `[Self=ByRef]` if there are cases
/// where we need to force the receiver to be taken by reference. /// where we need to force the receiver to be taken by reference.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub(super) enum SelfType { pub(super) enum SelfType {
ByArc, // Method receiver is `Arc<Self>`. ByArc, // Method receiver is `Arc<Self>`.
} }
@ -398,7 +399,7 @@ impl TryFrom<&weedle::attribute::IdentifierOrString<'_>> for SelfType {
/// Represents UDL attributes that might appear on a typedef /// Represents UDL attributes that might appear on a typedef
/// ///
/// This supports the `[External="crate_name"]` and `[Custom]` attributes for types. /// This supports the `[External="crate_name"]` and `[Custom]` attributes for types.
#[derive(Debug, Clone, Hash, Default)] #[derive(Debug, Clone, Checksum, Default)]
pub(super) struct TypedefAttributes(Vec<Attribute>); pub(super) struct TypedefAttributes(Vec<Attribute>);
impl TypedefAttributes { impl TypedefAttributes {

Просмотреть файл

@ -33,19 +33,25 @@
//! # Ok::<(), anyhow::Error>(()) //! # Ok::<(), anyhow::Error>(())
//! ``` //! ```
use std::hash::{Hash, Hasher};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
use super::ffi::{FFIArgument, FFIFunction, FFIType}; use super::ffi::{FFIArgument, FFIFunction, FFIType};
use super::object::Method; use super::object::Method;
use super::types::{Type, TypeIterator}; use super::types::{Type, TypeIterator};
use super::{APIConverter, ComponentInterface}; use super::{APIConverter, ComponentInterface};
#[derive(Debug, Clone)] #[derive(Debug, Clone, Checksum)]
pub struct CallbackInterface { pub struct CallbackInterface {
pub(super) name: String, pub(super) name: String,
pub(super) methods: Vec<Method>, pub(super) methods: Vec<Method>,
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
#[checksum_ignore]
pub(super) ffi_init_callback: FFIFunction, pub(super) ffi_init_callback: FFIFunction,
} }
@ -88,19 +94,6 @@ impl CallbackInterface {
} }
} }
impl Hash for CallbackInterface {
fn hash<H: Hasher>(&self, state: &mut H) {
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
self.name.hash(state);
self.methods.hash(state);
}
}
impl APIConverter<CallbackInterface> for weedle::CallbackInterfaceDefinition<'_> { impl APIConverter<CallbackInterface> for weedle::CallbackInterfaceDefinition<'_> {
fn convert(&self, ci: &mut ComponentInterface) -> Result<CallbackInterface> { fn convert(&self, ci: &mut ComponentInterface) -> Result<CallbackInterface> {
if self.attributes.is_some() { if self.attributes.is_some() {

Просмотреть файл

@ -77,6 +77,7 @@
//! ``` //! ```
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
use super::record::Field; use super::record::Field;
use super::types::{Type, TypeIterator}; use super::types::{Type, TypeIterator};
@ -87,7 +88,7 @@ use super::{APIConverter, ComponentInterface};
/// ///
/// Enums are passed across the FFI by serializing to a bytebuffer, with a /// Enums are passed across the FFI by serializing to a bytebuffer, with a
/// i32 indicating the variant followed by the serialization of each field. /// i32 indicating the variant followed by the serialization of each field.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub struct Enum { pub struct Enum {
pub(super) name: String, pub(super) name: String,
pub(super) variants: Vec<Variant>, pub(super) variants: Vec<Variant>,
@ -174,7 +175,7 @@ impl APIConverter<Enum> for weedle::InterfaceDefinition<'_> {
/// Represents an individual variant in an Enum. /// Represents an individual variant in an Enum.
/// ///
/// Each variant has a name and zero or more fields. /// Each variant has a name and zero or more fields.
#[derive(Debug, Clone, Default, Hash)] #[derive(Debug, Clone, Default, Checksum)]
pub struct Variant { pub struct Variant {
pub(super) name: String, pub(super) name: String,
pub(super) fields: Vec<Field>, pub(super) fields: Vec<Field>,

Просмотреть файл

@ -83,6 +83,7 @@
//! ``` //! ```
use anyhow::Result; use anyhow::Result;
use uniffi_meta::Checksum;
use super::enum_::{Enum, Variant}; use super::enum_::{Enum, Variant};
use super::types::{Type, TypeIterator}; use super::types::{Type, TypeIterator};
@ -94,7 +95,7 @@ use super::{APIConverter, ComponentInterface};
/// they're handled in the FFI very differently. We create them in `uniffi::call_with_result()` if /// they're handled in the FFI very differently. We create them in `uniffi::call_with_result()` if
/// the wrapped function returns an `Err` value /// the wrapped function returns an `Err` value
/// struct and assign an integer error code to each variant. /// struct and assign an integer error code to each variant.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub struct Error { pub struct Error {
pub name: String, pub name: String,
enum_: Enum, enum_: Enum,

Просмотреть файл

@ -32,9 +32,9 @@
//! # Ok::<(), anyhow::Error>(()) //! # Ok::<(), anyhow::Error>(())
//! ``` //! ```
use std::convert::TryFrom; use std::convert::TryFrom;
use std::hash::{Hash, Hasher};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
use super::ffi::{FFIArgument, FFIFunction}; use super::ffi::{FFIArgument, FFIFunction};
use super::literal::{convert_default_value, Literal}; use super::literal::{convert_default_value, Literal};
@ -51,11 +51,18 @@ use super::{APIConverter, ComponentInterface};
/// and has a corresponding standalone function in the foreign language bindings. /// and has a corresponding standalone function in the foreign language bindings.
/// ///
/// In the FFI, this will be a standalone function with appropriately lowered types. /// In the FFI, this will be a standalone function with appropriately lowered types.
#[derive(Debug, Clone)] #[derive(Debug, Clone, Checksum)]
pub struct Function { pub struct Function {
pub(super) name: String, pub(super) name: String,
pub(super) arguments: Vec<Argument>, pub(super) arguments: Vec<Argument>,
pub(super) return_type: Option<Type>, pub(super) return_type: Option<Type>,
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
#[checksum_ignore]
pub(super) ffi_func: FFIFunction, pub(super) ffi_func: FFIFunction,
pub(super) attributes: FunctionAttributes, pub(super) attributes: FunctionAttributes,
} }
@ -142,21 +149,6 @@ impl From<uniffi_meta::FnMetadata> for Function {
} }
} }
impl Hash for Function {
fn hash<H: Hasher>(&self, state: &mut H) {
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
self.name.hash(state);
self.arguments.hash(state);
self.return_type.hash(state);
self.attributes.hash(state);
}
}
impl APIConverter<Function> for weedle::namespace::NamespaceMember<'_> { impl APIConverter<Function> for weedle::namespace::NamespaceMember<'_> {
fn convert(&self, ci: &mut ComponentInterface) -> Result<Function> { fn convert(&self, ci: &mut ComponentInterface) -> Result<Function> {
match self { match self {
@ -185,7 +177,7 @@ impl APIConverter<Function> for weedle::namespace::OperationNamespaceMember<'_>
/// Represents an argument to a function/constructor/method call. /// Represents an argument to a function/constructor/method call.
/// ///
/// Each argument has a name and a type, along with some optional metadata. /// Each argument has a name and a type, along with some optional metadata.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub struct Argument { pub struct Argument {
pub(super) name: String, pub(super) name: String,
pub(super) type_: Type, pub(super) type_: Type,

Просмотреть файл

@ -8,12 +8,13 @@
//! which appear in places such as default arguments. //! which appear in places such as default arguments.
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
use super::types::Type; use super::types::Type;
// Represents a literal value. // Represents a literal value.
// Used for e.g. default argument values. // Used for e.g. default argument values.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub enum Literal { pub enum Literal {
Boolean(bool), Boolean(bool),
String(String), String(String),
@ -35,7 +36,7 @@ pub enum Literal {
// Represent the radix of integer literal values. // Represent the radix of integer literal values.
// We preserve the radix into the generated bindings for readability reasons. // We preserve the radix into the generated bindings for readability reasons.
#[derive(Debug, Clone, Copy, Hash)] #[derive(Debug, Clone, Copy, Checksum)]
pub enum Radix { pub enum Radix {
Decimal = 10, Decimal = 10,
Octal = 8, Octal = 8,

Просмотреть файл

@ -44,12 +44,7 @@
//! //!
//! * Error messages and general developer experience leave a lot to be desired. //! * Error messages and general developer experience leave a lot to be desired.
use std::{ use std::{collections::HashSet, convert::TryFrom, iter};
collections::HashSet,
convert::TryFrom,
hash::{Hash, Hasher},
iter,
};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
@ -77,22 +72,26 @@ pub use record::{Field, Record};
pub mod ffi; pub mod ffi;
pub use ffi::{FFIArgument, FFIFunction, FFIType}; pub use ffi::{FFIArgument, FFIFunction, FFIType};
use uniffi_meta::{MethodMetadata, ObjectMetadata}; use uniffi_meta::{Checksum, MethodMetadata, ObjectMetadata};
/// The main public interface for this module, representing the complete details of an interface exposed /// The main public interface for this module, representing the complete details of an interface exposed
/// by a rust component and the details of consuming it via an extern-C FFI layer. /// by a rust component and the details of consuming it via an extern-C FFI layer.
/// ///
#[derive(Debug, Default)] #[derive(Debug, Default, Checksum)]
pub struct ComponentInterface { pub struct ComponentInterface {
/// Every ComponentInterface gets tagged with the version of uniffi used to create it. /// Every ComponentInterface gets tagged with the version of uniffi used to create it.
/// This helps us avoid using a lib compiled with one version together with bindings created /// This helps us avoid using a lib compiled with one version together with bindings created
/// using a different version, which might introduce unsafety. /// using a different version, which might introduce unsafety.
uniffi_version: String, uniffi_version: String,
/// All of the types used in the interface. /// All of the types used in the interface.
// We can't checksum `self.types`, but its contents are implied by the other fields
// anyway, so it's safe to ignore it.
#[checksum_ignore]
pub(super) types: TypeUniverse, pub(super) types: TypeUniverse,
/// The unique prefix that we'll use for namespacing when exposing this component's API. /// The unique prefix that we'll use for namespacing when exposing this component's API.
namespace: String, namespace: String,
/// The internal unique prefix used to namespace FFI symbols /// The internal unique prefix used to namespace FFI symbols
#[checksum_ignore]
ffi_namespace: String, ffi_namespace: String,
/// The high-level API provided by the component. /// The high-level API provided by the component.
enums: Vec<Enum>, enums: Vec<Enum>,
@ -107,7 +106,7 @@ impl ComponentInterface {
/// Parse a `ComponentInterface` from a string containing a WebIDL definition. /// Parse a `ComponentInterface` from a string containing a WebIDL definition.
pub fn from_webidl(idl: &str) -> Result<Self> { pub fn from_webidl(idl: &str) -> Result<Self> {
let mut ci = Self { let mut ci = Self {
uniffi_version: env!("CARGO_PKG_VERSION").to_string(), uniffi_version: "0.21.0".to_string(),
..Default::default() ..Default::default()
}; };
// There's some lifetime thing with the errors returned from weedle::Definitions::parse // There's some lifetime thing with the errors returned from weedle::Definitions::parse
@ -321,16 +320,8 @@ impl ComponentInterface {
/// - They were generated from two different WebIDL files. /// - They were generated from two different WebIDL files.
/// - They were generated by two different versions of uniffi /// - They were generated by two different versions of uniffi
/// ///
/// The checksum may or may not change depending on the version of Rust used; since we expect
/// consumers to be using the same executable to generate both the scaffolding and the bindings,
/// assuming the same version of Rust seems acceptable.
///
/// Note that this is designed to prevent accidents, not attacks, so there is no need for the /// Note that this is designed to prevent accidents, not attacks, so there is no need for the
/// checksum to be cryptographically secure. /// checksum to be cryptographically secure.
///
/// TODO: it's not clear to me if the derivation of `Hash` is actually deterministic enough to
/// ensure the guarantees above, or if it might be sensitive to e.g. compiler-driven re-ordering
/// of struct field. Let's see how it goes...
pub fn checksum(&self) -> u16 { pub fn checksum(&self) -> u16 {
uniffi_meta::checksum(self) uniffi_meta::checksum(self)
} }
@ -672,23 +663,6 @@ impl ComponentInterface {
} }
} }
/// `ComponentInterface` structs can be hashed, but this is mostly a convenient way to
/// produce a checksum of their contents. They're not really intended to live in a hashtable.
impl Hash for ComponentInterface {
fn hash<H: Hasher>(&self, state: &mut H) {
// We can't hash `self.types`, but its contents are implied by the other fields
// anyway, so it's safe to ignore it.
self.uniffi_version.hash(state);
self.namespace.hash(state);
self.enums.hash(state);
self.records.hash(state);
self.functions.hash(state);
self.objects.hash(state);
self.callback_interfaces.hash(state);
self.errors.hash(state);
}
}
fn get_or_insert_object<'a>(objects: &'a mut Vec<Object>, name: &str) -> &'a mut Object { fn get_or_insert_object<'a>(objects: &'a mut Vec<Object>, name: &str) -> &'a mut Object {
// The find-based way of writing this currently runs into a borrow checker // The find-based way of writing this currently runs into a borrow checker
// error, so we use position // error, so we use position

Просмотреть файл

@ -58,10 +58,10 @@
//! ``` //! ```
use std::convert::TryFrom; use std::convert::TryFrom;
use std::hash::{Hash, Hasher};
use std::{collections::HashSet, iter}; use std::{collections::HashSet, iter};
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
use super::ffi::{FFIArgument, FFIFunction, FFIType}; use super::ffi::{FFIArgument, FFIFunction, FFIType};
use super::function::Argument; use super::function::Argument;
@ -86,12 +86,20 @@ use super::{APIConverter, ComponentInterface};
/// ///
/// TODO: /// TODO:
/// - maybe "Class" would be a better name than "Object" here? /// - maybe "Class" would be a better name than "Object" here?
#[derive(Debug, Clone)] #[derive(Debug, Clone, Checksum)]
pub struct Object { pub struct Object {
pub(super) name: String, pub(super) name: String,
pub(super) constructors: Vec<Constructor>, pub(super) constructors: Vec<Constructor>,
pub(super) methods: Vec<Method>, pub(super) methods: Vec<Method>,
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
#[checksum_ignore]
pub(super) ffi_func_free: FFIFunction, pub(super) ffi_func_free: FFIFunction,
#[checksum_ignore]
pub(super) uses_deprecated_threadsafe_attribute: bool, pub(super) uses_deprecated_threadsafe_attribute: bool,
} }
@ -190,20 +198,6 @@ impl Object {
} }
} }
impl Hash for Object {
fn hash<H: Hasher>(&self, state: &mut H) {
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
self.name.hash(state);
self.constructors.hash(state);
self.methods.hash(state);
}
}
impl APIConverter<Object> for weedle::InterfaceDefinition<'_> { impl APIConverter<Object> for weedle::InterfaceDefinition<'_> {
fn convert(&self, ci: &mut ComponentInterface) -> Result<Object> { fn convert(&self, ci: &mut ComponentInterface) -> Result<Object> {
if self.inheritance.is_some() { if self.inheritance.is_some() {
@ -245,10 +239,17 @@ impl APIConverter<Object> for weedle::InterfaceDefinition<'_> {
// //
// In the FFI, this will be a function that returns a pointer to an instance // In the FFI, this will be a function that returns a pointer to an instance
// of the corresponding object type. // of the corresponding object type.
#[derive(Debug, Clone)] #[derive(Debug, Clone, Checksum)]
pub struct Constructor { pub struct Constructor {
pub(super) name: String, pub(super) name: String,
pub(super) arguments: Vec<Argument>, pub(super) arguments: Vec<Argument>,
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
#[checksum_ignore]
pub(super) ffi_func: FFIFunction, pub(super) ffi_func: FFIFunction,
pub(super) attributes: ConstructorAttributes, pub(super) attributes: ConstructorAttributes,
} }
@ -299,20 +300,6 @@ impl Constructor {
} }
} }
impl Hash for Constructor {
fn hash<H: Hasher>(&self, state: &mut H) {
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
self.name.hash(state);
self.arguments.hash(state);
self.attributes.hash(state);
}
}
impl Default for Constructor { impl Default for Constructor {
fn default() -> Self { fn default() -> Self {
Constructor { Constructor {
@ -343,12 +330,19 @@ impl APIConverter<Constructor> for weedle::interface::ConstructorInterfaceMember
// //
// The FFI will represent this as a function whose first/self argument is a // The FFI will represent this as a function whose first/self argument is a
// `FFIType::RustArcPtr` to the instance. // `FFIType::RustArcPtr` to the instance.
#[derive(Debug, Clone)] #[derive(Debug, Clone, Checksum)]
pub struct Method { pub struct Method {
pub(super) name: String, pub(super) name: String,
pub(super) object_name: String, pub(super) object_name: String,
pub(super) return_type: Option<Type>,
pub(super) arguments: Vec<Argument>, pub(super) arguments: Vec<Argument>,
pub(super) return_type: Option<Type>,
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
#[checksum_ignore]
pub(super) ffi_func: FFIFunction, pub(super) ffi_func: FFIFunction,
pub(super) attributes: MethodAttributes, pub(super) attributes: MethodAttributes,
} }
@ -450,22 +444,6 @@ impl From<uniffi_meta::MethodMetadata> for Method {
} }
} }
impl Hash for Method {
fn hash<H: Hasher>(&self, state: &mut H) {
// We don't include the FFIFunc in the hash calculation, because:
// - it is entirely determined by the other fields,
// so excluding it is safe.
// - its `name` property includes a checksum derived from the very
// hash value we're trying to calculate here, so excluding it
// avoids a weird circular depenendency in the calculation.
self.name.hash(state);
self.object_name.hash(state);
self.arguments.hash(state);
self.return_type.hash(state);
self.attributes.hash(state);
}
}
impl APIConverter<Method> for weedle::interface::OperationInterfaceMember<'_> { impl APIConverter<Method> for weedle::interface::OperationInterfaceMember<'_> {
fn convert(&self, ci: &mut ComponentInterface) -> Result<Method> { fn convert(&self, ci: &mut ComponentInterface) -> Result<Method> {
if self.special.is_some() { if self.special.is_some() {

Просмотреть файл

@ -45,6 +45,7 @@
//! ``` //! ```
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use uniffi_meta::Checksum;
use super::types::{Type, TypeIterator}; use super::types::{Type, TypeIterator};
use super::{ use super::{
@ -58,7 +59,7 @@ use super::{APIConverter, ComponentInterface};
/// In the FFI these are represented as a byte buffer, which one side explicitly /// In the FFI these are represented as a byte buffer, which one side explicitly
/// serializes the data into and the other serializes it out of. So I guess they're /// serializes the data into and the other serializes it out of. So I guess they're
/// kind of like "pass by clone" values. /// kind of like "pass by clone" values.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub struct Record { pub struct Record {
pub(super) name: String, pub(super) name: String,
pub(super) fields: Vec<Field>, pub(super) fields: Vec<Field>,
@ -109,7 +110,7 @@ impl APIConverter<Record> for weedle::DictionaryDefinition<'_> {
} }
// Represents an individual field on a Record. // Represents an individual field on a Record.
#[derive(Debug, Clone, Hash)] #[derive(Debug, Clone, Checksum)]
pub struct Field { pub struct Field {
pub(super) name: String, pub(super) name: String,
pub(super) type_: Type, pub(super) type_: Type,

Просмотреть файл

@ -25,6 +25,7 @@ use std::{collections::hash_map::Entry, collections::BTreeSet, collections::Hash
use anyhow::{bail, Result}; use anyhow::{bail, Result};
use heck::ToUpperCamelCase; use heck::ToUpperCamelCase;
use uniffi_meta::Checksum;
use super::ffi::FFIType; use super::ffi::FFIType;
@ -36,7 +37,7 @@ pub(super) use resolver::{resolve_builtin_type, TypeResolver};
/// Represents all the different high-level types that can be used in a component interface. /// Represents all the different high-level types that can be used in a component interface.
/// At this level we identify user-defined types by name, without knowing any details /// At this level we identify user-defined types by name, without knowing any details
/// of their internal structure apart from what type of thing they are (record, enum, etc). /// of their internal structure apart from what type of thing they are (record, enum, etc).
#[derive(Debug, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Debug, Clone, Eq, PartialEq, Checksum, Ord, PartialOrd)]
pub enum Type { pub enum Type {
// Primitive types. // Primitive types.
UInt8, UInt8,

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"bf9105f53978ecdccad9a75fc3645f97982d3c4162a5a9b49ab16554162b51c1","src/lib.rs":"485a0c0ab99077a1d4037f4deec9801e87a248196e7589a002556fb84973528a"},"package":"510287c368a9386eb731ebe824a6fc6c82a105e20d020af1aa20519c1c1561db"} {"files":{"Cargo.toml":"30736876caf953bd0040b6c0fc824744556bf52fe23d656c7d01442d4c180674","src/lib.rs":"485a0c0ab99077a1d4037f4deec9801e87a248196e7589a002556fb84973528a"},"package":"d035e50433ee3d52ab0dcdcf3b9b26f2cc2ec39294b3c07d95865a518709455f"}

5
third_party/rust/uniffi_build/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package] [package]
edition = "2021" edition = "2021"
name = "uniffi_build" name = "uniffi_build"
version = "0.21.0" version = "0.21.1"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"] authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust (build script helpers)" description = "a multi-language bindings generator for rust (build script helpers)"
homepage = "https://mozilla.github.io/uniffi-rs" homepage = "https://mozilla.github.io/uniffi-rs"
@ -23,7 +23,6 @@ keywords = [
] ]
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/mozilla/uniffi-rs" repository = "https://github.com/mozilla/uniffi-rs"
resolver = "2"
[dependencies.anyhow] [dependencies.anyhow]
version = "1" version = "1"
@ -32,7 +31,7 @@ version = "1"
version = "1.0.8" version = "1.0.8"
[dependencies.uniffi_bindgen] [dependencies.uniffi_bindgen]
version = "=0.21.0" version = "=0.21.1"
optional = true optional = true
[features] [features]

1
third_party/rust/uniffi_checksum_derive/.cargo-checksum.json поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
{"files":{"Cargo.toml":"2ab3c60724c4c504297f8876bf0a8d1291f76a2fc46f5e83634aa147e89ffc71","src/lib.rs":"c68c69a1cf6a69e5fe78f7b069364a265c5bb6ce8c0abf0b5745eca01c79604a"},"package":"78b6e16d46caf942016997af8bbdf4b163bf8ae3deb0b667d9643de7b7ffd4c9"}

42
third_party/rust/uniffi_checksum_derive/Cargo.toml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,42 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
name = "uniffi_checksum_derive"
version = "0.21.1"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust (checksum custom derive)"
homepage = "https://mozilla.github.io/uniffi-rs"
documentation = "https://mozilla.github.io/uniffi-rs"
keywords = [
"ffi",
"bindgen",
]
license = "MPL-2.0"
repository = "https://github.com/mozilla/uniffi-rs"
[lib]
proc-macro = true
[dependencies.quote]
version = "1.0"
[dependencies.syn]
version = "1.0"
features = [
"derive",
"parsing",
]
[features]
default = []
nightly = []

134
third_party/rust/uniffi_checksum_derive/src/lib.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,134 @@
/* 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/. */
#![cfg_attr(feature = "nightly", feature(proc_macro_expand))]
//! Custom derive for uniffi_meta::Checksum
use proc_macro::TokenStream;
use quote::{format_ident, quote};
use syn::{parse_macro_input, Attribute, Data, DeriveInput, Expr, ExprLit, Fields, Index, Lit};
fn has_ignore_attribute(attrs: &[Attribute]) -> bool {
attrs.iter().any(|attr| {
if attr.path.is_ident("checksum_ignore") {
if !attr.tokens.is_empty() {
panic!("#[checksum_ignore] doesn't accept extra information");
}
true
} else {
false
}
})
}
#[proc_macro_derive(Checksum, attributes(checksum_ignore))]
pub fn checksum_derive(input: TokenStream) -> TokenStream {
let input: DeriveInput = parse_macro_input!(input);
let name = input.ident;
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let code = match input.data {
Data::Enum(enum_)
if enum_.variants.len() == 1
&& enum_
.variants
.iter()
.all(|variant| matches!(variant.fields, Fields::Unit)) =>
{
quote!()
}
Data::Enum(enum_) => {
let mut next_discriminant = 0u64;
let match_inner = enum_.variants.iter().map(|variant| {
let ident = &variant.ident;
if has_ignore_attribute(&variant.attrs) {
panic!("#[checksum_ignore] is not supported in enums");
}
match &variant.discriminant {
Some((_, Expr::Lit(ExprLit { lit: Lit::Int(value), .. }))) => {
next_discriminant = value.base10_parse::<u64>().unwrap();
}
Some(_) => {
panic!("#[derive(Checksum)] doesn't support non-numeric explicit discriminants in enums");
}
None => {}
}
let discriminant = quote! { state.write(&#next_discriminant.to_le_bytes()) };
next_discriminant += 1;
match &variant.fields {
Fields::Unnamed(fields) => {
let field_idents = fields
.unnamed
.iter()
.enumerate()
.map(|(num, _)| format_ident!("__self_{}", num));
let field_stmts = field_idents
.clone()
.map(|ident| quote! { Checksum::checksum(#ident, state); });
quote! {
Self::#ident(#(#field_idents,)*) => {
#discriminant;
#(#field_stmts)*
}
}
}
Fields::Named(fields) => {
let field_idents = fields
.named
.iter()
.map(|field| field.ident.as_ref().unwrap());
let field_stmts = field_idents
.clone()
.map(|ident| quote! { Checksum::checksum(#ident, state); });
quote! {
Self::#ident { #(#field_idents,)* } => {
#discriminant;
#(#field_stmts)*
}
}
}
Fields::Unit => quote! { Self::#ident => #discriminant, },
}
});
quote! {
match self {
#(#match_inner)*
}
}
}
Data::Struct(struct_) => {
let stmts = struct_
.fields
.iter()
.enumerate()
.filter_map(|(num, field)| {
(!has_ignore_attribute(&field.attrs)).then(|| match field.ident.as_ref() {
Some(ident) => quote! { Checksum::checksum(&self.#ident, state); },
None => {
let i = Index::from(num);
quote! { Checksum::checksum(&self.#i, state); }
}
})
});
quote! {
#(#stmts)*
}
}
Data::Union(_) => {
panic!("#[derive(Checksum)] is not supported for unions");
}
};
quote! {
#[automatically_derived]
impl #impl_generics Checksum for #name #ty_generics #where_clause {
fn checksum<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
#code
}
}
}
.into()
}

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"55f7e114dd34b0c60b58890120f8707601a5401e9d49d42a239b03da2e660d4f","src/export.rs":"e23929cf6fb5542d29514fe668f3b3d836fad968eacd9c6fcba74c5cd9cf2b61","src/export/metadata.rs":"af89a9942c7c0c4043a3cd57d1e6bd71cde19005e1f9f246efac761f47eff6be","src/export/metadata/convert.rs":"81060fb3390165d77db021f44142a2f3f10882515f859d7393857083370f2d35","src/export/metadata/function.rs":"11833cabd37e7671c0a01944bec73b8892a15df814bbe4c26fdae57aad89a2ba","src/export/metadata/impl_.rs":"ecfdaa132f05dd946414281e52165ef19c90c0bfd76ec651d4ec86837bd41d1c","src/export/scaffolding.rs":"66939405063e56fc983126f249e2d7ddc3257cb045a738abd0cf813a4aafc59c","src/lib.rs":"ca77b437a58cfb3ddeb106d3c1c8378545c46ef241298e62ab1190c5136d1fb1","src/object.rs":"955b596f344304013692042bdc1760bbb1192ec33950b0dd2932cb8de94ec297","src/record.rs":"67a5c7ed6a448f7ad8f5c8e930c5e3007b2b0cac32f52cc8596bdae6fb3c816e","src/util.rs":"6389a9b4258808a3af168cf85658fb7c069172d5e528ee0e94210fa664f2a414"},"package":"5c8604503caa2cbcf271578dc51ca236d40e3b22e1514ffa2e638e2c39f6ad10"} {"files":{"Cargo.toml":"6511b493b676ac3941d70477c91abec62642c3c9aab088ecdf4f733eef3f1faa","src/export.rs":"e23929cf6fb5542d29514fe668f3b3d836fad968eacd9c6fcba74c5cd9cf2b61","src/export/metadata.rs":"af89a9942c7c0c4043a3cd57d1e6bd71cde19005e1f9f246efac761f47eff6be","src/export/metadata/convert.rs":"81060fb3390165d77db021f44142a2f3f10882515f859d7393857083370f2d35","src/export/metadata/function.rs":"11833cabd37e7671c0a01944bec73b8892a15df814bbe4c26fdae57aad89a2ba","src/export/metadata/impl_.rs":"ecfdaa132f05dd946414281e52165ef19c90c0bfd76ec651d4ec86837bd41d1c","src/export/scaffolding.rs":"66939405063e56fc983126f249e2d7ddc3257cb045a738abd0cf813a4aafc59c","src/lib.rs":"ca77b437a58cfb3ddeb106d3c1c8378545c46ef241298e62ab1190c5136d1fb1","src/object.rs":"955b596f344304013692042bdc1760bbb1192ec33950b0dd2932cb8de94ec297","src/record.rs":"67a5c7ed6a448f7ad8f5c8e930c5e3007b2b0cac32f52cc8596bdae6fb3c816e","src/util.rs":"6389a9b4258808a3af168cf85658fb7c069172d5e528ee0e94210fa664f2a414"},"package":"c96a574677566f83ea8458dac1dd7792fd63e7c3f9dbcd865f0e8d6f8057b127"}

7
third_party/rust/uniffi_macros/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package] [package]
edition = "2021" edition = "2021"
name = "uniffi_macros" name = "uniffi_macros"
version = "0.21.0" version = "0.21.1"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"] authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust (convenience macros)" description = "a multi-language bindings generator for rust (convenience macros)"
homepage = "https://mozilla.github.io/uniffi-rs" homepage = "https://mozilla.github.io/uniffi-rs"
@ -23,7 +23,6 @@ keywords = [
] ]
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/mozilla/uniffi-rs" repository = "https://github.com/mozilla/uniffi-rs"
resolver = "2"
[lib] [lib]
proc-macro = true proc-macro = true
@ -60,10 +59,10 @@ features = [
version = "0.5.9" version = "0.5.9"
[dependencies.uniffi_build] [dependencies.uniffi_build]
version = "=0.21.0" version = "=0.21.1"
[dependencies.uniffi_meta] [dependencies.uniffi_meta]
version = "=0.21.0" version = "=0.21.1"
[features] [features]
builtin-bindgen = ["uniffi_build/builtin-bindgen"] builtin-bindgen = ["uniffi_build/builtin-bindgen"]

Просмотреть файл

@ -1 +1 @@
{"files":{"Cargo.toml":"4a474782b3acac7e99435c0cfc6cd4790817ee5c15980b10dc927d95795b977f","src/lib.rs":"dc4c91763c01e8c09ef55cdb103bc02c7aba71c5660ba88f776a8a03a747d6e8"},"package":"cd9417cc653937681436b93838d8c5f97a5b8c58697813982ee8810bd1dc3b57"} {"files":{"Cargo.toml":"4c34032ec5fadf8b996c671425d5afa38e0e5c223ab0b2ed3b44099fb78157d3","src/lib.rs":"a9854421f120e1c4a9d7d36bb006a4c5e7d2e054564f95aa9b6956e7ebb348fd"},"package":"729835442da829c9b6f7c111c76cf87b2498e129101203bec94f0c39a3296a38"}

9
third_party/rust/uniffi_meta/Cargo.toml поставляемый
Просмотреть файл

@ -12,7 +12,7 @@
[package] [package]
edition = "2021" edition = "2021"
name = "uniffi_meta" name = "uniffi_meta"
version = "0.21.0" version = "0.21.1"
description = "uniffi_meta" description = "uniffi_meta"
homepage = "https://mozilla.github.io/uniffi-rs" homepage = "https://mozilla.github.io/uniffi-rs"
keywords = [ keywords = [
@ -21,8 +21,13 @@ keywords = [
] ]
license = "MPL-2.0" license = "MPL-2.0"
repository = "https://github.com/mozilla/uniffi-rs" repository = "https://github.com/mozilla/uniffi-rs"
resolver = "2"
[dependencies.serde] [dependencies.serde]
version = "1.0.136" version = "1.0.136"
features = ["derive"] features = ["derive"]
[dependencies.siphasher]
version = "0.3"
[dependencies.uniffi_checksum_derive]
version = "0.21.0"

102
third_party/rust/uniffi_meta/src/lib.rs поставляемый
Просмотреть файл

@ -2,14 +2,84 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::{ use std::hash::Hasher;
collections::hash_map::DefaultHasher, pub use uniffi_checksum_derive::Checksum;
hash::{Hash, Hasher},
};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] /// Similar to std::hash::Hash.
///
/// Implementations of this trait are expected to update the hasher state in
/// the same way across platforms. #[derive(Checksum)] will do the right thing.
pub trait Checksum {
fn checksum<H: Hasher>(&self, state: &mut H);
}
impl Checksum for bool {
fn checksum<H: Hasher>(&self, state: &mut H) {
state.write_u8(*self as u8);
}
}
impl Checksum for u64 {
fn checksum<H: Hasher>(&self, state: &mut H) {
state.write(&self.to_le_bytes());
}
}
impl Checksum for i64 {
fn checksum<H: Hasher>(&self, state: &mut H) {
state.write(&self.to_le_bytes());
}
}
impl<T: Checksum> Checksum for Box<T> {
fn checksum<H: Hasher>(&self, state: &mut H) {
(**self).checksum(state)
}
}
impl<T: Checksum> Checksum for [T] {
fn checksum<H: Hasher>(&self, state: &mut H) {
state.write(&(self.len() as u64).to_le_bytes());
for item in self {
Checksum::checksum(item, state);
}
}
}
impl<T: Checksum> Checksum for Vec<T> {
fn checksum<H: Hasher>(&self, state: &mut H) {
Checksum::checksum(&**self, state);
}
}
impl<T: Checksum> Checksum for Option<T> {
fn checksum<H: Hasher>(&self, state: &mut H) {
match self {
None => state.write(&0u64.to_le_bytes()),
Some(value) => {
state.write(&1u64.to_le_bytes());
Checksum::checksum(value, state)
}
}
}
}
impl Checksum for str {
fn checksum<H: Hasher>(&self, state: &mut H) {
state.write(self.as_bytes());
state.write_u8(0xff);
}
}
impl Checksum for String {
fn checksum<H: Hasher>(&self, state: &mut H) {
(**self).checksum(state)
}
}
#[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub struct FnMetadata { pub struct FnMetadata {
pub module_path: Vec<String>, pub module_path: Vec<String>,
pub name: String, pub name: String,
@ -23,7 +93,7 @@ impl FnMetadata {
} }
} }
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub struct MethodMetadata { pub struct MethodMetadata {
pub module_path: Vec<String>, pub module_path: Vec<String>,
pub self_name: String, pub self_name: String,
@ -39,14 +109,14 @@ impl MethodMetadata {
} }
} }
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub struct FnParamMetadata { pub struct FnParamMetadata {
pub name: String, pub name: String,
#[serde(rename = "type")] #[serde(rename = "type")]
pub ty: Type, pub ty: Type,
} }
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Checksum, Deserialize, Serialize)]
pub enum Type { pub enum Type {
U8, U8,
U16, U16,
@ -78,21 +148,21 @@ pub enum Type {
}, },
} }
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub struct RecordMetadata { pub struct RecordMetadata {
pub module_path: Vec<String>, pub module_path: Vec<String>,
pub name: String, pub name: String,
pub fields: Vec<FieldMetadata>, pub fields: Vec<FieldMetadata>,
} }
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub struct FieldMetadata { pub struct FieldMetadata {
pub name: String, pub name: String,
#[serde(rename = "type")] #[serde(rename = "type")]
pub ty: Type, pub ty: Type,
} }
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub struct ObjectMetadata { pub struct ObjectMetadata {
pub module_path: Vec<String>, pub module_path: Vec<String>,
pub name: String, pub name: String,
@ -108,13 +178,13 @@ impl ObjectMetadata {
} }
} }
/// Returns the last 16 bits of the value's hash as computed with [`DefaultHasher`]. /// Returns the last 16 bits of the value's hash as computed with [`SipHasher13`].
/// ///
/// To be used as a checksum of FFI symbols, as a safeguard against different UniFFI versions being /// To be used as a checksum of FFI symbols, as a safeguard against different UniFFI versions being
/// used for scaffolding and bindings generation. /// used for scaffolding and bindings generation.
pub fn checksum<T: Hash>(val: &T) -> u16 { pub fn checksum<T: Checksum>(val: &T) -> u16 {
let mut hasher = DefaultHasher::new(); let mut hasher = siphasher::sip::SipHasher13::new();
val.hash(&mut hasher); val.checksum(&mut hasher);
(hasher.finish() & 0x000000000000FFFF) as u16 (hasher.finish() & 0x000000000000FFFF) as u16
} }
@ -124,7 +194,7 @@ pub fn fn_ffi_symbol_name(mod_path: &[String], name: &str, checksum: u16) -> Str
} }
/// Enum covering all the possible metadata types /// Enum covering all the possible metadata types
#[derive(Clone, Debug, Hash, Deserialize, Serialize)] #[derive(Clone, Debug, Checksum, Deserialize, Serialize)]
pub enum Metadata { pub enum Metadata {
Func(FnMetadata), Func(FnMetadata),
Method(MethodMetadata), Method(MethodMetadata),