Bug 1867639 - Vendor in new application-services / Glean / UniFFI. r=markh,janerik,supply-chain-reviewers,mach-reviewers,ahal

Updated uniffi-bindgen-gecko-js to work with UniFFI 0.25.2:
- Use `config.toml` to list UniFFI sources.  This makes it easier to
  associate data with them, for example the `crate_name` field that's
  now required to generate the sources.
- Enable the `extern-rustbuffer` feature on `uniffi_core`
- Updated the external types fixture to work around
  https://github.com/mozilla/uniffi-rs/issues/1872

Ran mach vendor and mach cargo vet to update the Rust crates.

Differential Revision: https://phabricator.services.mozilla.com/D195163
This commit is contained in:
Ben Dean-Kawamura 2023-12-12 14:13:44 +00:00
Родитель 4b45645145
Коммит aff73c9027
294 изменённых файлов: 13695 добавлений и 6361 удалений

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

@ -50,9 +50,9 @@ git = "https://github.com/mozilla-spidermonkey/jsparagus"
rev = "64ba08e24749616de2344112f226d1ef4ba893ae"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c"]
[source."git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822"]
git = "https://github.com/mozilla/application-services"
rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c"
rev = "5babdbc9756a879c906d12613bb764b3f99fe822"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"]
@ -85,9 +85,9 @@ git = "https://github.com/mozilla/neqo"
tag = "v0.6.8"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21"]
[source."git+https://github.com/mozilla/uniffi-rs.git?rev=afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"]
git = "https://github.com/mozilla/uniffi-rs.git"
rev = "c0e64b839018728d8153ce1758d391b7782e2e21"
rev = "afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"
replace-with = "vendored-sources"
[source."git+https://github.com/rust-lang/rust-bindgen?rev=86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"]

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

@ -1583,7 +1583,7 @@ dependencies = [
[[package]]
name = "error-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"error-support-macros",
"lazy_static",
@ -1595,7 +1595,7 @@ dependencies = [
[[package]]
name = "error-support-macros"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"proc-macro2",
"quote",
@ -2245,6 +2245,7 @@ dependencies = [
"uniffi-example-todolist",
"uniffi-fixture-callbacks",
"uniffi-fixture-external-types",
"uniffi_core",
"url",
"viaduct",
"webext_storage_bridge",
@ -2284,9 +2285,9 @@ dependencies = [
[[package]]
name = "glean"
version = "55.0.0"
version = "56.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2082baa3ee5b327652819b7476e1a7dc75c03217382e15764a3284b90fb071e4"
checksum = "4bd4421c9e77e098f774ce712128179069dd6a56904d3b95c9cf35b8418e3d6a"
dependencies = [
"chrono",
"crossbeam-channel",
@ -2304,9 +2305,9 @@ dependencies = [
[[package]]
name = "glean-core"
version = "55.0.0"
version = "56.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed16f55045cb3e210e6ce19c03597a77a2a086a36733eea9c332dcd696962995"
checksum = "a39d53b7dd7b0b81325273cd601f7ae19fba48e0916413c72952a3cf2b82293e"
dependencies = [
"android_logger",
"bincode",
@ -2806,7 +2807,7 @@ dependencies = [
[[package]]
name = "interrupt-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"lazy_static",
"parking_lot",
@ -3984,7 +3985,7 @@ dependencies = [
[[package]]
name = "nss_build_common"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
[[package]]
name = "nsstring"
@ -4105,6 +4106,12 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "oneshot-uniffi"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ae4988774e7a7e6a0783d119bdc683ea8c1d01a24d4fff9b4bdc280e07bd99e"
[[package]]
name = "ordered-float"
version = "3.4.0"
@ -4649,7 +4656,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "remote_settings"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"parking_lot",
"serde",
@ -5180,7 +5187,7 @@ dependencies = [
[[package]]
name = "sql-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"ffi-support",
"interrupt-support",
@ -5361,7 +5368,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "suggest"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"anyhow",
"chrono",
@ -5407,7 +5414,7 @@ dependencies = [
[[package]]
name = "sync-guid"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"base64 0.21.3",
"rand",
@ -5418,7 +5425,7 @@ dependencies = [
[[package]]
name = "sync15"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"anyhow",
"error-support",
@ -5450,7 +5457,7 @@ dependencies = [
[[package]]
name = "tabs"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"anyhow",
"error-support",
@ -5829,9 +5836,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "uniffi"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e835154c561cd75f253008093a908c06fb1f14327afb0ffea88eac72e534cc0"
checksum = "21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f"
dependencies = [
"anyhow",
"uniffi_build",
@ -5858,7 +5865,7 @@ dependencies = [
[[package]]
name = "uniffi-example-arithmetic"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=afb29ebdc1d9edf15021b1c5332fc9f285bbe13b#afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"
dependencies = [
"thiserror",
"uniffi",
@ -5878,7 +5885,7 @@ dependencies = [
[[package]]
name = "uniffi-example-geometry"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=afb29ebdc1d9edf15021b1c5332fc9f285bbe13b#afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"
dependencies = [
"uniffi",
]
@ -5886,7 +5893,7 @@ dependencies = [
[[package]]
name = "uniffi-example-rondpoint"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=afb29ebdc1d9edf15021b1c5332fc9f285bbe13b#afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"
dependencies = [
"uniffi",
]
@ -5894,7 +5901,7 @@ dependencies = [
[[package]]
name = "uniffi-example-sprites"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=afb29ebdc1d9edf15021b1c5332fc9f285bbe13b#afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"
dependencies = [
"uniffi",
]
@ -5902,7 +5909,7 @@ dependencies = [
[[package]]
name = "uniffi-example-todolist"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=afb29ebdc1d9edf15021b1c5332fc9f285bbe13b#afb29ebdc1d9edf15021b1c5332fc9f285bbe13b"
dependencies = [
"once_cell",
"thiserror",
@ -5928,9 +5935,9 @@ dependencies = [
[[package]]
name = "uniffi_bindgen"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f91fdcd44de3aab35847bf80485f412879dcdd92b5140ee67f948e5eed750e"
checksum = "fd992f2929a053829d5875af1eff2ee3d7a7001cb3b9a46cc7895f2caede6940"
dependencies = [
"anyhow",
"askama",
@ -5943,18 +5950,17 @@ dependencies = [
"once_cell",
"paste",
"serde",
"serde_json",
"toml",
"uniffi_meta",
"uniffi_testing",
"weedle2",
"uniffi_udl",
]
[[package]]
name = "uniffi_build"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b20f693fb51c21a21b9816bed5522f0231cc769d8ba38821a05ab7d39dad51d"
checksum = "001964dd3682d600084b3aaf75acf9c3426699bc27b65e96bb32d175a31c74e9"
dependencies = [
"anyhow",
"camino",
@ -5963,9 +5969,9 @@ dependencies = [
[[package]]
name = "uniffi_checksum_derive"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1b354a9bd654cc6547d461ccd60a10eb6c7473178f12d8ff91cf4340ae947e8"
checksum = "55137c122f712d9330fd985d66fa61bdc381752e89c35708c13ce63049a3002c"
dependencies = [
"quote",
"syn",
@ -5973,25 +5979,25 @@ dependencies = [
[[package]]
name = "uniffi_core"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32793120650ceda4f4e0d8eacd784c1a736834b2cca7b12e2550d3a190553af4"
checksum = "6121a127a3af1665cd90d12dd2b3683c2643c5103281d0fed5838324ca1fad5b"
dependencies = [
"anyhow",
"bytes",
"camino",
"cargo_metadata",
"log",
"once_cell",
"oneshot-uniffi",
"paste",
"static_assertions",
]
[[package]]
name = "uniffi_macros"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c65987b46a026ab1dfff218963d34c45375355dd6f1995618262e1e038507ba3"
checksum = "11cf7a58f101fcedafa5b77ea037999b88748607f0ef3a33eaa0efc5392e92e4"
dependencies = [
"bincode",
"camino",
@ -6008,30 +6014,39 @@ dependencies = [
[[package]]
name = "uniffi_meta"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f815bba89a6585954c089c53a775d166c0334c907be0e462bf0f0ac0494656e7"
checksum = "71dc8573a7b1ac4b71643d6da34888273ebfc03440c525121f1b3634ad3417a2"
dependencies = [
"anyhow",
"bytes",
"serde",
"siphasher",
"uniffi_checksum_derive",
]
[[package]]
name = "uniffi_testing"
version = "0.24.3"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1048d7c54816dc27ed4041fe952d42c7cb88e711cf3299e36ee70df7692c4a39"
checksum = "118448debffcb676ddbe8c5305fb933ab7e0123753e659a71dc4a693f8d9f23c"
dependencies = [
"anyhow",
"camino",
"cargo_metadata",
"fs-err",
"once_cell",
"serde",
"serde_json",
]
[[package]]
name = "uniffi_udl"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "889edb7109c6078abe0e53e9b4070cf74a6b3468d141bdf5ef1bd4d1dc24a1c3"
dependencies = [
"anyhow",
"uniffi_meta",
"uniffi_testing",
"weedle2",
]
[[package]]
@ -6090,7 +6105,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "viaduct"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"ffi-support",
"log",
@ -6236,7 +6251,7 @@ dependencies = [
[[package]]
name = "webext-storage"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
dependencies = [
"anyhow",
"error-support",

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

@ -51,7 +51,7 @@ resolver = "2"
[workspace.dependencies]
# Shared across multiple UniFFI consumers.
uniffi = "0.24.3"
uniffi = "0.25.3"
# Explicitly specify what our profiles use. The opt-level setting here is
# a total fiction; see the setup of MOZ_RUST_DEFAULT_FLAGS for what the
@ -203,13 +203,13 @@ warp = { git = "https://github.com/seanmonstar/warp", rev = "9d081461ae1167eb321
malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" }
# application-services overrides to make updating them all simpler.
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c" }
interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
sql-support = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
suggest = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
sync15 = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
tabs = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
viaduct = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
webext-storage = { git = "https://github.com/mozilla/application-services", rev = "5babdbc9756a879c906d12613bb764b3f99fe822" }
# Patch mio 0.6 to use winapi 0.3 and miow 0.3, getting rid of winapi 0.2.
# There is not going to be new version of mio 0.6, mio now being >= 0.7.11.
@ -217,8 +217,8 @@ webext-storage = { git = "https://github.com/mozilla/application-services", rev
path = "third_party/rust/mio-0.6.23"
[patch."https://github.com/mozilla/uniffi-rs.git"]
uniffi = "=0.24.3"
uniffi_bindgen = "=0.24.3"
uniffi_build = "=0.24.3"
uniffi_macros = "=0.24.3"
uniffi = "=0.25.3"
uniffi_bindgen = "=0.25.3"
uniffi_build = "=0.25.3"
uniffi_macros = "=0.25.3"
weedle2 = "=4.0.0"

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

@ -60,7 +60,7 @@ allprojects {
topsrcdir = gradle.mozconfig.topsrcdir
topobjdir = gradle.mozconfig.topobjdir
gleanVersion = "55.0.0"
gleanVersion = "56.0.0"
if (gleanVersion != getRustVersionFor("glean")) {
throw new StopExecutionException("Mismatched Glean version, expected: ${gleanVersion}," +
" found ${getRustVersionFor("glean")}")

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

@ -996,9 +996,9 @@ dependencies = [
[[package]]
name = "glean"
version = "55.0.0"
version = "56.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2082baa3ee5b327652819b7476e1a7dc75c03217382e15764a3284b90fb071e4"
checksum = "4bd4421c9e77e098f774ce712128179069dd6a56904d3b95c9cf35b8418e3d6a"
dependencies = [
"chrono",
"crossbeam-channel",
@ -1016,9 +1016,9 @@ dependencies = [
[[package]]
name = "glean-core"
version = "55.0.0"
version = "56.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed16f55045cb3e210e6ce19c03597a77a2a086a36733eea9c332dcd696962995"
checksum = "a39d53b7dd7b0b81325273cd601f7ae19fba48e0916413c72952a3cf2b82293e"
dependencies = [
"android_logger",
"bincode",
@ -1881,6 +1881,12 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "oneshot-uniffi"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ae4988774e7a7e6a0783d119bdc683ea8c1d01a24d4fff9b4bdc280e07bd99e"
[[package]]
name = "ordered-float"
version = "3.4.0"
@ -2738,9 +2744,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "uniffi"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6da26ba712a8547207ededc70f3e0952c09754be9516c320f71731d2f18daf3e"
checksum = "21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f"
dependencies = [
"anyhow",
"uniffi_build",
@ -2750,9 +2756,9 @@ dependencies = [
[[package]]
name = "uniffi_bindgen"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29bff3ba24868022fc82e2f1558f3a0fdcc2655e1335459a35f25d1ec4ff1d0c"
checksum = "fd992f2929a053829d5875af1eff2ee3d7a7001cb3b9a46cc7895f2caede6940"
dependencies = [
"anyhow",
"askama",
@ -2765,18 +2771,17 @@ dependencies = [
"once_cell",
"paste",
"serde",
"serde_json",
"toml",
"uniffi_meta",
"uniffi_testing",
"weedle2",
"uniffi_udl",
]
[[package]]
name = "uniffi_build"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52b7cd03e17b997469e5438d1a491c3b9e2d41c2a87c86fd91ba96e87aecba6a"
checksum = "001964dd3682d600084b3aaf75acf9c3426699bc27b65e96bb32d175a31c74e9"
dependencies = [
"anyhow",
"camino",
@ -2785,9 +2790,9 @@ dependencies = [
[[package]]
name = "uniffi_checksum_derive"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af98d58e238b6aef9ff62a93b5c60caa710bdb49351434a639b9bd7b4c84c808"
checksum = "55137c122f712d9330fd985d66fa61bdc381752e89c35708c13ce63049a3002c"
dependencies = [
"quote",
"syn 2.0.25",
@ -2795,25 +2800,25 @@ dependencies = [
[[package]]
name = "uniffi_core"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68640fa1b5dfbb4ccc149057c81b40adc51a01d295ce798c15c6c76f7e899907"
checksum = "6121a127a3af1665cd90d12dd2b3683c2643c5103281d0fed5838324ca1fad5b"
dependencies = [
"anyhow",
"bytes",
"camino",
"cargo_metadata",
"log",
"once_cell",
"oneshot-uniffi",
"paste",
"static_assertions",
]
[[package]]
name = "uniffi_macros"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76f72684ff48a8ff0ee95fde6dbcfa687236ad1789dc18205cb3305432a7b35c"
checksum = "11cf7a58f101fcedafa5b77ea037999b88748607f0ef3a33eaa0efc5392e92e4"
dependencies = [
"bincode",
"camino",
@ -2830,31 +2835,39 @@ dependencies = [
[[package]]
name = "uniffi_meta"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe3388a58b13dad8f0cdcbdee1c59af6408608ce8d85a3ef5d1429369ca7b217"
checksum = "71dc8573a7b1ac4b71643d6da34888273ebfc03440c525121f1b3634ad3417a2"
dependencies = [
"anyhow",
"bytes",
"serde",
"siphasher",
"uniffi_checksum_derive",
"uniffi_core",
]
[[package]]
name = "uniffi_testing"
version = "0.24.1"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb437a2c8565249274e381fd88bc75b539897f321b79022c9fe7e275d2c2bbb"
checksum = "118448debffcb676ddbe8c5305fb933ab7e0123753e659a71dc4a693f8d9f23c"
dependencies = [
"anyhow",
"camino",
"cargo_metadata",
"fs-err",
"once_cell",
"serde",
"serde_json",
]
[[package]]
name = "uniffi_udl"
version = "0.25.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "889edb7109c6078abe0e53e9b4070cf74a6b3468d141bdf5ef1bd4d1dc24a1c3"
dependencies = [
"anyhow",
"uniffi_meta",
"uniffi_testing",
"weedle2",
]
[[package]]

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

@ -52,7 +52,7 @@ svg_fmt = "0.4"
tracy-rs = "0.1.2"
derive_more = { version = "0.99", default-features = false, features = ["add_assign"] }
etagere = "0.2.6"
glean = "55.0.0"
glean = "56.0.0"
firefox-on-glean = { version = "0.1.0", optional = true }
swgl = { path = "../swgl", optional = true }
topological-sort = "0.1"

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

@ -25,7 +25,7 @@ tracy-rs = "0.1.2"
log = "0.4"
lazy_static = "1"
fxhash = "0.2.1"
glean = { version = "55.0.0", optional = true }
glean = { version = "56.0.0", optional = true }
firefox-on-glean = { version = "0.1.0", optional = true }
serde = { optional = true, version = "1.0", features = ["serde_derive"] }

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

@ -93,7 +93,7 @@ vendored:third_party/python/wheel
vendored:third_party/python/zipp
# glean-sdk may not be installable if a wheel isn't available
# and it has to be built from source.
pypi-optional:glean-sdk==55.0.0:telemetry will not be collected
pypi-optional:glean-sdk==56.0.0:telemetry will not be collected
# Mach gracefully handles the case where `psutil` is unavailable.
# We aren't (yet) able to pin packages in automation, so we have to
# support down to the oldest locally-installed version (5.4.2).

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

@ -357,6 +357,14 @@ start = "2022-05-05"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2021-10-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_bindgen]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -365,6 +373,14 @@ start = "2022-05-05"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_bindgen]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2021-10-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_build]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -373,6 +389,14 @@ start = "2022-05-05"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_build]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2021-10-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_checksum_derive]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -381,6 +405,14 @@ start = "2022-12-16"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_checksum_derive]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2023-01-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -389,6 +421,14 @@ start = "2023-06-21"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_core]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2023-01-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_macros]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -397,6 +437,14 @@ start = "2022-05-05"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_macros]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2021-10-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_meta]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -405,6 +453,14 @@ start = "2022-08-31"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_meta]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2022-09-13"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_testing]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
@ -413,6 +469,22 @@ start = "2022-12-16"
end = "2024-06-21"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_testing]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2023-01-27"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.uniffi_udl]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 127697 # bendk
start = "2023-10-18"
end = "2024-12-11"
notes = "Maintained by the Glean and Application Services teams"
[[wildcard-audits.utf8_iter]]
who = "Makoto Kato <m_kato@ga2.so-net.ne.jp>"
criteria = "safe-to-deploy"
@ -2665,6 +2737,29 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "1.16.0 -> 1.17.1"
[[audits.oneshot]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
version = "0.1.5"
notes = "Small crate, reviewed by bendk. There is a decent amount of unsafe code, but it's well tested and the crate has been well-used over the years."
[[audits.oneshot]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
version = "0.1.5@git:1f3c657c8073aec4f0b6ebac7be33b4851644745"
notes = """
Small crate, reviewed by bendk. There is a decent amount of unsafe code, but it's well tested and the crate has been well-used over the years.
The git branch is my fork of the official code that removes the `loom` target to avoid pulling in that crate and its dependencies into moz-central.
This doesn't change any of the functionality -- the `loom` target is only used for testing.
"""
[[audits.oneshot-uniffi]]
who = "Ben Dean-Kawamura <bdk@mozilla.com>"
criteria = "safe-to-deploy"
version = "0.1.5"
notes = "This is the essentially same code as `oneshot version 0.1.5` which has already been audited. The only difference is that it won't pull in `loom` and related dependencies when `mach vendor rust` is run."
[[audits.ordered-float]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"

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

@ -225,6 +225,13 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean]]
version = "56.0.0"
when = "2023-11-30"
user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean-core]]
version = "55.0.0"
when = "2023-10-23"
@ -232,6 +239,13 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean-core]]
version = "56.0.0"
when = "2023-11-30"
user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glslopt]]
version = "0.1.9"
when = "2021-03-17"
@ -657,6 +671,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_bindgen]]
version = "0.24.3"
when = "2023-08-01"
@ -664,6 +691,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_bindgen]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_bindgen]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_build]]
version = "0.24.3"
when = "2023-08-01"
@ -671,6 +711,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_build]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_build]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_checksum_derive]]
version = "0.24.3"
when = "2023-08-01"
@ -678,6 +731,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_checksum_derive]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_checksum_derive]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_core]]
version = "0.24.3"
when = "2023-08-01"
@ -685,6 +751,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_core]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_core]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_macros]]
version = "0.24.3"
when = "2023-08-01"
@ -692,6 +771,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_macros]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_macros]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_meta]]
version = "0.24.3"
when = "2023-08-01"
@ -699,6 +791,19 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_meta]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_meta]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_testing]]
version = "0.24.3"
when = "2023-08-01"
@ -706,6 +811,32 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.uniffi_testing]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_testing]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_udl]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.uniffi_udl]]
version = "0.25.3"
when = "2023-12-07"
user-id = 127697
user-login = "bendk"
[[publisher.utf8_iter]]
version = "1.0.3"
when = "2022-09-09"
@ -1483,6 +1614,78 @@ who = "Brandon Pitman <bran@bran.land>"
criteria = "safe-to-deploy"
delta = "0.10.7 -> 0.10.8"
[[audits.mozilla.wildcard-audits.uniffi]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2021-11-22"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_bindgen]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2021-11-22"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_build]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2021-11-22"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_checksum_derive]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2023-11-20"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_core]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2023-11-20"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_macros]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2021-11-22"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_meta]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2023-11-20"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_testing]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2023-11-20"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.uniffi_udl]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
user-id = 111105 # Mark Hammond (mhammond)
start = "2023-11-20"
end = "2024-11-28"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.wildcard-audits.zeitstempel]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"

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

@ -1 +1 @@
{"files":{"Cargo.toml":"04d1e52d52fbec3f7acea595ad02b7126baa5f6c21e431aaba2471f08fd5c95c","README.md":"8030b4a314b1be31ba018ac12c3b586bb736db5307c3c395f2857fffe0130322","android/build.gradle":"200fe9fcf26477ae4e941dd1e702c43deae9fb0a7252569bd7352eac1771efbe","android/src/main/AndroidManifest.xml":"4f8b16fa6a03120ac810c6438a3a60294075414d92e06caa7e85388e389e5d17","build.rs":"c8d3c38c1208eea36224662b284d8daf3e7ad1b07d22d750524f3da1cc66ccca","src/errorsupport.udl":"e793034d01a2608298528051757f38405e006ee1abc4cf65dc6f18c53590ace8","src/handling.rs":"545c969d71907d81cb5af93f435ba443508adda2ec57ac2a975fed7d9828ccea","src/lib.rs":"96ae3cc2c1077ae45442ace6b5b5311b86267d0b9067f3ff58396af30ccbbc07","src/macros.rs":"0d03f82fab20c96a182f941baf3fcf2a286b00fea871ee7fd8e339abc14f9522","src/redact.rs":"c9a4df1a87be68b15d583587bda941d4c60a1d0449e2d43ff99f3611a290a863","src/reporting.rs":"38efd24d86ba8facfb181cb27e8b698d2831db0afab85691ffda034a4dc68dfa","uniffi.toml":"644fe81c12fe3c01ee81e017ca3c00d0e611f014b7eade51aadaf208179a3450"},"package":null}
{"files":{"Cargo.toml":"cf73fe7b6066cb2ccccb0939f19b14d4e27d9cfdc20c9e527de3210029f2ee6f","README.md":"8030b4a314b1be31ba018ac12c3b586bb736db5307c3c395f2857fffe0130322","android/build.gradle":"200fe9fcf26477ae4e941dd1e702c43deae9fb0a7252569bd7352eac1771efbe","android/src/main/AndroidManifest.xml":"4f8b16fa6a03120ac810c6438a3a60294075414d92e06caa7e85388e389e5d17","build.rs":"c8d3c38c1208eea36224662b284d8daf3e7ad1b07d22d750524f3da1cc66ccca","src/errorsupport.udl":"e793034d01a2608298528051757f38405e006ee1abc4cf65dc6f18c53590ace8","src/handling.rs":"545c969d71907d81cb5af93f435ba443508adda2ec57ac2a975fed7d9828ccea","src/lib.rs":"96ae3cc2c1077ae45442ace6b5b5311b86267d0b9067f3ff58396af30ccbbc07","src/macros.rs":"0d03f82fab20c96a182f941baf3fcf2a286b00fea871ee7fd8e339abc14f9522","src/redact.rs":"c9a4df1a87be68b15d583587bda941d4c60a1d0449e2d43ff99f3611a290a863","src/reporting.rs":"38efd24d86ba8facfb181cb27e8b698d2831db0afab85691ffda034a4dc68dfa","uniffi.toml":"644fe81c12fe3c01ee81e017ca3c00d0e611f014b7eade51aadaf208179a3450"},"package":null}

4
third_party/rust/error-support/Cargo.toml поставляемый
Просмотреть файл

@ -20,7 +20,7 @@ license = "MPL-2.0"
[dependencies]
log = "0.4"
uniffi = "0.24.1"
uniffi = "0.25.2"
[dependencies.backtrace]
version = "0.3"
@ -36,5 +36,5 @@ version = "1.4"
version = ">=0.11,<=0.12"
[build-dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
features = ["build"]

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

8
third_party/rust/glean-core/Cargo.toml поставляемый
Просмотреть файл

@ -11,9 +11,9 @@
[package]
edition = "2021"
rust-version = "1.63"
rust-version = "1.65"
name = "glean-core"
version = "55.0.0"
version = "56.0.0"
authors = [
"Jan-Erik Rediger <jrediger@mozilla.com>",
"The Glean Team <glean-team@mozilla.com>",
@ -80,7 +80,7 @@ version = "1.0.4"
version = "0.1.40"
[dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
default-features = false
[dependencies.uuid]
@ -105,7 +105,7 @@ version = "0.4"
version = "3.8.0"
[build-dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
features = ["build"]
default-features = false

2
third_party/rust/glean-core/src/lib.rs поставляемый
Просмотреть файл

@ -242,6 +242,8 @@ impl fmt::Display for CallbackError {
}
}
impl std::error::Error for CallbackError {}
impl From<uniffi::UnexpectedUniFFICallbackError> for CallbackError {
fn from(_: uniffi::UnexpectedUniFFICallbackError) -> CallbackError {
CallbackError::UnexpectedError

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

@ -1 +1 @@
{"files":{"Cargo.toml":"fcdfb2582c4db4fe6cabf831526be9cd2016375f5af75134afdbbba9b13cd121","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"186b9d92e48f2f34f1ea51023ad83c9d7abec97bcb0b862641bcb79a93c97d9e","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"ffbfb09082bc7c758fcfa974226c7b7da75c88f259526a9ba085c511e1db1fa1","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"612a9f13ade0b202c8762bccc7b5dc288101cb3820e47be2755331911a221c55","src/private/event.rs":"02bbebf545695812e5055741cc0b5f3c99eda2039e684e26fcdd5f087ed15fe3","src/private/mod.rs":"eb8fe4e588bb32a54617324db39319920c627e6fc23c23cf4da5c17c63e0afed","src/private/ping.rs":"da7545b8fc3b8cbaa8f598dc18fa4ba7c499573c360e8de6e1714d38dd4a665d","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"3ff6cf151f416e7a8d0f1b54ff28360ad7ebd3dcf47df02c08a8039702d636d9","tests/common/mod.rs":"08fb9483d9b6ed9fe873b4395245166ae8a15263be750c7a8e298c41d9604745","tests/init_fails.rs":"96bbb67ec64976f505fc05eb2c2e101f06c11bd2eaf6a0c6383b1a3e05a1cf4b","tests/never_init.rs":"2cf13a67b34cda8447f489cf3755eba0595978d242d29025670f9bb7c1025937","tests/no_time_to_init.rs":"5fd92258e3fb0302c7f8ab1dee374ece7343cc727206d9da134442bca746b88d","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"e611cc168b648b5f515c54873c71b3e5e86431afa2aaff94581eeeb4f1d4935d","tests/simple.rs":"3a762995c06c0adc5adb94ad9c37e41dbbcf08a96b87bc20a449240fa0d93b0c","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/test-thread-crashing.sh":"ff1bc8e5d7e4ba3a10d0d38bef222db8bfba469e7d30e45b1053d177a4084f09","tests/upload_timing.rs":"4100ddba97cad28e1abfeb1492dfff61d151a67360392393d6f90d891b3e86be"},"package":"2082baa3ee5b327652819b7476e1a7dc75c03217382e15764a3284b90fb071e4"}
{"files":{"Cargo.toml":"74decb71ef8b82a2fa24b7d0073ce8833b9703a139c2555e7d50162de2414f13","LICENSE":"1f256ecad192880510e84ad60474eab7589218784b9a50bc7ceee34c2b91f1d5","README.md":"5627cc81e6187ab6c2b4dff061af16d559edcab64ba786bac39daa69c703c595","src/common_test.rs":"de47b53dcca37985c0a2b8c02daecbf32309aa54f5a4dd9290719c2c1fd0fa55","src/configuration.rs":"186b9d92e48f2f34f1ea51023ad83c9d7abec97bcb0b862641bcb79a93c97d9e","src/core_metrics.rs":"fef8fb4e5fa57c179836c6eb2cf59278fe3b8b036dbe57b0ff02971b4acd822f","src/lib.rs":"ffbfb09082bc7c758fcfa974226c7b7da75c88f259526a9ba085c511e1db1fa1","src/net/http_uploader.rs":"43812a70d19a38e8d7a093c8076c2b6345372c3c861b0f3511428762700a65e0","src/net/mod.rs":"612a9f13ade0b202c8762bccc7b5dc288101cb3820e47be2755331911a221c55","src/private/event.rs":"d7c70c02648584c19c73af89e5180d3c6153c911f2c6830f7d1599b18d6150eb","src/private/mod.rs":"eb8fe4e588bb32a54617324db39319920c627e6fc23c23cf4da5c17c63e0afed","src/private/ping.rs":"da7545b8fc3b8cbaa8f598dc18fa4ba7c499573c360e8de6e1714d38dd4a665d","src/system.rs":"6eae5b41c15eba9cad6dbd116abe3519ee3e1fe034e79bdd692b029829a8c384","src/test.rs":"3ff6cf151f416e7a8d0f1b54ff28360ad7ebd3dcf47df02c08a8039702d636d9","tests/common/mod.rs":"08fb9483d9b6ed9fe873b4395245166ae8a15263be750c7a8e298c41d9604745","tests/init_fails.rs":"96bbb67ec64976f505fc05eb2c2e101f06c11bd2eaf6a0c6383b1a3e05a1cf4b","tests/never_init.rs":"2cf13a67b34cda8447f489cf3755eba0595978d242d29025670f9bb7c1025937","tests/no_time_to_init.rs":"5fd92258e3fb0302c7f8ab1dee374ece7343cc727206d9da134442bca746b88d","tests/overflowing_preinit.rs":"7ad4b2274dd9240b53430859a4eb1d2597cf508a5a678333f3d3abbadd2ed4a7","tests/persist_ping_lifetime.rs":"81415dc1d74743f02269f0d0dfa524003147056853f080276972e64a0b761d3c","tests/persist_ping_lifetime_nopanic.rs":"18379d3ffbf4a2c8c684c04ff7a0660b86dfbbb447db2d24dfed6073cb7ddf8f","tests/schema.rs":"e611cc168b648b5f515c54873c71b3e5e86431afa2aaff94581eeeb4f1d4935d","tests/simple.rs":"3a762995c06c0adc5adb94ad9c37e41dbbcf08a96b87bc20a449240fa0d93b0c","tests/test-shutdown-blocking.sh":"9b16a01c190c7062474dd92182298a3d9a27928c8fa990340fdd798e6cdb7ab2","tests/test-thread-crashing.sh":"ff1bc8e5d7e4ba3a10d0d38bef222db8bfba469e7d30e45b1053d177a4084f09","tests/upload_timing.rs":"4100ddba97cad28e1abfeb1492dfff61d151a67360392393d6f90d891b3e86be"},"package":"4bd4421c9e77e098f774ce712128179069dd6a56904d3b95c9cf35b8418e3d6a"}

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

@ -11,9 +11,9 @@
[package]
edition = "2021"
rust-version = "1.63"
rust-version = "1.65"
name = "glean"
version = "55.0.0"
version = "56.0.0"
authors = [
"Jan-Erik Rediger <jrediger@mozilla.com>",
"The Glean Team <glean-team@mozilla.com>",
@ -42,7 +42,7 @@ features = ["serde"]
version = "0.5"
[dependencies.glean-core]
version = "55.0.0"
version = "56.0.0"
[dependencies.inherent]
version = "1"

54
third_party/rust/glean/src/private/event.rs поставляемый
Просмотреть файл

@ -9,8 +9,6 @@ use glean_core::traits;
use crate::{ErrorType, RecordedEvent};
pub use glean_core::traits::NoExtraKeys;
// We need to wrap the glean-core type: otherwise if we try to implement
// the trait for the metric in `glean_core::metrics` we hit error[E0117]:
// only traits defined in the current crate can be implemented for arbitrary
@ -59,6 +57,31 @@ impl<K: traits::ExtraKeys> EventMetric<K> {
}
}
#[inherent]
impl<K: traits::ExtraKeys> traits::Event for EventMetric<K> {
type Extra = K;
pub fn record<M: Into<Option<<Self as traits::Event>::Extra>>>(&self, extra: M) {
let extra = extra
.into()
.map(|e| e.into_ffi_extra())
.unwrap_or_else(HashMap::new);
self.inner.record(extra);
}
pub fn test_get_value<'a, S: Into<Option<&'a str>>>(
&self,
ping_name: S,
) -> Option<Vec<RecordedEvent>> {
let ping_name = ping_name.into().map(|s| s.to_string());
self.inner.test_get_value(ping_name)
}
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
self.inner.test_get_num_recorded_errors(error)
}
}
#[cfg(test)]
mod test {
use super::*;
@ -70,7 +93,7 @@ mod test {
let _lock = lock_test();
let _t = new_glean(None, true);
let metric: EventMetric<NoExtraKeys> = EventMetric::new(CommonMetricData {
let metric: EventMetric<traits::NoExtraKeys> = EventMetric::new(CommonMetricData {
name: "event".into(),
category: "test".into(),
send_in_pings: vec!["test1".into()],
@ -196,28 +219,3 @@ mod test {
assert_eq!(None, data[2].extra);
}
}
#[inherent]
impl<K: traits::ExtraKeys> traits::Event for EventMetric<K> {
type Extra = K;
pub fn record<M: Into<Option<<Self as traits::Event>::Extra>>>(&self, extra: M) {
let extra = extra
.into()
.map(|e| e.into_ffi_extra())
.unwrap_or_else(HashMap::new);
self.inner.record(extra);
}
pub fn test_get_value<'a, S: Into<Option<&'a str>>>(
&self,
ping_name: S,
) -> Option<Vec<RecordedEvent>> {
let ping_name = ping_name.into().map(|s| s.to_string());
self.inner.test_get_value(ping_name)
}
pub fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32 {
self.inner.test_get_num_recorded_errors(error)
}
}

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

@ -0,0 +1 @@
{"files":{"CHANGELOG.md":"e1165d97c283b915d87e22f209494be39933723a0b544e725f69cfa5cef3876c","Cargo.lock":"7625529900ca1e3626b90e74ef268b31e06da85e8334a885711fdfd80821ddda","Cargo.toml":"81dde8ad3180c7b97325a6a67bfbefb145590606de9008d881c4e04808865f0a","README.md":"811ea1c958d5a65583d0223b7ab09bb282e7a51ed60f9a2cb90ef6d555325a68","benches/benches.rs":"67dcc916d0b7e28e396c28dac0499726366e1cb10e9991948d1c881a5abf5faa","check_mem_leaks.sh":"c1ab6ef27997c7f971352ab1c86a184004843c499bc24925da953aefcf1c624c","examples/recv_before_send.rs":"9a3cabcc2878990b61787d0048061b382555a8cd1a08b1ddec63a6e8a4a31e56","examples/recv_before_send_then_drop_sender.rs":"14706c6b4308a690662ceaa47f1699588bd833b3ec020eb9f42f220f3ffc7ae7","examples/recv_ref_before_send.rs":"43699f4720c46b5f138c260b866eb708ddf616e2b442ffa74a97373f4f48d4d0","examples/recv_ref_before_send_then_drop_sender.rs":"a190ed220cb4288d4965485365c9afaed30535cbfad5f8cb7389071b82d67cac","examples/recv_timeout_before_send.rs":"2262aa6531afce7816d43182ad9cbec2c04f3dc129064e11e89452278ce8b163","examples/recv_timeout_before_send_then_drop_sender.rs":"4cc8eade4c211f52f5b9be0f72a5906689b894490f4cb5255525e44106e7a4a8","examples/recv_with_dropped_sender.rs":"7906685053ce1c53ff6c26ce11d3221d4bf5ca3429d1d4d2c28de9237cb151c6","examples/send_before_recv.rs":"5555bd61ad52273b663007794128d8f012fc54272bd3225259b5546221bcd591","examples/send_then_drop_receiver.rs":"c3612de207309098404b057468687a2d2311d07f354b7e046398e35e93c4cdcf","examples/send_with_dropped_receiver.rs":"f5a7762b231a24a0db4397c5139437cba155d09b9dbb59872d662c7923080706","src/errors.rs":"df6a1db663fdb1c54d6941d737f6591bfe0dc6f01bd627ba0a94d67ed50b27a9","src/lib.rs":"86893f56e8e762b41ee079b42f4248608e9efb68bd76aa9550fce61e7466bbb0","src/loombox.rs":"fc85d1c2d3fda432be60f0c4d1d528e5998ec2b738a5b395a242285051b94d65","tests/assert_mem.rs":"b1e5190af01af22e55c7c1cd1ff2711807591f788e4eb8b6c6d89123e146105e","tests/async.rs":"6fd2826e589b94677d4eeed1080deda8bcc429aa05a20d843d1442a3a48ea757","tests/future.rs":"0e71f0293cd5a8c44210e8882aca20cfbf1e3771ecd4e4f6b59b924c0d01dd97","tests/helpers/mod.rs":"19161ed33e0ba8862746f04678d0606dee90205896083f85d8c1dcd4d211ccb0","tests/helpers/waker.rs":"77494d49f62d0d320df3830643c306e06e6e20751d210cf6fa58b238bd96c3f9","tests/loom.rs":"ea350fa424a95581e1871bc0037badecc5a090f28fd10532917abbaf561218ab","tests/sync.rs":"1186fa6cdb5a180944fa7d793ccb8be412c4a4e88bb504daa70bc097ee081b06"},"package":"9ae4988774e7a7e6a0783d119bdc683ea8c1d01a24d4fff9b4bdc280e07bd99e"}

62
third_party/rust/oneshot-uniffi/CHANGELOG.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,62 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
### Categories each change fall into
* **Added**: for new features.
* **Changed**: for changes in existing functionality.
* **Deprecated**: for soon-to-be removed features.
* **Removed**: for now removed features.
* **Fixed**: for any bug fixes.
* **Security**: in case of vulnerabilities.
## [Unreleased]
## [0.1.5] - 2022-09-01
### Fixed
- Handle the UNPARKING state correctly in all recv methods. `try_recv` will now not panic
if used on a `Receiver` that is being unparked from an async wait. The other `recv` methods
will still panic (as they should), but with a better error message.
## [0.1.4] - 2022-08-30
### Changed
- Upgrade to Rust edition 2021. Also increases the MSRV to Rust 1.60.
- Add null-pointer optimization to `Sender`, `Receiver` and `SendError`.
This reduces the call stack size of Sender::send and it makes
`Option<Sender>` and `Option<Receiver>` pointer sized (#18).
- Relax the memory ordering of all atomic operations from `SeqCst` to the most appropriate
lower ordering (#17 + #20).
### Fixed
- Fix undefined behavior due to multiple mutable references to the same channel instance (#18).
- Fix race condition that could happen during unparking of a receiving `Receiver` (#17 + #20).
## [0.1.3] - 2021-11-23
### Fixed
- Keep the *last* `Waker` in `Future::poll`, not the *first* one. Stops breaking the contract
on how futures should work.
## [0.1.2] - 2020-08-11
### Fixed
- Fix unreachable code panic that happened if the `Receiver` of an empty but open channel was
polled and then dropped.
## [0.1.1] - 2020-05-10
Initial implementation. Supports basically all the (for now) intended functionality.
Sender is as lock-free as I think it can get and the receiver can both do thread blocking
and be awaited asynchronously. The receiver also has a wait-free `try_recv` method.
The crate has two features. They are activated by default, but the user can opt out of async
support as well as usage of libstd (making the crate `no_std` but still requiring liballoc)
## [0.1.0] - 2019-05-30
Name reserved on crate.io by someone other than the author of this crate.

1118
third_party/rust/oneshot-uniffi/Cargo.lock сгенерированный поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,64 @@
# 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"
rust-version = "1.60.0"
name = "oneshot-uniffi"
version = "0.1.5"
authors = ["Linus Färnstrand <faern@faern.net>"]
description = """
Patched version of oneshot specifically for the UniFFI project.
This removes the `loom` target and dependency which helps with UniFFI's downstream consumers.
"""
readme = "README.md"
keywords = [
"oneshot",
"spsc",
"async",
"sync",
"channel",
]
categories = [
"asynchronous",
"concurrency",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/faern/oneshot"
[[bench]]
name = "benches"
harness = false
[dev-dependencies.async-std]
version = "1"
features = ["attributes"]
[dev-dependencies.criterion]
version = "0.3"
[dev-dependencies.tokio]
version = "1"
features = [
"rt",
"rt-multi-thread",
"macros",
"time",
]
[features]
async = []
default = [
"std",
"async",
]
std = []

94
third_party/rust/oneshot-uniffi/README.md поставляемый Normal file
Просмотреть файл

@ -0,0 +1,94 @@
# oneshot
Oneshot spsc (single producer, single consumer) channel. Meaning each channel instance
can only transport a single message. This has a few nice outcomes. One thing is that
the implementation can be very efficient, utilizing the knowledge that there will
only be one message. But more importantly, it allows the API to be expressed in such
a way that certain edge cases that you don't want to care about when only sending a
single message on a channel does not exist. For example: The sender can't be copied
or cloned, and the send method takes ownership and consumes the sender.
So you are guaranteed, at the type level, that there can only be one message sent.
The sender's send method is non-blocking, and potentially lock- and wait-free.
See documentation on [Sender::send] for situations where it might not be fully wait-free.
The receiver supports both lock- and wait-free `try_recv` as well as indefinite and time
limited thread blocking receive operations. The receiver also implements `Future` and
supports asynchronously awaiting the message.
## Examples
This example sets up a background worker that processes requests coming in on a standard
mpsc channel and replies on a oneshot channel provided with each request. The worker can
be interacted with both from sync and async contexts since the oneshot receiver
can receive both blocking and async.
```rust
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
type Request = String;
// Starts a background thread performing some computation on requests sent to it.
// Delivers the response back over a oneshot channel.
fn spawn_processing_thread() -> mpsc::Sender<(Request, oneshot::Sender<usize>)> {
let (request_sender, request_receiver) = mpsc::channel::<(Request, oneshot::Sender<usize>)>();
thread::spawn(move || {
for (request_data, response_sender) in request_receiver.iter() {
let compute_operation = || request_data.len();
let _ = response_sender.send(compute_operation()); // <- Send on the oneshot channel
}
});
request_sender
}
let processor = spawn_processing_thread();
// If compiled with `std` the library can receive messages with timeout on regular threads
#[cfg(feature = "std")] {
let (response_sender, response_receiver) = oneshot::channel();
let request = Request::from("data from sync thread");
processor.send((request, response_sender)).expect("Processor down");
match response_receiver.recv_timeout(Duration::from_secs(1)) { // <- Receive on the oneshot channel
Ok(result) => println!("Processor returned {}", result),
Err(oneshot::RecvTimeoutError::Timeout) => eprintln!("Processor was too slow"),
Err(oneshot::RecvTimeoutError::Disconnected) => panic!("Processor exited"),
}
}
// If compiled with the `async` feature, the `Receiver` can be awaited in an async context
#[cfg(feature = "async")] {
tokio::runtime::Runtime::new()
.unwrap()
.block_on(async move {
let (response_sender, response_receiver) = oneshot::channel();
let request = Request::from("data from sync thread");
processor.send((request, response_sender)).expect("Processor down");
match response_receiver.await { // <- Receive on the oneshot channel asynchronously
Ok(result) => println!("Processor returned {}", result),
Err(_e) => panic!("Processor exited"),
}
});
}
```
## Sync vs async
The main motivation for writing this library was that there were no (known to me) channel
implementations allowing you to seamlessly send messages between a normal thread and an async
task, or the other way around. If message passing is the way you are communicating, of course
that should work smoothly between the sync and async parts of the program!
This library achieves that by having a fast and cheap send operation that can
be used in both sync threads and async tasks. The receiver has both thread blocking
receive methods for synchronous usage, and implements `Future` for asynchronous usage.
The receiving endpoint of this channel implements Rust's `Future` trait and can be waited on
in an asynchronous task. This implementation is completely executor/runtime agnostic. It should
be possible to use this library with any executor.
License: MIT OR Apache-2.0

122
third_party/rust/oneshot-uniffi/benches/benches.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,122 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use std::mem;
use std::time::{Duration, Instant};
criterion_group!(benches, bench);
criterion_main!(benches);
macro_rules! bench_send_and_recv {
($c:expr, $($type:ty => $value:expr);+) => {
// Sanity check that all $values are of $type.
$(let _: $type = $value;)*
{
let mut group = $c.benchmark_group("create_channel");
$(group.bench_function(stringify!($type), |b| {
b.iter(oneshot::channel::<$type>)
});)*
group.finish();
}
{
let mut group = $c.benchmark_group("create_and_send");
$(group.bench_function(stringify!($type), |b| {
b.iter(|| {
let (sender, _receiver) = oneshot::channel();
sender.send(black_box($value)).unwrap()
});
});)*
group.finish();
}
{
let mut group = $c.benchmark_group("create_and_send_on_closed");
$(group.bench_function(stringify!($type), |b| {
b.iter(|| {
let (sender, _) = oneshot::channel();
sender.send(black_box($value)).unwrap_err()
});
});)*
group.finish();
}
{
let mut group = $c.benchmark_group("create_send_and_recv");
$(group.bench_function(stringify!($type), |b| {
b.iter(|| {
let (sender, receiver) = oneshot::channel();
sender.send(black_box($value)).unwrap();
receiver.recv().unwrap()
});
});)*
group.finish();
}
{
let mut group = $c.benchmark_group("create_send_and_recv_ref");
$(group.bench_function(stringify!($type), |b| {
b.iter(|| {
let (sender, receiver) = oneshot::channel();
sender.send(black_box($value)).unwrap();
receiver.recv_ref().unwrap()
});
});)*
group.finish();
}
};
}
fn bench(c: &mut Criterion) {
bench_send_and_recv!(c,
() => ();
u8 => 7u8;
usize => 9876usize;
u128 => 1234567u128;
[u8; 64] => [0b10101010u8; 64];
[u8; 4096] => [0b10101010u8; 4096]
);
bench_try_recv(c);
bench_recv_deadline_now(c);
bench_recv_timeout_zero(c);
}
fn bench_try_recv(c: &mut Criterion) {
let (sender, receiver) = oneshot::channel::<u128>();
c.bench_function("try_recv_empty", |b| {
b.iter(|| receiver.try_recv().unwrap_err())
});
mem::drop(sender);
c.bench_function("try_recv_empty_closed", |b| {
b.iter(|| receiver.try_recv().unwrap_err())
});
}
fn bench_recv_deadline_now(c: &mut Criterion) {
let now = Instant::now();
{
let (_sender, receiver) = oneshot::channel::<u128>();
c.bench_function("recv_deadline_now", |b| {
b.iter(|| receiver.recv_deadline(now).unwrap_err())
});
}
{
let (sender, receiver) = oneshot::channel::<u128>();
mem::drop(sender);
c.bench_function("recv_deadline_now_closed", |b| {
b.iter(|| receiver.recv_deadline(now).unwrap_err())
});
}
}
fn bench_recv_timeout_zero(c: &mut Criterion) {
let zero = Duration::from_nanos(0);
{
let (_sender, receiver) = oneshot::channel::<u128>();
c.bench_function("recv_timeout_zero", |b| {
b.iter(|| receiver.recv_timeout(zero).unwrap_err())
});
}
{
let (sender, receiver) = oneshot::channel::<u128>();
mem::drop(sender);
c.bench_function("recv_timeout_zero_closed", |b| {
b.iter(|| receiver.recv_timeout(zero).unwrap_err())
});
}
}

13
third_party/rust/oneshot-uniffi/check_mem_leaks.sh поставляемый Executable file
Просмотреть файл

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eu
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
for example_path in examples/*.rs; do
example_filename=$(basename -- $example_path)
example=${example_filename%.*}
echo $example
cargo valgrind run --example "$example"
done

18
third_party/rust/oneshot-uniffi/examples/recv_before_send.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,18 @@
#[cfg(feature = "std")]
fn main() {
use std::thread;
use std::time::Duration;
let (sender, receiver) = oneshot::channel();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
sender.send(9u128).unwrap();
});
assert_eq!(receiver.recv(), Ok(9));
t.join().unwrap();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,18 @@
#[cfg(feature = "std")]
fn main() {
use std::thread;
use std::time::Duration;
let (sender, receiver) = oneshot::channel::<u128>();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
std::mem::drop(sender);
});
assert!(receiver.recv().is_err());
t.join().unwrap();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,18 @@
#[cfg(feature = "std")]
fn main() {
use std::thread;
use std::time::Duration;
let (sender, receiver) = oneshot::channel();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
sender.send(9u128).unwrap();
});
assert_eq!(receiver.recv_ref(), Ok(9));
t.join().unwrap();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,18 @@
#[cfg(feature = "std")]
fn main() {
use std::thread;
use std::time::Duration;
let (sender, receiver) = oneshot::channel::<u128>();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
std::mem::drop(sender);
});
assert!(receiver.recv_ref().is_err());
t.join().unwrap();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,18 @@
#[cfg(feature = "std")]
fn main() {
use std::thread;
use std::time::Duration;
let (sender, receiver) = oneshot::channel();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
sender.send(9u128).unwrap();
});
assert_eq!(receiver.recv_timeout(Duration::from_millis(100)), Ok(9));
t.join().unwrap();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,18 @@
#[cfg(feature = "std")]
fn main() {
use std::thread;
use std::time::Duration;
let (sender, receiver) = oneshot::channel::<u128>();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
std::mem::drop(sender);
});
assert!(receiver.recv_timeout(Duration::from_millis(100)).is_err());
t.join().unwrap();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,11 @@
#[cfg(feature = "std")]
fn main() {
let (sender, receiver) = oneshot::channel::<u128>();
std::mem::drop(sender);
receiver.recv().unwrap_err();
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

11
third_party/rust/oneshot-uniffi/examples/send_before_recv.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,11 @@
#[cfg(feature = "std")]
fn main() {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
assert_eq!(receiver.recv(), Ok(19i128));
}
#[cfg(not(feature = "std"))]
fn main() {
panic!("This example is only for when the \"sync\" feature is used");
}

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

@ -0,0 +1,7 @@
use std::mem;
fn main() {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
mem::drop(receiver);
}

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

@ -0,0 +1,8 @@
use std::mem;
fn main() {
let (sender, receiver) = oneshot::channel();
mem::drop(receiver);
let send_error = sender.send(5u128).unwrap_err();
assert_eq!(send_error.into_inner(), 5);
}

144
third_party/rust/oneshot-uniffi/src/errors.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,144 @@
use super::{dealloc, Channel};
use core::fmt;
use core::mem;
use core::ptr::NonNull;
/// An error returned when trying to send on a closed channel. Returned from
/// [`Sender::send`] if the corresponding [`Receiver`] has already been dropped.
///
/// The message that could not be sent can be retreived again with [`SendError::into_inner`].
pub struct SendError<T> {
channel_ptr: NonNull<Channel<T>>,
}
unsafe impl<T: Send> Send for SendError<T> {}
unsafe impl<T: Sync> Sync for SendError<T> {}
impl<T> SendError<T> {
/// # Safety
///
/// By calling this function, the caller semantically transfers ownership of the
/// channel's resources to the created `SendError`. Thus the caller must ensure that the
/// pointer is not used in a way which would violate this ownership transfer. Moreover,
/// the caller must assert that the channel contains a valid, initialized message.
pub(crate) const unsafe fn new(channel_ptr: NonNull<Channel<T>>) -> Self {
Self { channel_ptr }
}
/// Consumes the error and returns the message that failed to be sent.
#[inline]
pub fn into_inner(self) -> T {
let channel_ptr = self.channel_ptr;
// Don't run destructor if we consumed ourselves. Freeing happens here.
mem::forget(self);
// SAFETY: we have ownership of the channel
let channel: &Channel<T> = unsafe { channel_ptr.as_ref() };
// SAFETY: we know that the message is initialized according to the safety requirements of
// `new`
let message = unsafe { channel.take_message() };
// SAFETY: we own the channel
unsafe { dealloc(channel_ptr) };
message
}
/// Get a reference to the message that failed to be sent.
#[inline]
pub fn as_inner(&self) -> &T {
unsafe { self.channel_ptr.as_ref().message().assume_init_ref() }
}
}
impl<T> Drop for SendError<T> {
fn drop(&mut self) {
// SAFETY: we have ownership of the channel and require that the message is initialized
// upon construction
unsafe {
self.channel_ptr.as_ref().drop_message();
dealloc(self.channel_ptr);
}
}
}
impl<T> fmt::Display for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"sending on a closed channel".fmt(f)
}
}
impl<T> fmt::Debug for SendError<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SendError<{}>(_)", stringify!(T))
}
}
#[cfg(feature = "std")]
impl<T> std::error::Error for SendError<T> {}
/// An error returned from the indefinitely blocking recv functions on a [`Receiver`].
///
/// The recv operation can only fail if the corresponding [`Sender`] was dropped before sending
/// any message. Or if a message has already been sent and received on the channel.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct RecvError;
impl fmt::Display for RecvError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
"receiving on a closed channel".fmt(f)
}
}
#[cfg(feature = "std")]
impl std::error::Error for RecvError {}
/// An error returned when trying a non blocking receive on a [`Receiver`].
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum TryRecvError {
/// The channel is still open, but there was no message present in it.
Empty,
/// The channel is closed. Either the sender was dropped before sending any message, or the
/// message has already been extracted from the receiver.
Disconnected,
}
impl fmt::Display for TryRecvError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match self {
TryRecvError::Empty => "receiving on an empty channel",
TryRecvError::Disconnected => "receiving on a closed channel",
};
msg.fmt(f)
}
}
#[cfg(feature = "std")]
impl std::error::Error for TryRecvError {}
/// An error returned when trying a time limited blocking receive on a [`Receiver`].
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub enum RecvTimeoutError {
/// No message arrived on the channel before the timeout was reached. The channel is still open.
Timeout,
/// The channel is closed. Either the sender was dropped before sending any message, or the
/// message has already been extracted from the receiver.
Disconnected,
}
impl fmt::Display for RecvTimeoutError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let msg = match self {
RecvTimeoutError::Timeout => "timed out waiting on channel",
RecvTimeoutError::Disconnected => "channel is empty and sending half is closed",
};
msg.fmt(f)
}
}
#[cfg(feature = "std")]
impl std::error::Error for RecvTimeoutError {}

1193
third_party/rust/oneshot-uniffi/src/lib.rs поставляемый Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

151
third_party/rust/oneshot-uniffi/src/loombox.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,151 @@
use core::{borrow, fmt, hash, mem, ptr};
use loom::alloc;
pub struct Box<T: ?Sized> {
ptr: *mut T,
}
impl<T> Box<T> {
pub fn new(value: T) -> Self {
let layout = alloc::Layout::new::<T>();
let ptr = unsafe { alloc::alloc(layout) } as *mut T;
unsafe { ptr::write(ptr, value) };
Self { ptr }
}
}
impl<T: ?Sized> Box<T> {
#[inline]
pub fn into_raw(b: Box<T>) -> *mut T {
let ptr = b.ptr;
mem::forget(b);
ptr
}
pub const unsafe fn from_raw(ptr: *mut T) -> Box<T> {
Self { ptr }
}
}
impl<T: ?Sized> Drop for Box<T> {
fn drop(&mut self) {
unsafe {
let size = mem::size_of_val(&*self.ptr);
let align = mem::align_of_val(&*self.ptr);
let layout = alloc::Layout::from_size_align(size, align).unwrap();
ptr::drop_in_place(self.ptr);
alloc::dealloc(self.ptr as *mut u8, layout);
}
}
}
unsafe impl<T: Send> Send for Box<T> {}
unsafe impl<T: Sync> Sync for Box<T> {}
impl<T: ?Sized> core::ops::Deref for Box<T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.ptr }
}
}
impl<T: ?Sized> core::ops::DerefMut for Box<T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.ptr }
}
}
impl<T: ?Sized> borrow::Borrow<T> for Box<T> {
fn borrow(&self) -> &T {
&**self
}
}
impl<T: ?Sized> borrow::BorrowMut<T> for Box<T> {
fn borrow_mut(&mut self) -> &mut T {
&mut **self
}
}
impl<T: ?Sized> AsRef<T> for Box<T> {
fn as_ref(&self) -> &T {
&**self
}
}
impl<T: ?Sized> AsMut<T> for Box<T> {
fn as_mut(&mut self) -> &mut T {
&mut **self
}
}
impl<T: fmt::Display + ?Sized> fmt::Display for Box<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&**self, f)
}
}
impl<T: fmt::Debug + ?Sized> fmt::Debug for Box<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Debug::fmt(&**self, f)
}
}
impl<T: Clone> Clone for Box<T> {
#[inline]
fn clone(&self) -> Box<T> {
Self::new(self.as_ref().clone())
}
}
impl<T: ?Sized + PartialEq> PartialEq for Box<T> {
#[inline]
fn eq(&self, other: &Box<T>) -> bool {
PartialEq::eq(&**self, &**other)
}
#[allow(clippy::partialeq_ne_impl)]
#[inline]
fn ne(&self, other: &Box<T>) -> bool {
PartialEq::ne(&**self, &**other)
}
}
impl<T: ?Sized + Eq> Eq for Box<T> {}
impl<T: ?Sized + PartialOrd> PartialOrd for Box<T> {
#[inline]
fn partial_cmp(&self, other: &Box<T>) -> Option<core::cmp::Ordering> {
PartialOrd::partial_cmp(&**self, &**other)
}
#[inline]
fn lt(&self, other: &Box<T>) -> bool {
PartialOrd::lt(&**self, &**other)
}
#[inline]
fn le(&self, other: &Box<T>) -> bool {
PartialOrd::le(&**self, &**other)
}
#[inline]
fn ge(&self, other: &Box<T>) -> bool {
PartialOrd::ge(&**self, &**other)
}
#[inline]
fn gt(&self, other: &Box<T>) -> bool {
PartialOrd::gt(&**self, &**other)
}
}
impl<T: ?Sized + Ord> Ord for Box<T> {
#[inline]
fn cmp(&self, other: &Box<T>) -> core::cmp::Ordering {
Ord::cmp(&**self, &**other)
}
}
impl<T: ?Sized + hash::Hash> hash::Hash for Box<T> {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
(**self).hash(state);
}
}

37
third_party/rust/oneshot-uniffi/tests/assert_mem.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,37 @@
use oneshot::{Receiver, Sender};
use std::mem;
/// Just sanity check that both channel endpoints stay the size of a single pointer.
#[test]
fn channel_endpoints_single_pointer() {
const PTR_SIZE: usize = mem::size_of::<*const ()>();
assert_eq!(mem::size_of::<Sender<()>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Receiver<()>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Sender<u8>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Receiver<u8>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Sender<[u8; 1024]>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Receiver<[u8; 1024]>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Option<Sender<[u8; 1024]>>>(), PTR_SIZE);
assert_eq!(mem::size_of::<Option<Receiver<[u8; 1024]>>>(), PTR_SIZE);
}
/// Check that the `SendError` stays small. Useful to automatically detect if it is refactored
/// to become large. We do not want the stack requirement for calling `Sender::send` to grow.
#[test]
fn error_sizes() {
const PTR_SIZE: usize = mem::size_of::<usize>();
assert_eq!(mem::size_of::<oneshot::SendError<()>>(), PTR_SIZE);
assert_eq!(mem::size_of::<oneshot::SendError<u8>>(), PTR_SIZE);
assert_eq!(mem::size_of::<oneshot::SendError<[u8; 1024]>>(), PTR_SIZE);
// The type returned from `Sender::send` is also just pointer sized
assert_eq!(
mem::size_of::<Result<(), oneshot::SendError<[u8; 1024]>>>(),
PTR_SIZE
);
}

128
third_party/rust/oneshot-uniffi/tests/async.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,128 @@
#![cfg(all(feature = "async", not(loom)))]
use core::mem;
use core::time::Duration;
mod helpers;
use helpers::DropCounter;
#[tokio::test]
async fn send_before_await_tokio() {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
assert_eq!(receiver.await, Ok(19i128));
}
#[async_std::test]
async fn send_before_await_async_std() {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
assert_eq!(receiver.await, Ok(19i128));
}
#[tokio::test]
async fn await_with_dropped_sender_tokio() {
let (sender, receiver) = oneshot::channel::<u128>();
mem::drop(sender);
receiver.await.unwrap_err();
}
#[async_std::test]
async fn await_with_dropped_sender_async_std() {
let (sender, receiver) = oneshot::channel::<u128>();
mem::drop(sender);
receiver.await.unwrap_err();
}
#[tokio::test]
async fn await_before_send_tokio() {
let (sender, receiver) = oneshot::channel();
let (message, counter) = DropCounter::new(79u128);
let t = tokio::spawn(async move {
tokio::time::sleep(Duration::from_millis(10)).await;
sender.send(message)
});
let returned_message = receiver.await.unwrap();
assert_eq!(counter.count(), 0);
assert_eq!(*returned_message.value(), 79u128);
mem::drop(returned_message);
assert_eq!(counter.count(), 1);
t.await.unwrap().unwrap();
}
#[async_std::test]
async fn await_before_send_async_std() {
let (sender, receiver) = oneshot::channel();
let (message, counter) = DropCounter::new(79u128);
let t = async_std::task::spawn(async move {
async_std::task::sleep(Duration::from_millis(10)).await;
sender.send(message)
});
let returned_message = receiver.await.unwrap();
assert_eq!(counter.count(), 0);
assert_eq!(*returned_message.value(), 79u128);
mem::drop(returned_message);
assert_eq!(counter.count(), 1);
t.await.unwrap();
}
#[tokio::test]
async fn await_before_send_then_drop_sender_tokio() {
let (sender, receiver) = oneshot::channel::<u128>();
let t = tokio::spawn(async {
tokio::time::sleep(Duration::from_millis(10)).await;
mem::drop(sender);
});
assert!(receiver.await.is_err());
t.await.unwrap();
}
#[async_std::test]
async fn await_before_send_then_drop_sender_async_std() {
let (sender, receiver) = oneshot::channel::<u128>();
let t = async_std::task::spawn(async {
async_std::task::sleep(Duration::from_millis(10)).await;
mem::drop(sender);
});
assert!(receiver.await.is_err());
t.await;
}
// Tests that the Receiver handles being used synchronously even after being polled
#[tokio::test]
async fn poll_future_and_then_try_recv() {
use core::future::Future;
use core::pin::Pin;
use core::task::{self, Poll};
struct StupidReceiverFuture(oneshot::Receiver<()>);
impl Future for StupidReceiverFuture {
type Output = Result<(), oneshot::RecvError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
let poll_result = Future::poll(Pin::new(&mut self.0), cx);
self.0.try_recv().expect_err("Should never be a message");
poll_result
}
}
let (sender, receiver) = oneshot::channel();
let t = tokio::spawn(async {
tokio::time::sleep(Duration::from_millis(20)).await;
mem::drop(sender);
});
StupidReceiverFuture(receiver).await.unwrap_err();
t.await.unwrap();
}
#[tokio::test]
async fn poll_receiver_then_drop_it() {
let (sender, receiver) = oneshot::channel::<()>();
// This will poll the receiver and then give up after 100 ms.
tokio::time::timeout(Duration::from_millis(100), receiver)
.await
.unwrap_err();
// Make sure the receiver has been dropped by the runtime.
assert!(sender.send(()).is_err());
}

65
third_party/rust/oneshot-uniffi/tests/future.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,65 @@
#![cfg(feature = "async")]
use core::{future, mem, pin, task};
#[cfg(loom)]
pub use loom::sync::{Arc, Mutex};
#[cfg(not(loom))]
pub use std::sync::{Arc, Mutex};
mod helpers;
use helpers::maybe_loom_model;
#[test]
fn multiple_receiver_polls_keeps_only_latest_waker() {
#[derive(Default)]
struct MockWaker {
cloned: usize,
dropped: usize,
}
fn clone_mock_waker(waker: *const ()) -> task::RawWaker {
let mock_waker = unsafe { Arc::from_raw(waker as *const Mutex<MockWaker>) };
mock_waker.lock().unwrap().cloned += 1;
let new_waker =
task::RawWaker::new(Arc::into_raw(mock_waker.clone()) as *const (), &VTABLE);
mem::forget(mock_waker);
new_waker
}
fn drop_mock_waker(waker: *const ()) {
let mock_waker = unsafe { Arc::from_raw(waker as *const Mutex<MockWaker>) };
mock_waker.lock().unwrap().dropped += 1;
}
const VTABLE: task::RawWakerVTable =
task::RawWakerVTable::new(clone_mock_waker, |_| (), |_| (), drop_mock_waker);
maybe_loom_model(|| {
let mock_waker1 = Arc::new(Mutex::new(MockWaker::default()));
let raw_waker1 =
task::RawWaker::new(Arc::into_raw(mock_waker1.clone()) as *const (), &VTABLE);
let waker1 = unsafe { task::Waker::from_raw(raw_waker1) };
let mut context1 = task::Context::from_waker(&waker1);
let (_sender, mut receiver) = oneshot::channel::<()>();
let poll_result = future::Future::poll(pin::Pin::new(&mut receiver), &mut context1);
assert_eq!(poll_result, task::Poll::Pending);
assert_eq!(mock_waker1.lock().unwrap().cloned, 1);
assert_eq!(mock_waker1.lock().unwrap().dropped, 0);
let mock_waker2 = Arc::new(Mutex::new(MockWaker::default()));
let raw_waker2 =
task::RawWaker::new(Arc::into_raw(mock_waker2.clone()) as *const (), &VTABLE);
let waker2 = unsafe { task::Waker::from_raw(raw_waker2) };
let mut context2 = task::Context::from_waker(&waker2);
let poll_result = future::Future::poll(pin::Pin::new(&mut receiver), &mut context2);
assert_eq!(poll_result, task::Poll::Pending);
assert_eq!(mock_waker2.lock().unwrap().cloned, 1);
assert_eq!(mock_waker2.lock().unwrap().dropped, 0);
assert_eq!(mock_waker1.lock().unwrap().cloned, 1);
assert_eq!(mock_waker1.lock().unwrap().dropped, 1);
});
}

63
third_party/rust/oneshot-uniffi/tests/helpers/mod.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,63 @@
#![allow(dead_code)]
extern crate alloc;
#[cfg(not(loom))]
use alloc::sync::Arc;
#[cfg(not(loom))]
use core::sync::atomic::{AtomicUsize, Ordering::SeqCst};
#[cfg(loom)]
use loom::sync::{
atomic::{AtomicUsize, Ordering::SeqCst},
Arc,
};
#[cfg(loom)]
pub mod waker;
pub fn maybe_loom_model(test: impl Fn() + Sync + Send + 'static) {
#[cfg(loom)]
loom::model(test);
#[cfg(not(loom))]
test();
}
pub struct DropCounter<T> {
drop_count: Arc<AtomicUsize>,
value: Option<T>,
}
pub struct DropCounterHandle(Arc<AtomicUsize>);
impl<T> DropCounter<T> {
pub fn new(value: T) -> (Self, DropCounterHandle) {
let drop_count = Arc::new(AtomicUsize::new(0));
(
Self {
drop_count: drop_count.clone(),
value: Some(value),
},
DropCounterHandle(drop_count),
)
}
pub fn value(&self) -> &T {
self.value.as_ref().unwrap()
}
pub fn into_value(mut self) -> T {
self.value.take().unwrap()
}
}
impl DropCounterHandle {
pub fn count(&self) -> usize {
self.0.load(SeqCst)
}
}
impl<T> Drop for DropCounter<T> {
fn drop(&mut self) {
self.drop_count.fetch_add(1, SeqCst);
}
}

64
third_party/rust/oneshot-uniffi/tests/helpers/waker.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,64 @@
//! Creates a Waker that can be observed from tests.
use std::mem::forget;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use std::task::{RawWaker, RawWakerVTable, Waker};
#[derive(Default)]
pub struct WakerHandle {
clone_count: AtomicU32,
drop_count: AtomicU32,
wake_count: AtomicU32,
}
impl WakerHandle {
pub fn clone_count(&self) -> u32 {
self.clone_count.load(Ordering::Relaxed)
}
pub fn drop_count(&self) -> u32 {
self.drop_count.load(Ordering::Relaxed)
}
pub fn wake_count(&self) -> u32 {
self.wake_count.load(Ordering::Relaxed)
}
}
pub fn waker() -> (Waker, Arc<WakerHandle>) {
let waker_handle = Arc::new(WakerHandle::default());
let waker_handle_ptr = Arc::into_raw(waker_handle.clone());
let raw_waker = RawWaker::new(waker_handle_ptr as *const _, waker_vtable());
(unsafe { Waker::from_raw(raw_waker) }, waker_handle)
}
pub(super) fn waker_vtable() -> &'static RawWakerVTable {
&RawWakerVTable::new(clone_raw, wake_raw, wake_by_ref_raw, drop_raw)
}
unsafe fn clone_raw(data: *const ()) -> RawWaker {
let handle: Arc<WakerHandle> = Arc::from_raw(data as *const _);
handle.clone_count.fetch_add(1, Ordering::Relaxed);
forget(handle.clone());
forget(handle);
RawWaker::new(data, waker_vtable())
}
unsafe fn wake_raw(data: *const ()) {
let handle: Arc<WakerHandle> = Arc::from_raw(data as *const _);
handle.wake_count.fetch_add(1, Ordering::Relaxed);
handle.drop_count.fetch_add(1, Ordering::Relaxed);
}
unsafe fn wake_by_ref_raw(data: *const ()) {
let handle: Arc<WakerHandle> = Arc::from_raw(data as *const _);
handle.wake_count.fetch_add(1, Ordering::Relaxed);
forget(handle)
}
unsafe fn drop_raw(data: *const ()) {
let handle: Arc<WakerHandle> = Arc::from_raw(data as *const _);
handle.drop_count.fetch_add(1, Ordering::Relaxed);
drop(handle)
}

223
third_party/rust/oneshot-uniffi/tests/loom.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,223 @@
#![cfg(loom)]
use oneshot::TryRecvError;
use loom::hint;
use loom::thread;
#[cfg(feature = "async")]
use std::future::Future;
#[cfg(feature = "async")]
use std::pin::Pin;
#[cfg(feature = "async")]
use std::task::{self, Poll};
#[cfg(feature = "std")]
use std::time::Duration;
mod helpers;
#[test]
fn try_recv() {
loom::model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
let t = thread::spawn(move || loop {
match receiver.try_recv() {
Ok(msg) => break msg,
Err(TryRecvError::Empty) => hint::spin_loop(),
Err(TryRecvError::Disconnected) => panic!("Should not be disconnected"),
}
});
assert!(sender.send(19).is_ok());
assert_eq!(t.join().unwrap(), 19);
})
}
#[cfg(feature = "std")]
#[test]
fn send_recv_different_threads() {
loom::model(|| {
let (sender, receiver) = oneshot::channel();
let t2 = thread::spawn(move || {
assert_eq!(receiver.recv_timeout(Duration::from_millis(1)), Ok(9));
});
let t1 = thread::spawn(move || {
sender.send(9u128).unwrap();
});
t1.join().unwrap();
t2.join().unwrap();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_drop_sender_different_threads() {
loom::model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
let t2 = thread::spawn(move || {
assert!(receiver.recv_timeout(Duration::from_millis(0)).is_err());
});
let t1 = thread::spawn(move || {
drop(sender);
});
t1.join().unwrap();
t2.join().unwrap();
})
}
#[cfg(feature = "async")]
#[test]
fn async_recv() {
loom::model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
let t1 = thread::spawn(move || {
sender.send(987).unwrap();
});
assert_eq!(loom::future::block_on(receiver), Ok(987));
t1.join().unwrap();
})
}
#[cfg(feature = "async")]
#[test]
fn send_then_poll() {
loom::model(|| {
let (sender, mut receiver) = oneshot::channel::<u128>();
sender.send(1234).unwrap();
let (waker, waker_handle) = helpers::waker::waker();
let mut context = task::Context::from_waker(&waker);
assert_eq!(
Pin::new(&mut receiver).poll(&mut context),
Poll::Ready(Ok(1234))
);
assert_eq!(waker_handle.clone_count(), 0);
assert_eq!(waker_handle.drop_count(), 0);
assert_eq!(waker_handle.wake_count(), 0);
})
}
#[cfg(feature = "async")]
#[test]
fn poll_then_send() {
loom::model(|| {
let (sender, mut receiver) = oneshot::channel::<u128>();
let (waker, waker_handle) = helpers::waker::waker();
let mut context = task::Context::from_waker(&waker);
assert_eq!(Pin::new(&mut receiver).poll(&mut context), Poll::Pending);
assert_eq!(waker_handle.clone_count(), 1);
assert_eq!(waker_handle.drop_count(), 0);
assert_eq!(waker_handle.wake_count(), 0);
sender.send(1234).unwrap();
assert_eq!(waker_handle.clone_count(), 1);
assert_eq!(waker_handle.drop_count(), 1);
assert_eq!(waker_handle.wake_count(), 1);
assert_eq!(
Pin::new(&mut receiver).poll(&mut context),
Poll::Ready(Ok(1234))
);
assert_eq!(waker_handle.clone_count(), 1);
assert_eq!(waker_handle.drop_count(), 1);
assert_eq!(waker_handle.wake_count(), 1);
})
}
#[cfg(feature = "async")]
#[test]
fn poll_with_different_wakers() {
loom::model(|| {
let (sender, mut receiver) = oneshot::channel::<u128>();
let (waker1, waker_handle1) = helpers::waker::waker();
let mut context1 = task::Context::from_waker(&waker1);
assert_eq!(Pin::new(&mut receiver).poll(&mut context1), Poll::Pending);
assert_eq!(waker_handle1.clone_count(), 1);
assert_eq!(waker_handle1.drop_count(), 0);
assert_eq!(waker_handle1.wake_count(), 0);
let (waker2, waker_handle2) = helpers::waker::waker();
let mut context2 = task::Context::from_waker(&waker2);
assert_eq!(Pin::new(&mut receiver).poll(&mut context2), Poll::Pending);
assert_eq!(waker_handle1.clone_count(), 1);
assert_eq!(waker_handle1.drop_count(), 1);
assert_eq!(waker_handle1.wake_count(), 0);
assert_eq!(waker_handle2.clone_count(), 1);
assert_eq!(waker_handle2.drop_count(), 0);
assert_eq!(waker_handle2.wake_count(), 0);
// Sending should cause the waker from the latest poll to be woken up
sender.send(1234).unwrap();
assert_eq!(waker_handle1.clone_count(), 1);
assert_eq!(waker_handle1.drop_count(), 1);
assert_eq!(waker_handle1.wake_count(), 0);
assert_eq!(waker_handle2.clone_count(), 1);
assert_eq!(waker_handle2.drop_count(), 1);
assert_eq!(waker_handle2.wake_count(), 1);
})
}
#[cfg(feature = "async")]
#[test]
fn poll_then_try_recv() {
loom::model(|| {
let (_sender, mut receiver) = oneshot::channel::<u128>();
let (waker, waker_handle) = helpers::waker::waker();
let mut context = task::Context::from_waker(&waker);
assert_eq!(Pin::new(&mut receiver).poll(&mut context), Poll::Pending);
assert_eq!(waker_handle.clone_count(), 1);
assert_eq!(waker_handle.drop_count(), 0);
assert_eq!(waker_handle.wake_count(), 0);
assert_eq!(receiver.try_recv(), Err(TryRecvError::Empty));
assert_eq!(Pin::new(&mut receiver).poll(&mut context), Poll::Pending);
assert_eq!(waker_handle.clone_count(), 2);
assert_eq!(waker_handle.drop_count(), 1);
assert_eq!(waker_handle.wake_count(), 0);
})
}
#[cfg(feature = "async")]
#[test]
fn poll_then_try_recv_while_sending() {
loom::model(|| {
let (sender, mut receiver) = oneshot::channel::<u128>();
let (waker, waker_handle) = helpers::waker::waker();
let mut context = task::Context::from_waker(&waker);
assert_eq!(Pin::new(&mut receiver).poll(&mut context), Poll::Pending);
assert_eq!(waker_handle.clone_count(), 1);
assert_eq!(waker_handle.drop_count(), 0);
assert_eq!(waker_handle.wake_count(), 0);
let t = thread::spawn(move || {
sender.send(1234).unwrap();
});
let msg = loop {
match receiver.try_recv() {
Ok(msg) => break msg,
Err(TryRecvError::Empty) => hint::spin_loop(),
Err(TryRecvError::Disconnected) => panic!("Should not be disconnected"),
}
};
assert_eq!(msg, 1234);
assert_eq!(waker_handle.clone_count(), 1);
assert_eq!(waker_handle.drop_count(), 1);
assert_eq!(waker_handle.wake_count(), 1);
t.join().unwrap();
})
}

343
third_party/rust/oneshot-uniffi/tests/sync.rs поставляемый Normal file
Просмотреть файл

@ -0,0 +1,343 @@
use core::mem;
use oneshot::TryRecvError;
#[cfg(feature = "std")]
use oneshot::{RecvError, RecvTimeoutError};
#[cfg(feature = "std")]
use std::time::{Duration, Instant};
#[cfg(feature = "std")]
mod thread {
#[cfg(loom)]
pub use loom::thread::spawn;
#[cfg(not(loom))]
pub use std::thread::{sleep, spawn};
#[cfg(loom)]
pub fn sleep(_timeout: core::time::Duration) {
loom::thread::yield_now()
}
}
mod helpers;
use helpers::{maybe_loom_model, DropCounter};
#[test]
fn send_before_try_recv() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
assert_eq!(receiver.try_recv(), Ok(19i128));
assert_eq!(receiver.try_recv(), Err(TryRecvError::Disconnected));
#[cfg(feature = "std")]
{
assert_eq!(receiver.recv_ref(), Err(RecvError));
assert!(receiver.recv_timeout(Duration::from_secs(1)).is_err());
}
})
}
#[cfg(feature = "std")]
#[test]
fn send_before_recv() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<()>();
assert!(sender.send(()).is_ok());
assert_eq!(receiver.recv(), Ok(()));
});
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u8>();
assert!(sender.send(19).is_ok());
assert_eq!(receiver.recv(), Ok(19));
});
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u64>();
assert!(sender.send(21).is_ok());
assert_eq!(receiver.recv(), Ok(21));
});
// FIXME: This test does not work with loom. There is something that happens after the
// channel object becomes larger than ~500 bytes and that makes an atomic read from the state
// result in "signal: 10, SIGBUS: access to undefined memory"
#[cfg(not(loom))]
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<[u8; 4096]>();
assert!(sender.send([0b10101010; 4096]).is_ok());
assert!(receiver.recv().unwrap()[..] == [0b10101010; 4096][..]);
});
}
#[cfg(feature = "std")]
#[test]
fn send_before_recv_ref() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
assert_eq!(receiver.recv_ref(), Ok(19i128));
assert_eq!(receiver.recv_ref(), Err(RecvError));
assert_eq!(receiver.try_recv(), Err(TryRecvError::Disconnected));
assert!(receiver.recv_timeout(Duration::from_secs(1)).is_err());
})
}
#[cfg(feature = "std")]
#[test]
fn send_before_recv_timeout() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
let start = Instant::now();
let timeout = Duration::from_secs(1);
assert_eq!(receiver.recv_timeout(timeout), Ok(19i128));
assert!(start.elapsed() < Duration::from_millis(100));
assert!(receiver.recv_timeout(timeout).is_err());
assert!(receiver.try_recv().is_err());
assert!(receiver.recv().is_err());
})
}
#[test]
fn send_then_drop_receiver() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
assert!(sender.send(19i128).is_ok());
mem::drop(receiver);
})
}
#[test]
fn send_with_dropped_receiver() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
mem::drop(receiver);
let send_error = sender.send(5u128).unwrap_err();
assert_eq!(*send_error.as_inner(), 5);
assert_eq!(send_error.into_inner(), 5);
})
}
#[test]
fn try_recv_with_dropped_sender() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
mem::drop(sender);
receiver.try_recv().unwrap_err();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_with_dropped_sender() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
mem::drop(sender);
receiver.recv().unwrap_err();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_before_send() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
sender.send(9u128).unwrap();
});
assert_eq!(receiver.recv(), Ok(9));
t.join().unwrap();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_timeout_before_send() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(2));
sender.send(9u128).unwrap();
});
assert_eq!(receiver.recv_timeout(Duration::from_secs(1)), Ok(9));
t.join().unwrap();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_before_send_then_drop_sender() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(10));
mem::drop(sender);
});
assert!(receiver.recv().is_err());
t.join().unwrap();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_timeout_before_send_then_drop_sender() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
let t = thread::spawn(move || {
thread::sleep(Duration::from_millis(10));
mem::drop(sender);
});
assert!(receiver.recv_timeout(Duration::from_secs(1)).is_err());
t.join().unwrap();
})
}
#[test]
fn try_recv() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
assert_eq!(receiver.try_recv(), Err(TryRecvError::Empty));
mem::drop(sender)
})
}
#[cfg(feature = "std")]
#[test]
fn try_recv_then_drop_receiver() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel::<u128>();
let t1 = thread::spawn(move || {
let _ = sender.send(42);
});
let t2 = thread::spawn(move || {
assert!(matches!(
receiver.try_recv(),
Ok(42) | Err(TryRecvError::Empty)
));
mem::drop(receiver);
});
t1.join().unwrap();
t2.join().unwrap();
})
}
#[cfg(feature = "std")]
#[test]
fn recv_deadline_and_timeout_no_time() {
maybe_loom_model(|| {
let (_sender, receiver) = oneshot::channel::<u128>();
let start = Instant::now();
assert_eq!(
receiver.recv_deadline(start),
Err(RecvTimeoutError::Timeout)
);
assert!(start.elapsed() < Duration::from_millis(200));
let start = Instant::now();
assert_eq!(
receiver.recv_timeout(Duration::from_millis(0)),
Err(RecvTimeoutError::Timeout)
);
assert!(start.elapsed() < Duration::from_millis(200));
})
}
// This test doesn't give meaningful results when run with oneshot_test_delay and loom
#[cfg(all(feature = "std", not(all(oneshot_test_delay, loom))))]
#[test]
fn recv_deadline_time_should_elapse() {
maybe_loom_model(|| {
let (_sender, receiver) = oneshot::channel::<u128>();
let start = Instant::now();
#[cfg(not(loom))]
let timeout = Duration::from_millis(100);
#[cfg(loom)]
let timeout = Duration::from_millis(1);
assert_eq!(
receiver.recv_deadline(start + timeout),
Err(RecvTimeoutError::Timeout)
);
assert!(start.elapsed() > timeout);
assert!(start.elapsed() < timeout * 3);
})
}
#[cfg(all(feature = "std", not(all(oneshot_test_delay, loom))))]
#[test]
fn recv_timeout_time_should_elapse() {
maybe_loom_model(|| {
let (_sender, receiver) = oneshot::channel::<u128>();
let start = Instant::now();
#[cfg(not(loom))]
let timeout = Duration::from_millis(100);
#[cfg(loom)]
let timeout = Duration::from_millis(1);
assert_eq!(
receiver.recv_timeout(timeout),
Err(RecvTimeoutError::Timeout)
);
assert!(start.elapsed() > timeout);
assert!(start.elapsed() < timeout * 3);
})
}
#[cfg(not(loom))]
#[test]
fn non_send_type_can_be_used_on_same_thread() {
use std::ptr;
#[derive(Debug, Eq, PartialEq)]
struct NotSend(*mut ());
let (sender, receiver) = oneshot::channel();
sender.send(NotSend(ptr::null_mut())).unwrap();
let reply = receiver.try_recv().unwrap();
assert_eq!(reply, NotSend(ptr::null_mut()));
}
#[test]
fn message_in_channel_dropped_on_receiver_drop() {
maybe_loom_model(|| {
let (sender, receiver) = oneshot::channel();
let (message, counter) = DropCounter::new(());
assert_eq!(counter.count(), 0);
sender.send(message).unwrap();
assert_eq!(counter.count(), 0);
mem::drop(receiver);
assert_eq!(counter.count(), 1);
})
}
#[test]
fn send_error_drops_message_correctly() {
maybe_loom_model(|| {
let (sender, _) = oneshot::channel();
let (message, counter) = DropCounter::new(());
let send_error = sender.send(message).unwrap_err();
assert_eq!(counter.count(), 0);
mem::drop(send_error);
assert_eq!(counter.count(), 1);
});
}
#[test]
fn send_error_drops_message_correctly_on_into_inner() {
maybe_loom_model(|| {
let (sender, _) = oneshot::channel();
let (message, counter) = DropCounter::new(());
let send_error = sender.send(message).unwrap_err();
assert_eq!(counter.count(), 0);
let message = send_error.into_inner();
assert_eq!(counter.count(), 0);
mem::drop(message);
assert_eq!(counter.count(), 1);
});
}

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

@ -1 +1 @@
{"files":{"Cargo.toml":"c74e3df90cd82fb4ee00dd38d7e39cd7a0142ad601b8b63ae214978a28fbe1ac","build.rs":"4326f03729cf8f1673e4228e6dc111de1ea4d8bcc06351f7ae563efb2613f866","src/client.rs":"3d87162e6913a81cc6f5178a7ca791e262d0d029e7dedf3df4fe2f66e5501185","src/config.rs":"7bb678addfae3b4ed5f2892d32263e5b33cc05e5a12a250f664150e78211f94a","src/error.rs":"192ca42af7c6b882f3129378c23b45dab8a0d2b179e23a8813a335ffd56b21dc","src/lib.rs":"416e99894e152f6cea7418ad2fabfd94bc3d907efd9f33fbd2a83fb99452b2df","src/remote_settings.udl":"e38758592ca75adbebb8fe688b10520d9931a5f3292d94f229cba05310756a43","uniffi.toml":"f8ec8dc593e0d501c2e9e40368ec93ec33b1edd8608e29495e0a54b63144e880"},"package":null}
{"files":{"Cargo.toml":"cf0a08d6b0d6285a459b78115aa24818a04b5987652655e64b80ffd8c8ae0813","build.rs":"4326f03729cf8f1673e4228e6dc111de1ea4d8bcc06351f7ae563efb2613f866","src/client.rs":"3d87162e6913a81cc6f5178a7ca791e262d0d029e7dedf3df4fe2f66e5501185","src/config.rs":"7bb678addfae3b4ed5f2892d32263e5b33cc05e5a12a250f664150e78211f94a","src/error.rs":"192ca42af7c6b882f3129378c23b45dab8a0d2b179e23a8813a335ffd56b21dc","src/lib.rs":"416e99894e152f6cea7418ad2fabfd94bc3d907efd9f33fbd2a83fb99452b2df","src/remote_settings.udl":"e38758592ca75adbebb8fe688b10520d9931a5f3292d94f229cba05310756a43","uniffi.toml":"f8ec8dc593e0d501c2e9e40368ec93ec33b1edd8608e29495e0a54b63144e880"},"package":null}

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

@ -23,12 +23,15 @@ license = "MPL-2.0"
[dependencies]
parking_lot = "0.12"
serde = "1"
serde_json = "1"
thiserror = "1.0"
uniffi = "0.24.1"
uniffi = "0.25.2"
url = "2.1"
[dependencies.serde]
version = "1"
features = ["derive"]
[dependencies.viaduct]
path = "../viaduct"
@ -40,5 +43,5 @@ mockito = "0.31"
path = "../support/viaduct-reqwest"
[build-dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
features = ["build"]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"385ca48ab05649059b50b9c6931a4ed009d03f8cb55a6dc94b36ef11501fa8cc","README.md":"8d7457893194e255b87e5a2667ee25c87bd470f5338d7078506f866a67a3fdbd","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/db.rs":"091493d50385379da34b5c780d10e087f307b99f80d80da83b97cf5cc28a6031","src/error.rs":"f47763a1a5d228b446eb8f718433e49fdb1c7b304de1255891215144dddd7a43","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"c6bb8d94cf361482c5ebc182c4c853b72ed4eaad3220a7da9be5c7bd9aa08509","src/pocket.rs":"c4dda43390d1c39dc795933596b3c1e4e282932cac6c69da53c6e05d39e9ef29","src/provider.rs":"23733f87d3fa8d5574f9d12cb1c2762f168c4cd76118d2e27aae905d994ad767","src/rs.rs":"e39c79e7f1e5c369788fa3a2f61b327befe97fedd0cd3a77f0270b34ed01cab0","src/schema.rs":"97cbd1796ccb1416d313e0e2935443bb8b600d877c4dff1fa60b496857b4fa64","src/store.rs":"e16749d44c97a89a1f77f38e525893ad65de68232a986e164dac20d5929f0d18","src/suggest.udl":"653bb92b9f13c5800bd54fc2e11600bae9fda0ea09f072705bc039f33df22dd4","src/suggestion.rs":"4832bb3e66a5a647b3f0b935ff98cd9be585a889224cea9a775c51113b83d9c6","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null}
{"files":{"Cargo.toml":"7839381979f9d80ac58e1dbf5d3403d9b44575f77d20c9b3782733fa69b6bba0","README.md":"8d7457893194e255b87e5a2667ee25c87bd470f5338d7078506f866a67a3fdbd","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/db.rs":"60aaceae91013aac3d6420773eceb8eaa59109509bcba1d9661200bd6ab690ff","src/error.rs":"f47763a1a5d228b446eb8f718433e49fdb1c7b304de1255891215144dddd7a43","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"c6bb8d94cf361482c5ebc182c4c853b72ed4eaad3220a7da9be5c7bd9aa08509","src/pocket.rs":"c4dda43390d1c39dc795933596b3c1e4e282932cac6c69da53c6e05d39e9ef29","src/provider.rs":"23733f87d3fa8d5574f9d12cb1c2762f168c4cd76118d2e27aae905d994ad767","src/rs.rs":"e39c79e7f1e5c369788fa3a2f61b327befe97fedd0cd3a77f0270b34ed01cab0","src/schema.rs":"97cbd1796ccb1416d313e0e2935443bb8b600d877c4dff1fa60b496857b4fa64","src/store.rs":"256c24d6fec81cb596738c79f631d6802472bc941449408fe00f4745fd5204d6","src/suggest.udl":"653bb92b9f13c5800bd54fc2e11600bae9fda0ea09f072705bc039f33df22dd4","src/suggestion.rs":"4832bb3e66a5a647b3f0b935ff98cd9be585a889224cea9a775c51113b83d9c6","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null}

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

@ -28,7 +28,7 @@ once_cell = "1.5"
parking_lot = ">=0.11,<=0.12"
serde_json = "1"
thiserror = "1"
uniffi = "0.24.1"
uniffi = "0.25.2"
[dependencies.interrupt-support]
path = "../support/interrupt"
@ -62,5 +62,5 @@ default-features = false
path = "../support/rc_crypto"
[build-dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
features = ["build"]

11
third_party/rust/suggest/src/db.rs поставляемый
Просмотреть файл

@ -125,7 +125,8 @@ impl<'a> SuggestDao<'a> {
/// Fetches suggestions that match the given query from the database.
pub fn fetch_suggestions(&self, query: &SuggestionQuery) -> Result<Vec<Suggestion>> {
let (keyword_prefix, keyword_suffix) = split_keyword(&query.keyword);
let keyword_lowercased = &query.keyword.to_lowercase();
let (keyword_prefix, keyword_suffix) = split_keyword(keyword_lowercased);
let suggestions_limit = query.limit.unwrap_or(-1);
let (mut statement, params) = if query
@ -150,7 +151,7 @@ impl<'a> SuggestDao<'a> {
providers_to_sql_list(&query.providers),
),
)?, vec![
(":keyword", &query.keyword as &dyn ToSql),
(":keyword", keyword_lowercased as &dyn ToSql),
(":keyword_prefix", &keyword_prefix as &dyn ToSql),
(":suggestions_limit", &suggestions_limit as &dyn ToSql),
])
@ -167,7 +168,7 @@ impl<'a> SuggestDao<'a> {
providers_to_sql_list(&query.providers),
),
)?, vec![
(":keyword", &query.keyword as &dyn ToSql),
(":keyword", keyword_lowercased as &dyn ToSql),
(":suggestions_limit", &suggestions_limit as &dyn ToSql),
])
};
@ -210,7 +211,7 @@ impl<'a> SuggestDao<'a> {
title,
url: cooked_url,
raw_url,
full_keyword: full_keyword(&query.keyword, &keywords),
full_keyword: full_keyword(keyword_lowercased, &keywords),
icon: row.get("icon")?,
impression_url: row.get("impression_url")?,
click_url: cooked_click_url,
@ -233,7 +234,7 @@ impl<'a> SuggestDao<'a> {
Ok(Some(Suggestion::Wikipedia {
title,
url: raw_url,
full_keyword: full_keyword(&query.keyword, &keywords),
full_keyword: full_keyword(keyword_lowercased, &keywords),
icon,
}))
}

56
third_party/rust/suggest/src/store.rs поставляемый
Просмотреть файл

@ -1691,6 +1691,62 @@ mod tests {
]
"#]],
),
(
"MultiMatch; all providers, mixed case",
SuggestionQuery {
keyword: "MultiMatch".into(),
providers: vec![
SuggestionProvider::Amp,
SuggestionProvider::Wikipedia,
SuggestionProvider::Amo,
SuggestionProvider::Pocket,
],
limit: None,
},
expect![[r#"
[
Wikipedia {
title: "Multimatch",
url: "https://wikipedia.org/Multimatch",
icon: Some(
[
97,
108,
115,
111,
45,
97,
110,
45,
105,
99,
111,
110,
],
),
full_keyword: "multimatch",
},
Amo {
title: "Firefox Multimatch",
url: "https://addons.mozilla.org/en-US/firefox/addon/multimatch",
icon_url: "https://addons.mozilla.org/user-media/addon_icons/2633/2633704-64.png?modified=2c11a80b",
description: "amo suggestion multi-match",
rating: Some(
"4.9",
),
number_of_ratings: 888,
guid: "{b9db16a4-6edc-47ec-a1f4-b86292ed211d}",
score: 0.25,
},
Pocket {
title: "Multimatching",
url: "https://getpocket.com/collections/multimatch",
score: 0.25,
is_top_pick: true,
},
]
"#]],
),
(
"multimatch; all providers, limit 2",
SuggestionQuery {

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

@ -1 +1 @@
{"files":{"Cargo.toml":"bb7f41be2a4a4407df9f53ac805e7da3794e6e894b067093b0c29bafbfc780fe","README.md":"6d4ff5b079ac5340d18fa127f583e7ad793c5a2328b8ecd12c3fc723939804f2","build.rs":"aa971160d67ce8626b26e15c04c34b730f594c45c817aae34cfc9f3ea14ae284","src/bso/content.rs":"92935258745bdf0c3915a555cb6884a7fa69faa1290ec2c1815f6e2f3c0f0562","src/bso/crypto.rs":"27602dcccb37d3a55620ee4e16b705da455d49af575de115c7c79c0178eb1d6d","src/bso/mod.rs":"09e723dc7e99295ecafdcadffaf604d66ea27cf2b7f1fd9ab3cac4f4698ff6a7","src/bso/test_utils.rs":"4ec5a2df5e1c0ec14dc770681e959bdcef6ef04f6fde435999197f46a8ae4831","src/client/coll_state.rs":"13e6ef55273baf5536acc369be522e34a803a32cabf19cce43e426aea9b6223e","src/client/coll_update.rs":"dac04a90c29dd969f8b4250414609c9b6d61daf2dfa4ae77d1c4a165ba970b05","src/client/collection_keys.rs":"c27b2277a3a52033b58ab01490fc2ea7007494195dd5e6dc2c6931a4ca96795a","src/client/mod.rs":"8f588d4a035cf79d96f2500f06d5651c1a7c566127c456ffa5429811ddce3fd6","src/client/request.rs":"8841524e37d8195867bdf6ba98c75f610cf47a4644adeebd6372cc6713f2260a","src/client/state.rs":"4e31193ef2471c1dfabf1c6a391bcb95e14ddb45855786a4194ff187d5c9347c","src/client/status.rs":"f445a8765dac9789444e23b5145148413407bb1d18a15ef56682243997f591bf","src/client/storage_client.rs":"8de72d4ba3ca4f68c8e1898466de83a2b543545a18679800cb4f7fbda2dc3183","src/client/sync.rs":"b29abb512ec9d163f7883b71f78c9202802dcb17cad1fc5dc08087fb0bb66704","src/client/sync_multiple.rs":"6e92571132f89744b553190c596be8aff9b2d031d8f79d82c94cdf78b1683f4a","src/client/token.rs":"b268759d31e0fe17e0e2a428694cd9a317fcfbdd52f023d5d8c7cc6f00f1a102","src/client/util.rs":"71cc70ee41f821f53078675e636e9fad9c6046fa1a989e37f5487e340a2277d6","src/client_types.rs":"3c3cac1540b92482f43660d9e43bdde8481c4cc1a98253a68c80e791231f5976","src/clients_engine/engine.rs":"9e11b47be81fc63214f31879af74075674aa50a8f8989afe20fefa7990fa99b9","src/clients_engine/mod.rs":"461729e6f89b66b2cbd89b041a03d4d6a8ba582284ed4f3015cb13e1a0c6da97","src/clients_engine/record.rs":"b0d84bf420743d7638a45e4836633a45e50257d5548fe7ecd04bff4d724439b8","src/clients_engine/ser.rs":"ef12daeb11faf618fe3cafe91f20a031fe5bb6751369b6ee5aee03f196efe88c","src/device_type.rs":"dc2d4296d25e31471c8e68488f1043ff239b902036cd6aea8a686cf79b4ed335","src/enc_payload.rs":"aa3eea7df49b24cd59831680a47c417b73a3e36e6b0f3f4baf14ca66bd68be6b","src/engine/bridged_engine.rs":"f70f1bfce6e0c04b0c72ec9cbfbb12c82d4009a23fb9768792107d41b2865a4f","src/engine/mod.rs":"90f1f9760f5f712a337aebb04e59c736e4b6fbd89d6a188d969210c7f3f321ae","src/engine/request.rs":"5923025fb9550178339f880a1bf8526d8e853e7a0b2bce6d9d687cc808ac0085","src/engine/sync_engine.rs":"5f6489fa2d92475e79fe2f6e54c9f091f2528e2afe0d1aeebeab3863721efbc9","src/error.rs":"a45cfe02e6301f473c34678b694943c1a04308b8c292c6e0448bf495194c3b5e","src/key_bundle.rs":"abd0781f3be8c8e7c691f18bb71f3433b633803c48da9794e15ac6301ed60d6c","src/lib.rs":"f59f8817978d943518dfa03ab31fc0f6b1fc72ee9943a97aef1537e2769649f5","src/record_types.rs":"02bb3d352fb808131d298f9b90d9c95b7e9e0138b97c5401f3b9fdacc5562f44","src/server_timestamp.rs":"0020f31971ccbfc485894cabc3087459d42252b86d7de07f2136997864b0373b","src/sync15.udl":"005b2b056b93c959a04670f6f489afecb8e17093d8e4be34765a3a4cc0faeb8c","src/telemetry.rs":"e3a7e13e85f5e336526ebf07db04c81b8f1ba89ae1db4159a3a570826cb8cfd2","uniffi.toml":"34488f947497a9b05007445dd816024ef02e6b1696f1056ee868f039722828ee"},"package":null}
{"files":{"Cargo.toml":"430dc61a88547775628f467d0a40cf7ee9fd560eb31e5ff0a13a9c28221bc6f1","README.md":"6d4ff5b079ac5340d18fa127f583e7ad793c5a2328b8ecd12c3fc723939804f2","build.rs":"aa971160d67ce8626b26e15c04c34b730f594c45c817aae34cfc9f3ea14ae284","src/bso/content.rs":"92935258745bdf0c3915a555cb6884a7fa69faa1290ec2c1815f6e2f3c0f0562","src/bso/crypto.rs":"27602dcccb37d3a55620ee4e16b705da455d49af575de115c7c79c0178eb1d6d","src/bso/mod.rs":"09e723dc7e99295ecafdcadffaf604d66ea27cf2b7f1fd9ab3cac4f4698ff6a7","src/bso/test_utils.rs":"4ec5a2df5e1c0ec14dc770681e959bdcef6ef04f6fde435999197f46a8ae4831","src/client/coll_state.rs":"13e6ef55273baf5536acc369be522e34a803a32cabf19cce43e426aea9b6223e","src/client/coll_update.rs":"dac04a90c29dd969f8b4250414609c9b6d61daf2dfa4ae77d1c4a165ba970b05","src/client/collection_keys.rs":"c27b2277a3a52033b58ab01490fc2ea7007494195dd5e6dc2c6931a4ca96795a","src/client/mod.rs":"8f588d4a035cf79d96f2500f06d5651c1a7c566127c456ffa5429811ddce3fd6","src/client/request.rs":"8841524e37d8195867bdf6ba98c75f610cf47a4644adeebd6372cc6713f2260a","src/client/state.rs":"4e31193ef2471c1dfabf1c6a391bcb95e14ddb45855786a4194ff187d5c9347c","src/client/status.rs":"f445a8765dac9789444e23b5145148413407bb1d18a15ef56682243997f591bf","src/client/storage_client.rs":"8de72d4ba3ca4f68c8e1898466de83a2b543545a18679800cb4f7fbda2dc3183","src/client/sync.rs":"b29abb512ec9d163f7883b71f78c9202802dcb17cad1fc5dc08087fb0bb66704","src/client/sync_multiple.rs":"6e92571132f89744b553190c596be8aff9b2d031d8f79d82c94cdf78b1683f4a","src/client/token.rs":"b268759d31e0fe17e0e2a428694cd9a317fcfbdd52f023d5d8c7cc6f00f1a102","src/client/util.rs":"71cc70ee41f821f53078675e636e9fad9c6046fa1a989e37f5487e340a2277d6","src/client_types.rs":"3c3cac1540b92482f43660d9e43bdde8481c4cc1a98253a68c80e791231f5976","src/clients_engine/engine.rs":"9e11b47be81fc63214f31879af74075674aa50a8f8989afe20fefa7990fa99b9","src/clients_engine/mod.rs":"461729e6f89b66b2cbd89b041a03d4d6a8ba582284ed4f3015cb13e1a0c6da97","src/clients_engine/record.rs":"b0d84bf420743d7638a45e4836633a45e50257d5548fe7ecd04bff4d724439b8","src/clients_engine/ser.rs":"ef12daeb11faf618fe3cafe91f20a031fe5bb6751369b6ee5aee03f196efe88c","src/device_type.rs":"dc2d4296d25e31471c8e68488f1043ff239b902036cd6aea8a686cf79b4ed335","src/enc_payload.rs":"aa3eea7df49b24cd59831680a47c417b73a3e36e6b0f3f4baf14ca66bd68be6b","src/engine/bridged_engine.rs":"f70f1bfce6e0c04b0c72ec9cbfbb12c82d4009a23fb9768792107d41b2865a4f","src/engine/mod.rs":"90f1f9760f5f712a337aebb04e59c736e4b6fbd89d6a188d969210c7f3f321ae","src/engine/request.rs":"5923025fb9550178339f880a1bf8526d8e853e7a0b2bce6d9d687cc808ac0085","src/engine/sync_engine.rs":"5f6489fa2d92475e79fe2f6e54c9f091f2528e2afe0d1aeebeab3863721efbc9","src/error.rs":"a45cfe02e6301f473c34678b694943c1a04308b8c292c6e0448bf495194c3b5e","src/key_bundle.rs":"abd0781f3be8c8e7c691f18bb71f3433b633803c48da9794e15ac6301ed60d6c","src/lib.rs":"f59f8817978d943518dfa03ab31fc0f6b1fc72ee9943a97aef1537e2769649f5","src/record_types.rs":"02bb3d352fb808131d298f9b90d9c95b7e9e0138b97c5401f3b9fdacc5562f44","src/server_timestamp.rs":"0020f31971ccbfc485894cabc3087459d42252b86d7de07f2136997864b0373b","src/sync15.udl":"005b2b056b93c959a04670f6f489afecb8e17093d8e4be34765a3a4cc0faeb8c","src/telemetry.rs":"e3a7e13e85f5e336526ebf07db04c81b8f1ba89ae1db4159a3a570826cb8cfd2","uniffi.toml":"34488f947497a9b05007445dd816024ef02e6b1696f1056ee868f039722828ee"},"package":null}

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

@ -30,7 +30,7 @@ serde_derive = "1"
serde_json = "1"
serde_path_to_error = "0.1"
thiserror = "1.0"
uniffi = "0.24.1"
uniffi = "0.25.2"
[dependencies.base16]
version = "0.2"
@ -72,7 +72,7 @@ version = "0.7"
default-features = false
[build-dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
features = ["build"]
[features]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"d7cd2b49c0450e74662d7a7d320fd0f4eef25a7ee0c00a78b7bab1b6235a3f99","README.md":"c48b8f391ef822c4f3971b5f453a1e7b43bea232752d520460d2f04803aead1a","build.rs":"33e61b811b19ed2b58e319cc65d5988bed258d2c4fea2d706301184c59847a0f","src/error.rs":"2694657aeb12f99c4b2fe102ad2b08b79955d209201831b3e071129f0b7d7eda","src/lib.rs":"7208f78955e015ef8bab7916307e551cd3c1bd56d7fe14f8b53cd53bc4b38555","src/schema.rs":"2b7b51f3c2edc0ca603495c10b917603fd9ac791c4a366080e40d090b13b91f2","src/storage.rs":"4ad235bda076a85660f7825aea518c0d1ae458e7eddf47b1cf1167ca5a52385f","src/store.rs":"ab0b6214b30b0f0fa7c6a89098ff3db1a8f76264f6711c4481c0be460afe522b","src/sync/bridge.rs":"3bf96a7e028efb771854439f7ec183488f831f859396b562bbcf1ece9a6959b3","src/sync/engine.rs":"13656bf027fcbf0b5682a66d29f062177e49250a73ec1fd0cf2af3f1fe59f12f","src/sync/mod.rs":"09ba3c87f1174a243bf5aaa481effd18929d54359ceb9b23ccb2c32ee3482f34","src/sync/record.rs":"896ebc6aa213bac9e6170c7e0b7dbee322f62e5f6c28462cb6da0bfe8ce938ba","src/tabs.udl":"e94706bc555ed082c806b2bc806f494770b66470aa8ee437f7f43eb26fd8f112","uniffi.toml":"f9125e8d55b109e86076ee88bfd640372f06b142b7db557e41816c7227dd445c"},"package":null}
{"files":{"Cargo.toml":"78673ad0821c15aa4a2f491df9f0012f9405946cf726ea37c7334b300e717dd9","README.md":"c48b8f391ef822c4f3971b5f453a1e7b43bea232752d520460d2f04803aead1a","build.rs":"33e61b811b19ed2b58e319cc65d5988bed258d2c4fea2d706301184c59847a0f","src/error.rs":"2694657aeb12f99c4b2fe102ad2b08b79955d209201831b3e071129f0b7d7eda","src/lib.rs":"7208f78955e015ef8bab7916307e551cd3c1bd56d7fe14f8b53cd53bc4b38555","src/schema.rs":"2b7b51f3c2edc0ca603495c10b917603fd9ac791c4a366080e40d090b13b91f2","src/storage.rs":"4ad235bda076a85660f7825aea518c0d1ae458e7eddf47b1cf1167ca5a52385f","src/store.rs":"ab0b6214b30b0f0fa7c6a89098ff3db1a8f76264f6711c4481c0be460afe522b","src/sync/bridge.rs":"3bf96a7e028efb771854439f7ec183488f831f859396b562bbcf1ece9a6959b3","src/sync/engine.rs":"13656bf027fcbf0b5682a66d29f062177e49250a73ec1fd0cf2af3f1fe59f12f","src/sync/mod.rs":"09ba3c87f1174a243bf5aaa481effd18929d54359ceb9b23ccb2c32ee3482f34","src/sync/record.rs":"896ebc6aa213bac9e6170c7e0b7dbee322f62e5f6c28462cb6da0bfe8ce938ba","src/tabs.udl":"e94706bc555ed082c806b2bc806f494770b66470aa8ee437f7f43eb26fd8f112","uniffi.toml":"f9125e8d55b109e86076ee88bfd640372f06b142b7db557e41816c7227dd445c"},"package":null}

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

@ -29,7 +29,7 @@ serde = "1"
serde_derive = "1"
serde_json = "1"
thiserror = "1.0"
uniffi = "0.24.1"
uniffi = "0.25.2"
url = "2.1"
[dependencies.error-support]
@ -69,5 +69,5 @@ features = [
default-features = false
[build-dependencies.uniffi]
version = "0.24.1"
version = "0.25.2"
features = ["build"]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"5a622a88b40296d8fdcc0f5ef273ac6df3e7f1cc28db290086d71136df5b3b36","build.rs":"7d98b49c1d9c868c4199f0417eaa017ab459cdd536e9a29851d5f707941f9ead","src/arithmetic.udl":"8554c6907ece627645f6b896f71430e5412bf19b0ac6becf63eb9a69868d0f7a","src/lib.rs":"c454193443e92d49f997c760f4131192fb66bf213bbac1710c1ebde19e765e5d","tests/bindings/test_arithmetic.kts":"e0e9347755db4e18f70b1b74c2d5a4aa328373015090ed959b46d65c2a205d92","tests/bindings/test_arithmetic.py":"3e41d69e21e96a6830197c760f3b7bddd754edc0c5515b7bd33b79cccb10f941","tests/bindings/test_arithmetic.rb":"ea0fdce0a4c7b557b427db77521da05240cd6e87d60a128ac2307fab3bbbc76d","tests/bindings/test_arithmetic.swift":"455b87d95fc690af9c35f9e43676e9c855dedddd2fc1c9e1cbaa6a02835c2d4c","tests/test_generated_bindings.rs":"26b92d6b3e648f6fadd4182cbdba4f412b73da48a789785fd98cd486b29abf05","uniffi.toml":"a2d4f46fa51dc1be1e8bcdf67ec13223637fc1b6c6437455cf53c2dae065fb45"},"package":null}
{"files":{"Cargo.toml":"056d32277bd81040868270ae29d54b3d59ba08833cc307e8aee14a61b914d658","build.rs":"7d98b49c1d9c868c4199f0417eaa017ab459cdd536e9a29851d5f707941f9ead","src/arithmetic.udl":"8554c6907ece627645f6b896f71430e5412bf19b0ac6becf63eb9a69868d0f7a","src/lib.rs":"c454193443e92d49f997c760f4131192fb66bf213bbac1710c1ebde19e765e5d","tests/bindings/test_arithmetic.kts":"e0e9347755db4e18f70b1b74c2d5a4aa328373015090ed959b46d65c2a205d92","tests/bindings/test_arithmetic.py":"3e41d69e21e96a6830197c760f3b7bddd754edc0c5515b7bd33b79cccb10f941","tests/bindings/test_arithmetic.rb":"ea0fdce0a4c7b557b427db77521da05240cd6e87d60a128ac2307fab3bbbc76d","tests/bindings/test_arithmetic.swift":"455b87d95fc690af9c35f9e43676e9c855dedddd2fc1c9e1cbaa6a02835c2d4c","tests/test_generated_bindings.rs":"26b92d6b3e648f6fadd4182cbdba4f412b73da48a789785fd98cd486b29abf05","uniffi.toml":"a2d4f46fa51dc1be1e8bcdf67ec13223637fc1b6c6437455cf53c2dae065fb45"},"package":null}

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

@ -28,15 +28,15 @@ crate-type = [
thiserror = "1.0"
[dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
[dev-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["bindgen-tests"]
[build-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["build"]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"3392be31826fc4a45d5de79f58c7f1f0bb092b85de681e63b3acfc03456f7d32","build.rs":"fc5da645c8862e15f3b6879db179a1e5eec6161dc1cfbf95a4db9daf107a133f","src/geometry.udl":"7da7a6ec080c7117ec3c25206e23f9ed436e60b1a26fba34f991547680443550","src/lib.rs":"f9d004c97efb1a719368169f0aab181f27439eda3520c1afaca2420433226682","tests/bindings/test_geometry.kts":"e537185e3c699df1c0468525700e8a38f9a504b2a663c38442146b951e38e9a7","tests/bindings/test_geometry.py":"3ea483b8a4fbe13aefa6641177ae149f75f734bc32bf0da533b97c1abf3dc317","tests/bindings/test_geometry.rb":"17c2fe8a7b477419a6646983dd88f1b07a0304b58a568c03e9bfa640d5b2df5c","tests/bindings/test_geometry.swift":"a61fec6bfe16020809e20e4da372748c24366767138c5672a0bfff85c4b62d78","tests/test_generated_bindings.rs":"ff8fc093ccb6ee3ee2235c09276c7bb87234ad143667429cb721e46379577f3d"},"package":null}
{"files":{"Cargo.toml":"caa1fbdbfdf87670cf571dda2e693e8bc9ba38a0a8fbf803014664e84cde3213","build.rs":"fc5da645c8862e15f3b6879db179a1e5eec6161dc1cfbf95a4db9daf107a133f","src/geometry.udl":"7da7a6ec080c7117ec3c25206e23f9ed436e60b1a26fba34f991547680443550","src/lib.rs":"f9d004c97efb1a719368169f0aab181f27439eda3520c1afaca2420433226682","tests/bindings/test_geometry.kts":"e537185e3c699df1c0468525700e8a38f9a504b2a663c38442146b951e38e9a7","tests/bindings/test_geometry.py":"3ea483b8a4fbe13aefa6641177ae149f75f734bc32bf0da533b97c1abf3dc317","tests/bindings/test_geometry.rb":"17c2fe8a7b477419a6646983dd88f1b07a0304b58a568c03e9bfa640d5b2df5c","tests/bindings/test_geometry.swift":"a61fec6bfe16020809e20e4da372748c24366767138c5672a0bfff85c4b62d78","tests/test_generated_bindings.rs":"ff8fc093ccb6ee3ee2235c09276c7bb87234ad143667429cb721e46379577f3d"},"package":null}

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

@ -25,15 +25,15 @@ crate-type = [
]
[dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
[dev-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["bindgen-tests"]
[build-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["build"]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"31cb23f36f5c1ac6d2d234a6797e26f5be2c56354da93ed34359604e1e22752c","build.rs":"ba88cce38ecd3321a7a93623755e3339e255360a7f946d3779ded804662c081a","src/lib.rs":"740d70ab5ca22eefcc291a56a9e4ed84e9669f4cfe3890e7d79bc56ae4b991a3","src/rondpoint.udl":"ca4d8720758608b06ffd5f81bfc73881fbd0693a7a5b21bfe61a4557ea052048","tests/bindings/test_rondpoint.kts":"4aac8353278807f4add95c81f4c6c61187204b9767f882fd64872ed8ac1f6451","tests/bindings/test_rondpoint.py":"d618274170af767f8a5614a2565ea698b26ea3e1a222d5c110e7b2d00763e73b","tests/bindings/test_rondpoint.rb":"9cc49df311823d6caedbe7b05ff8c4da6329063c2ce16810192aaaa7edcdf5f5","tests/bindings/test_rondpoint.swift":"fa806e7e09c22ed44496658f6e0781765447bbdd250d7adf4b1152248ed70e69","tests/test_generated_bindings.rs":"5464f89e91c458f164b83a454c6df67a2953873e8a785a4720a2253d843f88e5"},"package":null}
{"files":{"Cargo.toml":"e945bedc4897a588199714e71d6210a77d051925af39b345e605fc58fb782b50","build.rs":"ba88cce38ecd3321a7a93623755e3339e255360a7f946d3779ded804662c081a","src/lib.rs":"740d70ab5ca22eefcc291a56a9e4ed84e9669f4cfe3890e7d79bc56ae4b991a3","src/rondpoint.udl":"c903cb8c95b3ec1b103350857c3c3bc428bfd90c86a6c48089db9e0fc6e41eb5","tests/bindings/test_rondpoint.kts":"4aac8353278807f4add95c81f4c6c61187204b9767f882fd64872ed8ac1f6451","tests/bindings/test_rondpoint.py":"d618274170af767f8a5614a2565ea698b26ea3e1a222d5c110e7b2d00763e73b","tests/bindings/test_rondpoint.rb":"9cc49df311823d6caedbe7b05ff8c4da6329063c2ce16810192aaaa7edcdf5f5","tests/bindings/test_rondpoint.swift":"fa806e7e09c22ed44496658f6e0781765447bbdd250d7adf4b1152248ed70e69","tests/test_generated_bindings.rs":"5464f89e91c458f164b83a454c6df67a2953873e8a785a4720a2253d843f88e5"},"package":null}

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

@ -25,15 +25,15 @@ crate-type = [
]
[dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
[dev-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["bindgen-tests"]
[build-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["build"]

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

@ -2,7 +2,7 @@ namespace rondpoint {
Dictionnaire copie_dictionnaire(Dictionnaire d);
Enumeration copie_enumeration(Enumeration e);
sequence<Enumeration> copie_enumerations(sequence<Enumeration> e);
record<DOMString, EnumerationAvecDonnees> copie_carte(record<DOMString, EnumerationAvecDonnees> c);
record<string, EnumerationAvecDonnees> copie_carte(record<string, EnumerationAvecDonnees> c);
boolean switcheroo(boolean b);
};

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

@ -1 +1 @@
{"files":{"Cargo.toml":"69f1bca53f00d5972b31dfecfd1f8bae745ae96965dc6cb1e5cb7b48b5df68e4","build.rs":"7e9d92d7c8fc17b359a29117b137ffc4d32f6c10b450d03e30a396339d8c9099","src/lib.rs":"d7984c0c10011b1bd939bce71dae7437ebb9090583b5d1b1cc133c2e5f60ab66","src/sprites.udl":"bfd35f04ba0549301189dfb8fc45b0f39bad00956c324f33be0e845fb7ff78aa","tests/bindings/test_sprites.kts":"06ed115325f37ce59ed6f33e2d651cd2aa352fddcc644580f62a6da6ca075844","tests/bindings/test_sprites.py":"2e6ce838cfb387586257703c3500062438e840dd7ae57d185cdc244dc0745b8f","tests/bindings/test_sprites.rb":"6289a1833c7c8f4583ee4f0488d680de2ee46cfb203095a9b66d7234e2f07d53","tests/bindings/test_sprites.swift":"b2c0a6f4d5edfd7de7c2ba77b838865ffda153a6f364f273456175192d3e6e00","tests/test_generated_bindings.rs":"9a22d693c97fc6d90031cc60f61ece1d9279165ad6a92c9fe937448e126e8de6"},"package":null}
{"files":{"Cargo.toml":"e2d06b68b0865f390496bffce512d19d5fc473b64ff23c705daabb4169b8301c","build.rs":"7e9d92d7c8fc17b359a29117b137ffc4d32f6c10b450d03e30a396339d8c9099","src/lib.rs":"d7984c0c10011b1bd939bce71dae7437ebb9090583b5d1b1cc133c2e5f60ab66","src/sprites.udl":"bfd35f04ba0549301189dfb8fc45b0f39bad00956c324f33be0e845fb7ff78aa","tests/bindings/test_sprites.kts":"06ed115325f37ce59ed6f33e2d651cd2aa352fddcc644580f62a6da6ca075844","tests/bindings/test_sprites.py":"2e6ce838cfb387586257703c3500062438e840dd7ae57d185cdc244dc0745b8f","tests/bindings/test_sprites.rb":"6289a1833c7c8f4583ee4f0488d680de2ee46cfb203095a9b66d7234e2f07d53","tests/bindings/test_sprites.swift":"b2c0a6f4d5edfd7de7c2ba77b838865ffda153a6f364f273456175192d3e6e00","tests/test_generated_bindings.rs":"9a22d693c97fc6d90031cc60f61ece1d9279165ad6a92c9fe937448e126e8de6"},"package":null}

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

@ -25,15 +25,15 @@ crate-type = [
]
[dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
[dev-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["bindgen-tests"]
[build-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["build"]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"326454bd365ffa7684f9ca8c1f8199986450df0897bbd62b6049875f62e0ed03","build.rs":"709d073560a66876d2b975f5145a2dc36e1e3420d79328c8b62666526cae5b2d","src/lib.rs":"ccf6851beb2a3e481541dd8a3c3e3d2fbd513a410eef820221942098212a8184","src/todolist.udl":"1f8a24049c2340b9184e95facfc191ecdcb91541729ae7f20b4625d67685f13c","tests/bindings/test_todolist.kts":"f3d29b48e0193563fc4f131d91ea697f758174dcdb80ea554f233949e575bf55","tests/bindings/test_todolist.py":"f7430af9347df0daa954d38bc2203ce400affbb9a53fced4bb67a6796afa0664","tests/bindings/test_todolist.rb":"6524b5271a9cc0e2d78ca9f86ccb6973889926688a0843b4505a4f62d48f6dcb","tests/bindings/test_todolist.swift":"d1911b85fe0c8c0b42e5421b5af5d7359c9a65bba477d23560eb4b0f52e80662","tests/test_generated_bindings.rs":"46ef1fbedaac0c4867812ef2632a641eab36ab0ee12f5757567dd037aeddcbd3"},"package":null}
{"files":{"Cargo.toml":"cb308f7bd5299ed45a3bd516390e21e28d0b02a1913e25917e30e9b8ebe084e3","build.rs":"709d073560a66876d2b975f5145a2dc36e1e3420d79328c8b62666526cae5b2d","src/lib.rs":"ccf6851beb2a3e481541dd8a3c3e3d2fbd513a410eef820221942098212a8184","src/todolist.udl":"1f8a24049c2340b9184e95facfc191ecdcb91541729ae7f20b4625d67685f13c","tests/bindings/test_todolist.kts":"f3d29b48e0193563fc4f131d91ea697f758174dcdb80ea554f233949e575bf55","tests/bindings/test_todolist.py":"f7430af9347df0daa954d38bc2203ce400affbb9a53fced4bb67a6796afa0664","tests/bindings/test_todolist.rb":"6524b5271a9cc0e2d78ca9f86ccb6973889926688a0843b4505a4f62d48f6dcb","tests/bindings/test_todolist.swift":"d1911b85fe0c8c0b42e5421b5af5d7359c9a65bba477d23560eb4b0f52e80662","tests/test_generated_bindings.rs":"46ef1fbedaac0c4867812ef2632a641eab36ab0ee12f5757567dd037aeddcbd3"},"package":null}

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

@ -29,15 +29,15 @@ once_cell = "1.12"
thiserror = "1.0"
[dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
[dev-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["bindgen-tests"]
[build-dependencies.uniffi]
version = "0.24"
version = "0.25"
path = "../../uniffi"
features = ["build"]

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

@ -1 +1 @@
{"files":{"Cargo.toml":"e057e79bc35844251d55557fa1f3dc0fe595816968d41bbeef14176c135d33e1","release.toml":"1aa1b131d4cc93b5eba8758a4401c70bc0d7fe5861e2ec147e9259fe7c0da472","src/cli.rs":"37da575b038e47119cc3183ae7a5ac30e5d0155104f1beec55491aacec02ec52","src/lib.rs":"4295c25a304cb715eda3f6fd0853c09001f713ab8634c823c133b1b85256d2c4","tests/ui/proc_macro_arc.rs":"fedc429603753e8ef953642a7295323ccb3f76fd3ae1ab181ad90c5eb88212bb","tests/ui/proc_macro_arc.stderr":"72db6deb09fb1b473d7c65f17f7c0023947818812ee0da380937cc7fa3ff9311","tests/ui/version_mismatch.rs":"16ea359e5853517ee0d0704c015ae8c825533109fbefd715130d0f4a51f15898","tests/ui/version_mismatch.stderr":"21dcb836253312ba8e3a0502cce6ff279818aaaadcea9628a41b196e0c8c94b6"},"package":"7e835154c561cd75f253008093a908c06fb1f14327afb0ffea88eac72e534cc0"}
{"files":{"Cargo.toml":"5a5cf41b9eb4aac8e312fc9584c0d47585a5a20b13bc7cfb14c9b8813ea596e6","release.toml":"1aa1b131d4cc93b5eba8758a4401c70bc0d7fe5861e2ec147e9259fe7c0da472","src/cli.rs":"0b4791c263d6cf54e4e63dff9a8ead59838d5e7b45fbf5b7f77ab16f602bdb0d","src/lib.rs":"6bc2c11f466fbcd128827a57b5f93a77f716262200f4e5ad2ed8dd75845320fc","tests/ui/proc_macro_arc.rs":"fedc429603753e8ef953642a7295323ccb3f76fd3ae1ab181ad90c5eb88212bb","tests/ui/proc_macro_arc.stderr":"a24af227b907328c9cac6317ec9f43dbc45d7f7c77c603e5d72db7fa050e8b01","tests/ui/version_mismatch.rs":"16ea359e5853517ee0d0704c015ae8c825533109fbefd715130d0f4a51f15898","tests/ui/version_mismatch.stderr":"21dcb836253312ba8e3a0502cce6ff279818aaaadcea9628a41b196e0c8c94b6"},"package":"21345172d31092fd48c47fd56c53d4ae9e41c4b1f559fb8c38c1ab1685fd919f"}

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

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "uniffi"
version = "0.24.3"
version = "0.25.3"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust"
homepage = "https://mozilla.github.io/uniffi-rs"
@ -41,18 +41,18 @@ features = [
optional = true
[dependencies.uniffi_bindgen]
version = "=0.24.3"
version = "=0.25.3"
optional = true
[dependencies.uniffi_build]
version = "=0.24.3"
version = "=0.25.3"
optional = true
[dependencies.uniffi_core]
version = "=0.24.3"
version = "=0.25.3"
[dependencies.uniffi_macros]
version = "=0.24.3"
version = "=0.25.3"
[dev-dependencies.trybuild]
version = "1"

16
third_party/rust/uniffi/src/cli.rs поставляемый
Просмотреть файл

@ -47,7 +47,9 @@ enum Commands {
#[clap(long = "library")]
library_mode: bool,
/// When `--library` is passed, only generate bindings for one crate
/// When `--library` is passed, only generate bindings for one crate.
/// When `--library` is not passed, use this as the crate name instead of attempting to
/// locate and parse Cargo.toml.
#[clap(long = "crate")]
crate_name: Option<String>,
@ -69,8 +71,8 @@ enum Commands {
udl_file: Utf8PathBuf,
},
/// Print the JSON representation of the interface from a dynamic library
PrintJson {
/// Print a debug representation of the interface from a dynamic library
PrintRepr {
/// Path to the library file (.so, .dll, .dylib, or .a)
path: Utf8PathBuf,
},
@ -104,15 +106,13 @@ pub fn run_main() -> anyhow::Result<()> {
&source, crate_name, &language, &out_dir, !no_format,
)?;
} else {
if crate_name.is_some() {
panic!("--crate requires --library.")
}
uniffi_bindgen::generate_bindings(
&source,
config.as_deref(),
language,
out_dir.as_deref(),
lib_file.as_deref(),
crate_name.as_deref(),
!no_format,
)?;
}
@ -128,8 +128,8 @@ pub fn run_main() -> anyhow::Result<()> {
!no_format,
)?;
}
Commands::PrintJson { path } => {
uniffi_bindgen::print_json(&path)?;
Commands::PrintRepr { path } => {
uniffi_bindgen::print_repr(&path)?;
}
};
Ok(())

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

@ -17,13 +17,19 @@ pub use uniffi_bindgen::bindings::ruby::run_test as ruby_run_test;
pub use uniffi_bindgen::bindings::swift::run_test as swift_run_test;
#[cfg(feature = "bindgen")]
pub use uniffi_bindgen::{
bindings::TargetLanguage, generate_bindings, generate_component_scaffolding, print_json,
bindings::TargetLanguage, generate_bindings, generate_component_scaffolding,
generate_component_scaffolding_for_crate, print_repr,
};
#[cfg(feature = "build")]
pub use uniffi_build::generate_scaffolding;
pub use uniffi_build::{generate_scaffolding, generate_scaffolding_for_crate};
#[cfg(feature = "bindgen-tests")]
pub use uniffi_macros::build_foreign_language_testcases;
#[cfg(feature = "cli")]
pub fn uniffi_bindgen_main() {
cli::run_main().unwrap();
}
#[cfg(test)]
mod test {
#[test]
@ -32,8 +38,3 @@ mod test {
t.compile_fail("tests/ui/*.rs");
}
}
#[cfg(feature = "cli")]
pub fn uniffi_bindgen_main() {
cli::run_main().unwrap();
}

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

@ -1,35 +1,22 @@
error[E0277]: the trait bound `Foo: Interface<UniFfiTag>` is not satisfied
error[E0277]: the trait bound `Foo: FfiConverterArc<UniFfiTag>` is not satisfied
--> tests/ui/proc_macro_arc.rs:10:1
|
10 | #[uniffi::export]
| ^^^^^^^^^^^^^^^^^ the trait `Interface<UniFfiTag>` is not implemented for `Foo`
| ^^^^^^^^^^^^^^^^^ the trait `FfiConverterArc<UniFfiTag>` is not implemented for `Foo`
|
= help: the trait `FfiConverter<UT>` is implemented for `Arc<T>`
= help: the trait `LowerReturn<UT>` is implemented for `Arc<T>`
= note: required for `Arc<Foo>` to implement `FfiConverter<UniFfiTag>`
= note: required for `Arc<Foo>` to implement `Lower<UniFfiTag>`
= note: required for `Arc<Foo>` to implement `LowerReturn<UniFfiTag>`
= note: this error originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info)
note: erroneous constant used
--> tests/ui/proc_macro_arc.rs:10:1
|
10 | #[uniffi::export]
| ^^^^^^^^^^^^^^^^^
|
= note: this note originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `child::Foo: Interface<UniFfiTag>` is not satisfied
error[E0277]: the trait bound `child::Foo: FfiConverterArc<UniFfiTag>` is not satisfied
--> tests/ui/proc_macro_arc.rs:20:5
|
20 | #[uniffi::export]
| ^^^^^^^^^^^^^^^^^ the trait `Interface<UniFfiTag>` is not implemented for `child::Foo`
| ^^^^^^^^^^^^^^^^^ the trait `FfiConverterArc<UniFfiTag>` is not implemented for `child::Foo`
|
= help: the trait `FfiConverter<UT>` is implemented for `Arc<T>`
= help: the trait `Lift<UT>` is implemented for `Arc<T>`
= note: required for `Arc<child::Foo>` to implement `FfiConverter<UniFfiTag>`
= note: required for `Arc<child::Foo>` to implement `Lift<UniFfiTag>`
= note: this error originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info)
note: erroneous constant used
--> tests/ui/proc_macro_arc.rs:20:5
|
20 | #[uniffi::export]
| ^^^^^^^^^^^^^^^^^
|
= note: this note originates in the attribute macro `uniffi::export` (in Nightly builds, run with -Z macro-backtrace for more info)

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

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

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "uniffi_bindgen"
version = "0.24.3"
version = "0.25.3"
authors = ["Firefox Sync Team <sync-team@mozilla.com>"]
description = "a multi-language bindings generator for rust (codegen and cli tooling)"
homepage = "https://mozilla.github.io/uniffi-rs"
@ -68,17 +68,14 @@ version = "1.0"
[dependencies.serde]
version = "1"
[dependencies.serde_json]
version = "1.0.80"
[dependencies.toml]
version = "0.5"
[dependencies.uniffi_meta]
version = "=0.24.3"
version = "=0.25.3"
[dependencies.uniffi_testing]
version = "=0.24.3"
version = "=0.25.3"
[dependencies.weedle2]
version = "4.0.0"
[dependencies.uniffi_udl]
version = "=0.25.3"

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

@ -4,7 +4,9 @@
//! Backend-agnostic askama filters
use crate::interface::{CallbackInterface, ComponentInterface, Enum, Function, Object, Record};
use crate::interface::{
AsType, CallbackInterface, ComponentInterface, Enum, FfiType, Function, Object, Record,
};
use askama::Result;
use std::fmt;
@ -67,3 +69,8 @@ pub fn get_callback_interface_definition<'a>(
ci.get_callback_interface_definition(name)
.ok_or_else(|| lookup_error!("callback interface {name} not found"))
}
/// Get the FfiType for a Type
pub fn ffi_type(type_: &impl AsType) -> Result<FfiType, askama::Error> {
Ok(type_.as_type().into())
}

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

@ -10,6 +10,10 @@
use super::Literal;
use std::fmt::Debug;
// XXX - Note that this trait is not used internally. It exists just to avoid an unnecessary
// breaking change for external bindings which use this trait.
// It is likely to be removed some time after 0.26.x.
/// A Trait to help render types in a language specific format.
pub trait CodeType: Debug {
/// The language specific label used to reference this type. This will be used in

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

@ -2,7 +2,8 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct CallbackInterfaceCodeType {
@ -16,18 +17,14 @@ impl CallbackInterfaceCodeType {
}
impl CodeType for CallbackInterfaceCodeType {
fn type_label(&self) -> String {
super::KotlinCodeOracle.class_name(&self.id)
fn type_label(&self, ci: &ComponentInterface) -> String {
super::KotlinCodeOracle.class_name(ci, &self.id)
}
fn canonical_name(&self) -> String {
format!("Type{}", self.id)
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!();
}
fn initialization_fn(&self) -> Option<String> {
Some(format!("{}.register", self.ffi_converter_name()))
}

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

@ -2,17 +2,19 @@
* 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/. */
use crate::backend::{CodeType, Literal, Type};
use super::{AsCodeType, CodeType};
use crate::backend::{Literal, Type};
use crate::ComponentInterface;
use paste::paste;
fn render_literal(literal: &Literal, inner: &Type) -> String {
fn render_literal(literal: &Literal, inner: &Type, ci: &ComponentInterface) -> String {
match literal {
Literal::Null => "null".into(),
Literal::EmptySequence => "listOf()".into(),
Literal::EmptyMap => "mapOf()".into(),
// For optionals
_ => super::KotlinCodeOracle.find(inner).literal(literal),
_ => super::KotlinCodeOracle.find(inner).literal(literal, ci),
}
}
@ -34,16 +36,16 @@ macro_rules! impl_code_type_for_compound {
}
impl CodeType for $T {
fn type_label(&self) -> String {
format!($type_label_pattern, super::KotlinCodeOracle.find(self.inner()).type_label())
fn type_label(&self, ci: &ComponentInterface) -> String {
format!($type_label_pattern, super::KotlinCodeOracle.find(self.inner()).type_label(ci))
}
fn canonical_name(&self) -> String {
format!($canonical_name_pattern, super::KotlinCodeOracle.find(self.inner()).canonical_name())
}
fn literal(&self, literal: &Literal) -> String {
render_literal(literal, self.inner())
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String {
render_literal(literal, self.inner(), ci)
}
}
}
@ -74,23 +76,23 @@ impl MapCodeType {
}
impl CodeType for MapCodeType {
fn type_label(&self) -> String {
fn type_label(&self, ci: &ComponentInterface) -> String {
format!(
"Map<{}, {}>",
super::KotlinCodeOracle.find(self.key()).type_label(),
super::KotlinCodeOracle.find(self.value()).type_label(),
super::KotlinCodeOracle.find(self.key()).type_label(ci),
super::KotlinCodeOracle.find(self.value()).type_label(ci),
)
}
fn canonical_name(&self) -> String {
format!(
"Map{}{}",
super::KotlinCodeOracle.find(self.key()).canonical_name(),
super::KotlinCodeOracle.find(self.value()).canonical_name(),
self.key().as_codetype().canonical_name(),
self.value().as_codetype().canonical_name(),
)
}
fn literal(&self, literal: &Literal) -> String {
render_literal(literal, &self.value)
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String {
render_literal(literal, &self.value, ci)
}
}

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

@ -2,7 +2,8 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct CustomCodeType {
@ -16,15 +17,11 @@ impl CustomCodeType {
}
impl CodeType for CustomCodeType {
fn type_label(&self) -> String {
fn type_label(&self, _ci: &ComponentInterface) -> String {
self.name.clone()
}
fn canonical_name(&self) -> String {
format!("Type{}", self.name)
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!("Can't have a literal of a custom type");
}
}

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

@ -2,7 +2,9 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::backend::Literal;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct EnumCodeType {
@ -16,19 +18,19 @@ impl EnumCodeType {
}
impl CodeType for EnumCodeType {
fn type_label(&self) -> String {
super::KotlinCodeOracle.class_name(&self.id)
fn type_label(&self, ci: &ComponentInterface) -> String {
super::KotlinCodeOracle.class_name(ci, &self.id)
}
fn canonical_name(&self) -> String {
format!("Type{}", self.id)
}
fn literal(&self, literal: &Literal) -> String {
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String {
if let Literal::Enum(v, _) = literal {
format!(
"{}.{}",
self.type_label(),
self.type_label(ci),
super::KotlinCodeOracle.enum_variant_name(v)
)
} else {

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

@ -1,31 +0,0 @@
/* 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/. */
use crate::backend::{CodeType, Literal};
// When a type is used as an error it gets a special CodeType.
#[derive(Debug)]
pub struct ErrorCodeType {
id: String,
}
impl ErrorCodeType {
pub fn new(id: String) -> Self {
Self { id }
}
}
impl CodeType for ErrorCodeType {
fn type_label(&self) -> String {
super::KotlinCodeOracle.error_name(&self.id)
}
fn canonical_name(&self) -> String {
format!("Type{}", self.id)
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!();
}
}

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

@ -2,13 +2,14 @@
* 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/. */
use crate::backend::CodeType;
use super::CodeType;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct ForeignExecutorCodeType;
impl CodeType for ForeignExecutorCodeType {
fn type_label(&self) -> String {
fn type_label(&self, _ci: &ComponentInterface) -> String {
// Kotlin uses a CoroutineScope for ForeignExecutor
"CoroutineScope".into()
}

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

@ -2,7 +2,8 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct ExternalCodeType {
@ -16,15 +17,11 @@ impl ExternalCodeType {
}
impl CodeType for ExternalCodeType {
fn type_label(&self) -> String {
fn type_label(&self, _ci: &ComponentInterface) -> String {
self.name.clone()
}
fn canonical_name(&self) -> String {
format!("Type{}", self.name)
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!("Can't have a literal of an external type");
}
}

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

@ -2,7 +2,8 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::ComponentInterface;
use paste::paste;
macro_rules! impl_code_type_for_miscellany {
@ -12,17 +13,13 @@ macro_rules! impl_code_type_for_miscellany {
pub struct $T;
impl CodeType for $T {
fn type_label(&self) -> String {
fn type_label(&self, _ci: &ComponentInterface) -> String {
$class_name.into()
}
fn canonical_name(&self) -> String {
$canonical_name.into()
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!()
}
}
}
};

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

@ -5,13 +5,14 @@
use std::borrow::Borrow;
use std::cell::RefCell;
use std::collections::{BTreeSet, HashMap, HashSet};
use std::fmt::Debug;
use anyhow::{Context, Result};
use askama::Template;
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToUpperCamelCase};
use serde::{Deserialize, Serialize};
use crate::backend::{CodeType, TemplateExpression};
use crate::backend::TemplateExpression;
use crate::interface::*;
use crate::BindingsConfig;
@ -19,7 +20,6 @@ mod callback_interface;
mod compounds;
mod custom;
mod enum_;
mod error;
mod executor;
mod external;
mod miscellany;
@ -28,6 +28,46 @@ mod primitives;
mod record;
mod variant;
trait CodeType: Debug {
/// The language specific label used to reference this type. This will be used in
/// method signatures and property declarations.
fn type_label(&self, ci: &ComponentInterface) -> String;
/// A representation of this type label that can be used as part of another
/// identifier. e.g. `read_foo()`, or `FooInternals`.
///
/// This is especially useful when creating specialized objects or methods to deal
/// with this type only.
fn canonical_name(&self) -> String;
fn literal(&self, _literal: &Literal, ci: &ComponentInterface) -> String {
unimplemented!("Unimplemented for {}", self.type_label(ci))
}
/// Name of the FfiConverter
///
/// This is the object that contains the lower, write, lift, and read methods for this type.
/// Depending on the binding this will either be a singleton or a class with static methods.
///
/// This is the newer way of handling these methods and replaces the lower, write, lift, and
/// read CodeType methods. Currently only used by Kotlin, but the plan is to move other
/// backends to using this.
fn ffi_converter_name(&self) -> String {
format!("FfiConverter{}", self.canonical_name())
}
/// A list of imports that are needed if this type is in use.
/// Classes are imported exactly once.
fn imports(&self) -> Option<Vec<String>> {
None
}
/// Function to run at startup
fn initialization_fn(&self) -> Option<String> {
None
}
}
// config options to customize the generated Kotlin.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Config {
@ -66,8 +106,6 @@ impl Config {
}
impl BindingsConfig for Config {
const TOML_KEY: &'static str = "kotlin";
fn update_from_ci(&mut self, ci: &ComponentInterface) {
self.package_name
.get_or_insert_with(|| format!("uniffi.{}", ci.namespace()));
@ -125,7 +163,7 @@ impl ImportRequirement {
#[derive(Template)]
#[template(syntax = "kt", escape = "none", path = "Types.kt")]
pub struct TypeRenderer<'a> {
kotlin_config: &'a Config,
config: &'a Config,
ci: &'a ComponentInterface,
// Track included modules for the `include_once()` macro
include_once_names: RefCell<HashSet<String>>,
@ -134,9 +172,9 @@ pub struct TypeRenderer<'a> {
}
impl<'a> TypeRenderer<'a> {
fn new(kotlin_config: &'a Config, ci: &'a ComponentInterface) -> Self {
fn new(config: &'a Config, ci: &'a ComponentInterface) -> Self {
Self {
kotlin_config,
config,
ci,
include_once_names: RefCell::new(HashSet::new()),
imports: RefCell::new(BTreeSet::new()),
@ -144,10 +182,13 @@ impl<'a> TypeRenderer<'a> {
}
// Get the package name for an external type
fn external_type_package_name(&self, crate_name: &str) -> String {
match self.kotlin_config.external_packages.get(crate_name) {
fn external_type_package_name(&self, module_path: &str, namespace: &str) -> String {
// config overrides are keyed by the crate name, default fallback is the namespace.
let crate_name = module_path.split("::").next().unwrap();
match self.config.external_packages.get(crate_name) {
Some(name) => name.clone(),
None => crate_name.to_string(),
// unreachable in library mode - all deps are in our config with correct namespace.
None => format!("uniffi.{namespace}"),
}
}
@ -195,6 +236,7 @@ pub struct KotlinWrapper<'a> {
ci: &'a ComponentInterface,
type_helper_code: String,
type_imports: BTreeSet<ImportRequirement>,
has_async_fns: bool,
}
impl<'a> KotlinWrapper<'a> {
@ -207,6 +249,7 @@ impl<'a> KotlinWrapper<'a> {
ci,
type_helper_code,
type_imports,
has_async_fns: ci.has_async_fns(),
}
}
@ -215,6 +258,10 @@ impl<'a> KotlinWrapper<'a> {
.iter_types()
.map(|t| KotlinCodeOracle.find(t))
.filter_map(|ct| ct.initialization_fn())
.chain(
self.has_async_fns
.then(|| "uniffiRustFutureContinuationCallback.register".into()),
)
.collect()
}
@ -231,17 +278,20 @@ impl KotlinCodeOracle {
type_.clone().as_type().as_codetype()
}
fn find_as_error(&self, type_: &Type) -> Box<dyn CodeType> {
match type_ {
Type::Enum(id) => Box::new(error::ErrorCodeType::new(id.clone())),
// XXX - not sure how we are supposed to return askama::Error?
_ => panic!("unsupported type for error: {type_:?}"),
}
/// Get the idiomatic Kotlin rendering of a class name (for enums, records, errors, etc).
fn class_name(&self, ci: &ComponentInterface, nm: &str) -> String {
let name = nm.to_string().to_upper_camel_case();
// fixup errors.
ci.is_name_used_as_error(nm)
.then(|| self.convert_error_suffix(&name))
.unwrap_or(name)
}
/// Get the idiomatic Kotlin rendering of a class name (for enums, records, errors, etc).
fn class_name(&self, nm: &str) -> String {
nm.to_string().to_upper_camel_case()
fn convert_error_suffix(&self, nm: &str) -> String {
match nm.strip_suffix("Error") {
None => nm.to_string(),
Some(stripped) => format!("{stripped}Exception"),
}
}
/// Get the idiomatic Kotlin rendering of a function name.
@ -259,20 +309,6 @@ impl KotlinCodeOracle {
nm.to_string().to_shouty_snake_case()
}
/// Get the idiomatic Kotlin rendering of an exception name
///
/// This replaces "Error" at the end of the name with "Exception". Rust code typically uses
/// "Error" for any type of error but in the Java world, "Error" means a non-recoverable error
/// and is distinguished from an "Exception".
fn error_name(&self, nm: &str) -> String {
// errors are a class in kotlin.
let name = self.class_name(nm);
match name.strip_suffix("Error") {
None => name,
Some(stripped) => format!("{stripped}Exception"),
}
}
fn ffi_type_label_by_value(ffi_type: &FfiType) -> String {
match ffi_type {
FfiType::RustBuffer(_) => format!("{}.ByValue", Self::ffi_type_label(ffi_type)),
@ -299,15 +335,16 @@ impl KotlinCodeOracle {
FfiType::ForeignCallback => "ForeignCallback".to_string(),
FfiType::ForeignExecutorHandle => "USize".to_string(),
FfiType::ForeignExecutorCallback => "UniFfiForeignExecutorCallback".to_string(),
FfiType::FutureCallback { return_type } => {
format!("UniFfiFutureCallback{}", Self::ffi_type_label(return_type))
FfiType::RustFutureHandle => "Pointer".to_string(),
FfiType::RustFutureContinuationCallback => {
"UniFffiRustFutureContinuationCallbackType".to_string()
}
FfiType::FutureCallbackData => "USize".to_string(),
FfiType::RustFutureContinuationData => "USize".to_string(),
}
}
}
pub trait AsCodeType {
trait AsCodeType {
fn as_codetype(&self) -> Box<dyn CodeType>;
}
@ -338,128 +375,89 @@ impl<T: AsType> AsCodeType for T {
Type::Timestamp => Box::new(miscellany::TimestampCodeType),
Type::Duration => Box::new(miscellany::DurationCodeType),
Type::Enum(id) => Box::new(enum_::EnumCodeType::new(id)),
Type::Enum { name, .. } => Box::new(enum_::EnumCodeType::new(name)),
Type::Object { name, .. } => Box::new(object::ObjectCodeType::new(name)),
Type::Record(id) => Box::new(record::RecordCodeType::new(id)),
Type::CallbackInterface(id) => {
Box::new(callback_interface::CallbackInterfaceCodeType::new(id))
Type::Record { name, .. } => Box::new(record::RecordCodeType::new(name)),
Type::CallbackInterface { name, .. } => {
Box::new(callback_interface::CallbackInterfaceCodeType::new(name))
}
Type::ForeignExecutor => Box::new(executor::ForeignExecutorCodeType),
Type::Optional(inner) => Box::new(compounds::OptionalCodeType::new(*inner)),
Type::Sequence(inner) => Box::new(compounds::SequenceCodeType::new(*inner)),
Type::Map(key, value) => Box::new(compounds::MapCodeType::new(*key, *value)),
Type::Optional { inner_type } => {
Box::new(compounds::OptionalCodeType::new(*inner_type))
}
Type::Sequence { inner_type } => {
Box::new(compounds::SequenceCodeType::new(*inner_type))
}
Type::Map {
key_type,
value_type,
} => Box::new(compounds::MapCodeType::new(*key_type, *value_type)),
Type::External { name, .. } => Box::new(external::ExternalCodeType::new(name)),
Type::Custom { name, .. } => Box::new(custom::CustomCodeType::new(name)),
}
}
}
pub mod filters {
mod filters {
use super::*;
pub use crate::backend::filters::*;
pub fn type_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().type_label())
pub(super) fn type_name(
as_ct: &impl AsCodeType,
ci: &ComponentInterface,
) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().type_label(ci))
}
pub fn canonical_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn canonical_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().canonical_name())
}
pub fn ffi_converter_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn ffi_converter_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().ffi_converter_name())
}
pub fn lower_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn lower_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!(
"{}.lower",
as_ct.as_codetype().ffi_converter_name()
))
}
pub fn allocation_size_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn allocation_size_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!(
"{}.allocationSize",
as_ct.as_codetype().ffi_converter_name()
))
}
pub fn write_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn write_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!(
"{}.write",
as_ct.as_codetype().ffi_converter_name()
))
}
pub fn lift_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn lift_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!("{}.lift", as_ct.as_codetype().ffi_converter_name()))
}
pub fn read_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub(super) fn read_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!("{}.read", as_ct.as_codetype().ffi_converter_name()))
}
pub fn error_handler(result_type: &ResultType) -> Result<String, askama::Error> {
match &result_type.throws_type {
Some(error_type) => Ok(KotlinCodeOracle.error_name(&type_name(error_type)?)),
None => Ok("NullCallStatusErrorHandler".into()),
}
}
pub fn future_callback_handler(result_type: &ResultType) -> Result<String, askama::Error> {
let return_component = match &result_type.return_type {
Some(return_type) => KotlinCodeOracle.find(return_type).canonical_name(),
None => "Void".into(),
};
let throws_component = match &result_type.throws_type {
Some(throws_type) => {
format!("_{}", KotlinCodeOracle.find(throws_type).canonical_name())
}
None => "".into(),
};
Ok(format!(
"UniFfiFutureCallbackHandler{return_component}{throws_component}"
))
}
pub fn future_continuation_type(result_type: &ResultType) -> Result<String, askama::Error> {
let return_type_name = match &result_type.return_type {
Some(t) => type_name(t)?,
None => "Unit".into(),
};
Ok(format!("Continuation<{return_type_name}>"))
}
pub fn render_literal(
literal: &Literal,
as_ct: &impl AsCodeType,
as_ct: &impl AsType,
ci: &ComponentInterface,
) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().literal(literal))
}
/// Get the Kotlin syntax for representing a given low-level `FfiType`.
pub fn ffi_type_name(type_: &FfiType) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle::ffi_type_label(type_))
Ok(as_ct.as_codetype().literal(literal, ci))
}
pub fn ffi_type_name_by_value(type_: &FfiType) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle::ffi_type_label_by_value(type_))
}
// Some FfiTypes have the same ffi_type_label - this makes a vec of them unique.
pub fn unique_ffi_types(
types: impl Iterator<Item = FfiType>,
) -> Result<impl Iterator<Item = FfiType>, askama::Error> {
let mut seen = HashSet::new();
let mut result = Vec::new();
for t in types {
if seen.insert(KotlinCodeOracle::ffi_type_label(&t)) {
result.push(t)
}
}
Ok(result.into_iter())
}
/// Get the idiomatic Kotlin rendering of a function name.
pub fn fn_name(nm: &str) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle.fn_name(nm))
@ -470,39 +468,55 @@ pub mod filters {
Ok(KotlinCodeOracle.var_name(nm))
}
/// Get a String representing the name used for an individual enum variant.
pub fn variant_name(v: &Variant) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle.enum_variant_name(v.name()))
}
/// Get a codetype for idiomatic Kotlin rendering of an individual enum variant.
pub fn enum_variant(v: &Variant) -> Result<impl AsCodeType, askama::Error> {
Ok(v.clone())
pub fn error_variant_name(v: &Variant) -> Result<String, askama::Error> {
let name = v.name().to_string().to_upper_camel_case();
Ok(KotlinCodeOracle.convert_error_suffix(&name))
}
/// Get a codetype for idiomatic Kotlin rendering of an individual enum variant
/// when used in an error.
pub fn error_variant(v: &Variant) -> Result<impl AsCodeType, askama::Error> {
Ok(variant::ErrorVariantCodeTypeProvider { v: v.clone() })
pub fn async_poll(
callable: impl Callable,
ci: &ComponentInterface,
) -> Result<String, askama::Error> {
let ffi_func = callable.ffi_rust_future_poll(ci);
Ok(format!(
"{{ future, continuation -> _UniFFILib.INSTANCE.{ffi_func}(future, continuation) }}"
))
}
/// Some of the above filters have different versions to help when the type
/// is used as an error.
pub fn error_type_name(as_type: &impl AsType) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle
.find_as_error(&as_type.as_type())
.type_label())
pub fn async_complete(
callable: impl Callable,
ci: &ComponentInterface,
) -> Result<String, askama::Error> {
let ffi_func = callable.ffi_rust_future_complete(ci);
let call = format!("_UniFFILib.INSTANCE.{ffi_func}(future, continuation)");
let call = match callable.return_type() {
Some(Type::External {
kind: ExternalKind::DataClass,
name,
..
}) => {
// Need to convert the RustBuffer from our package to the RustBuffer of the external package
let suffix = KotlinCodeOracle.class_name(ci, &name);
format!("{call}.let {{ RustBuffer{suffix}.create(it.capacity, it.len, it.data) }}")
}
_ => call,
};
Ok(format!("{{ future, continuation -> {call} }}"))
}
pub fn error_canonical_name(as_type: &impl AsType) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle
.find_as_error(&as_type.as_type())
.canonical_name())
}
pub fn error_ffi_converter_name(as_type: &impl AsType) -> Result<String, askama::Error> {
Ok(KotlinCodeOracle
.find_as_error(&as_type.as_type())
.ffi_converter_name())
pub fn async_free(
callable: impl Callable,
ci: &ComponentInterface,
) -> Result<String, askama::Error> {
let ffi_func = callable.ffi_rust_future_free(ci);
Ok(format!(
"{{ future -> _UniFFILib.INSTANCE.{ffi_func}(future) }}"
))
}
/// Remove the "`" chars we put around function/variable names

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

@ -2,7 +2,8 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct ObjectCodeType {
@ -16,15 +17,11 @@ impl ObjectCodeType {
}
impl CodeType for ObjectCodeType {
fn type_label(&self) -> String {
super::KotlinCodeOracle.class_name(&self.id)
fn type_label(&self, ci: &ComponentInterface) -> String {
super::KotlinCodeOracle.class_name(ci, &self.id)
}
fn canonical_name(&self) -> String {
format!("Type{}", self.id)
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!();
}
}

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

@ -2,11 +2,12 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use crate::interface::{types::Type, Radix};
use super::CodeType;
use crate::backend::Literal;
use crate::interface::{ComponentInterface, Radix, Type};
use paste::paste;
fn render_literal(literal: &Literal) -> String {
fn render_literal(literal: &Literal, _ci: &ComponentInterface) -> String {
fn typed_number(type_: &Type, num_str: String) -> String {
match type_ {
// Bytes, Shorts and Ints can all be inferred from the type.
@ -54,12 +55,16 @@ macro_rules! impl_code_type_for_primitive {
pub struct $T;
impl CodeType for $T {
fn type_label(&self) -> String {
fn type_label(&self, _ci: &ComponentInterface) -> String {
$class_name.into()
}
fn literal(&self, literal: &Literal) -> String {
render_literal(&literal)
fn canonical_name(&self) -> String {
$class_name.into()
}
fn literal(&self, literal: &Literal, ci: &ComponentInterface) -> String {
render_literal(&literal, ci)
}
}
}

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

@ -2,7 +2,8 @@
* 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/. */
use crate::backend::{CodeType, Literal};
use super::CodeType;
use crate::ComponentInterface;
#[derive(Debug)]
pub struct RecordCodeType {
@ -16,15 +17,11 @@ impl RecordCodeType {
}
impl CodeType for RecordCodeType {
fn type_label(&self) -> String {
super::KotlinCodeOracle.class_name(&self.id)
fn type_label(&self, ci: &ComponentInterface) -> String {
super::KotlinCodeOracle.class_name(ci, &self.id)
}
fn canonical_name(&self) -> String {
format!("Type{}", self.id)
}
fn literal(&self, _literal: &Literal) -> String {
unreachable!();
}
}

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

@ -2,9 +2,8 @@
* 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/. */
use super::{AsCodeType, KotlinCodeOracle};
use crate::backend::CodeType;
use crate::interface::Variant;
use super::{AsCodeType, CodeType, KotlinCodeOracle};
use crate::interface::{ComponentInterface, Variant};
#[derive(Debug)]
pub(super) struct VariantCodeType {
@ -12,8 +11,12 @@ pub(super) struct VariantCodeType {
}
impl CodeType for VariantCodeType {
fn type_label(&self) -> String {
KotlinCodeOracle.class_name(self.v.name())
fn type_label(&self, ci: &ComponentInterface) -> String {
KotlinCodeOracle.class_name(ci, self.v.name())
}
fn canonical_name(&self) -> String {
self.v.name().to_string()
}
}
@ -23,23 +26,8 @@ impl AsCodeType for Variant {
}
}
#[derive(Debug)]
pub(super) struct ErrorVariantCodeType {
pub v: Variant,
}
impl CodeType for ErrorVariantCodeType {
fn type_label(&self) -> String {
KotlinCodeOracle.error_name(self.v.name())
}
}
pub(super) struct ErrorVariantCodeTypeProvider {
pub v: Variant,
}
impl AsCodeType for ErrorVariantCodeTypeProvider {
impl AsCodeType for &Variant {
fn as_codetype(&self) -> Box<dyn CodeType> {
Box::new(ErrorVariantCodeType { v: self.v.clone() })
Box::new(VariantCodeType { v: (*self).clone() })
}
}

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

@ -0,0 +1,44 @@
// Async return type handlers
internal const val UNIFFI_RUST_FUTURE_POLL_READY = 0.toShort()
internal const val UNIFFI_RUST_FUTURE_POLL_MAYBE_READY = 1.toShort()
internal val uniffiContinuationHandleMap = UniFfiHandleMap<CancellableContinuation<Short>>()
// FFI type for Rust future continuations
internal object uniffiRustFutureContinuationCallback: UniFffiRustFutureContinuationCallbackType {
override fun callback(continuationHandle: USize, pollResult: Short) {
uniffiContinuationHandleMap.remove(continuationHandle)?.resume(pollResult)
}
internal fun register(lib: _UniFFILib) {
lib.{{ ci.ffi_rust_future_continuation_callback_set().name() }}(this)
}
}
internal suspend fun<T, F, E: Exception> uniffiRustCallAsync(
rustFuture: Pointer,
pollFunc: (Pointer, USize) -> Unit,
completeFunc: (Pointer, RustCallStatus) -> F,
freeFunc: (Pointer) -> Unit,
liftFunc: (F) -> T,
errorHandler: CallStatusErrorHandler<E>
): T {
try {
do {
val pollResult = suspendCancellableCoroutine<Short> { continuation ->
pollFunc(
rustFuture,
uniffiContinuationHandleMap.insert(continuation)
)
}
} while (pollResult != UNIFFI_RUST_FUTURE_POLL_READY);
return liftFunc(
rustCallWithError(errorHandler, { status -> completeFunc(rustFuture, status) })
)
} finally {
freeFunc(rustFuture)
}
}

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

@ -1,43 +0,0 @@
// Async return type handlers
{# add imports that we use #}
{{ self.add_import("kotlin.coroutines.Continuation") }}
{{ self.add_import("kotlin.coroutines.resume") }}
{{ self.add_import("kotlin.coroutines.resumeWithException") }}
{# We use these in the generated functions, which don't have access to add_import() -- might as well add it here #}
{{ self.add_import("kotlin.coroutines.suspendCoroutine") }}
{{ self.add_import("kotlinx.coroutines.coroutineScope") }}
// FFI type for callback handlers
{%- for callback_param in ci.iter_future_callback_params()|unique_ffi_types %}
internal interface UniFfiFutureCallback{{ callback_param|ffi_type_name }} : com.sun.jna.Callback {
// Note: callbackData is always 0. We could pass Rust a pointer/usize to represent the
// continuation, but with JNA it's easier to just store it in the callback handler.
fun invoke(_callbackData: USize, returnValue: {{ callback_param|ffi_type_name_by_value }}?, callStatus: RustCallStatus.ByValue);
}
{%- endfor %}
// Callback handlers for an async call. These are invoked by Rust when the future is ready. They
// lift the return value or error and resume the suspended function.
{%- for result_type in ci.iter_async_result_types() %}
{%- let callback_param = result_type.future_callback_param() %}
internal class {{ result_type|future_callback_handler }}(val continuation: {{ result_type|future_continuation_type }})
: UniFfiFutureCallback{{ callback_param|ffi_type_name }} {
override fun invoke(_callbackData: USize, returnValue: {{ callback_param|ffi_type_name_by_value }}?, callStatus: RustCallStatus.ByValue) {
try {
checkCallStatus({{ result_type|error_handler }}, callStatus)
{%- match result_type.return_type %}
{%- when Some(return_type) %}
continuation.resume({{ return_type|lift_fn }}(returnValue!!))
{%- when None %}
continuation.resume(Unit)
{%- endmatch %}
} catch (e: Throwable) {
continuation.resumeWithException(e)
}
}
}
{%- endfor %}

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

@ -35,7 +35,7 @@ internal class ConcurrentHandleMap<T>(
}
interface ForeignCallback : com.sun.jna.Callback {
public fun invoke(handle: Handle, method: Int, argsData: Pointer, argsLen: Int, outBuf: RustBufferByReference): Int
public fun callback(handle: Handle, method: Int, argsData: Pointer, argsLen: Int, outBuf: RustBufferByReference): Int
}
// Magic number for the Rust proxy to call using the same mechanism as every other method,

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

@ -1,5 +1,5 @@
{%- let cbi = ci|get_callback_interface_definition(name) %}
{%- let type_name = cbi|type_name %}
{%- let type_name = cbi|type_name(ci) %}
{%- let foreign_callback = format!("ForeignCallback{}", canonical_type_name) %}
{% if self.include_once_check("CallbackInterfaceRuntime.kt") %}{% include "CallbackInterfaceRuntime.kt" %}{% endif %}
@ -13,16 +13,17 @@ public interface {{ type_name }} {
{% for meth in cbi.methods() -%}
fun {{ meth.name()|fn_name }}({% call kt::arg_list_decl(meth) %})
{%- match meth.return_type() -%}
{%- when Some with (return_type) %}: {{ return_type|type_name -}}
{%- when Some with (return_type) %}: {{ return_type|type_name(ci) -}}
{%- else -%}
{%- endmatch %}
{% endfor %}
companion object
}
// The ForeignCallback that is passed to Rust.
internal class {{ foreign_callback }} : ForeignCallback {
@Suppress("TooGenericExceptionCaught")
override fun invoke(handle: Handle, method: Int, argsData: Pointer, argsLen: Int, outBuf: RustBufferByReference): Int {
override fun callback(handle: Handle, method: Int, argsData: Pointer, argsLen: Int, outBuf: RustBufferByReference): Int {
val cb = {{ ffi_converter_name }}.lift(handle)
return when (method) {
IDX_CALLBACK_FREE -> {
@ -104,7 +105,7 @@ internal class {{ foreign_callback }} : ForeignCallback {
{%- when Some(error_type) %}
fun makeCallAndHandleError() : Int = try {
makeCall()
} catch (e: {{ error_type|error_type_name }}) {
} catch (e: {{ error_type|type_name(ci) }}) {
// Expected error, serialize it into outBuf
outBuf.setValue({{ error_type|ffi_converter_name }}.lowerIntoRustBuffer(e))
UNIFFI_CALLBACK_ERROR

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

@ -1,4 +1,4 @@
{%- match kotlin_config.custom_types.get(name.as_str()) %}
{%- match config.custom_types.get(name.as_str()) %}
{%- when None %}
{#- Define the type using typealiases to the builtin #}
/**
@ -6,12 +6,12 @@
* is needed because the UDL type name is used in function/method signatures.
* It's also what we have an external type that references a custom type.
*/
public typealias {{ name }} = {{ builtin|type_name }}
public typealias {{ name }} = {{ builtin|type_name(ci) }}
public typealias {{ ffi_converter_name }} = {{ builtin|ffi_converter_name }}
{%- when Some with (config) %}
{%- let ffi_type_name=builtin.ffi_type().borrow()|ffi_type_name_by_value %}
{%- let ffi_type_name=builtin|ffi_type|ffi_type_name_by_value %}
{# When the config specifies a different type name, create a typealias for it #}
{%- match config.type_name %}

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

@ -11,6 +11,7 @@ enum class {{ type_name }} {
{% for variant in e.variants() -%}
{{ variant|variant_name }}{% if loop.last %};{% else %},{% endif %}
{%- endfor %}
companion object
}
public object {{ e|ffi_converter_name }}: FfiConverterRustBuffer<{{ type_name }}> {
@ -32,13 +33,15 @@ public object {{ e|ffi_converter_name }}: FfiConverterRustBuffer<{{ type_name }}
sealed class {{ type_name }}{% if contains_object_references %}: Disposable {% endif %} {
{% for variant in e.variants() -%}
{% if !variant.has_fields() -%}
object {{ variant|enum_variant|type_name }} : {{ type_name }}()
object {{ variant|type_name(ci) }} : {{ type_name }}()
{% else -%}
data class {{ variant|enum_variant|type_name }}(
data class {{ variant|type_name(ci) }}(
{% for field in variant.fields() -%}
val {{ field.name()|var_name }}: {{ field|type_name}}{% if loop.last %}{% else %}, {% endif %}
val {{ field.name()|var_name }}: {{ field|type_name(ci) }}{% if loop.last %}{% else %}, {% endif %}
{% endfor -%}
) : {{ type_name }}()
) : {{ type_name }}() {
companion object
}
{%- endif %}
{% endfor %}
@ -47,7 +50,7 @@ sealed class {{ type_name }}{% if contains_object_references %}: Disposable {% e
override fun destroy() {
when(this) {
{%- for variant in e.variants() %}
is {{ type_name }}.{{ variant|enum_variant|type_name }} -> {
is {{ type_name }}.{{ variant|type_name(ci) }} -> {
{%- if variant.has_fields() %}
{% call kt::destroy_fields(variant) %}
{% else -%}
@ -58,13 +61,14 @@ sealed class {{ type_name }}{% if contains_object_references %}: Disposable {% e
}.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
}
{% endif %}
companion object
}
public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }}>{
override fun read(buf: ByteBuffer): {{ type_name }} {
return when(buf.getInt()) {
{%- for variant in e.variants() %}
{{ loop.index }} -> {{ type_name }}.{{ variant|enum_variant|type_name }}{% if variant.has_fields() %}(
{{ loop.index }} -> {{ type_name }}.{{ variant|type_name(ci) }}{% if variant.has_fields() %}(
{% for field in variant.fields() -%}
{{ field|read_fn }}(buf),
{% endfor -%}
@ -76,7 +80,7 @@ public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }
override fun allocationSize(value: {{ type_name }}) = when(value) {
{%- for variant in e.variants() %}
is {{ type_name }}.{{ variant|enum_variant|type_name }} -> {
is {{ type_name }}.{{ variant|type_name(ci) }} -> {
// Add the size for the Int that specifies the variant plus the size needed for all fields
(
4
@ -91,7 +95,7 @@ public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }
override fun write(value: {{ type_name }}, buf: ByteBuffer) {
when(value) {
{%- for variant in e.variants() %}
is {{ type_name }}.{{ variant|enum_variant|type_name }} -> {
is {{ type_name }}.{{ variant|type_name(ci) }} -> {
buf.putInt({{ loop.index }})
{%- for field in variant.fields() %}
{{ field|write_fn }}(value.{{ field.name()|var_name }}, buf)

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

@ -1,13 +1,13 @@
{%- let type_name = type_|error_type_name %}
{%- let ffi_converter_name = type_|error_ffi_converter_name %}
{%- let canonical_type_name = type_|error_canonical_name %}
{%- let type_name = type_|type_name(ci) %}
{%- let ffi_converter_name = type_|ffi_converter_name %}
{%- let canonical_type_name = type_|canonical_name %}
{% if e.is_flat() %}
sealed class {{ type_name }}(message: String): Exception(message){% if contains_object_references %}, Disposable {% endif %} {
// Each variant is a nested class
// Flat enums carries a string error message, so no special implementation is necessary.
{% for variant in e.variants() -%}
class {{ variant|error_variant|type_name }}(message: String) : {{ type_name }}(message)
class {{ variant|error_variant_name }}(message: String) : {{ type_name }}(message)
{% endfor %}
companion object ErrorHandler : CallStatusErrorHandler<{{ type_name }}> {
@ -18,10 +18,10 @@ sealed class {{ type_name }}(message: String): Exception(message){% if contains_
sealed class {{ type_name }}: Exception(){% if contains_object_references %}, Disposable {% endif %} {
// Each variant is a nested class
{% for variant in e.variants() -%}
{%- let variant_name = variant|error_variant|type_name %}
{%- let variant_name = variant|error_variant_name %}
class {{ variant_name }}(
{% for field in variant.fields() -%}
val {{ field.name()|var_name }}: {{ field|type_name}}{% if loop.last %}{% else %}, {% endif %}
val {{ field.name()|var_name }}: {{ field|type_name(ci) }}{% if loop.last %}{% else %}, {% endif %}
{% endfor -%}
) : {{ type_name }}() {
override val message
@ -38,7 +38,7 @@ sealed class {{ type_name }}: Exception(){% if contains_object_references %}, Di
override fun destroy() {
when(this) {
{%- for variant in e.variants() %}
is {{ type_name }}.{{ variant|error_variant|type_name }} -> {
is {{ type_name }}.{{ variant|error_variant_name }} -> {
{%- if variant.has_fields() %}
{% call kt::destroy_fields(variant) %}
{% else -%}
@ -57,7 +57,7 @@ public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }
{% if e.is_flat() %}
return when(buf.getInt()) {
{%- for variant in e.variants() %}
{{ loop.index }} -> {{ type_name }}.{{ variant|error_variant|type_name }}({{ Type::String.borrow()|read_fn }}(buf))
{{ loop.index }} -> {{ type_name }}.{{ variant|error_variant_name }}({{ Type::String.borrow()|read_fn }}(buf))
{%- endfor %}
else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
}
@ -65,7 +65,7 @@ public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }
return when(buf.getInt()) {
{%- for variant in e.variants() %}
{{ loop.index }} -> {{ type_name }}.{{ variant|error_variant|type_name }}({% if variant.has_fields() %}
{{ loop.index }} -> {{ type_name }}.{{ variant|error_variant_name }}({% if variant.has_fields() %}
{% for field in variant.fields() -%}
{{ field|read_fn }}(buf),
{% endfor -%}
@ -82,7 +82,7 @@ public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }
{%- else %}
return when(value) {
{%- for variant in e.variants() %}
is {{ type_name }}.{{ variant|error_variant|type_name }} -> (
is {{ type_name }}.{{ variant|error_variant_name }} -> (
// Add the size for the Int that specifies the variant plus the size needed for all fields
4
{%- for field in variant.fields() %}
@ -97,7 +97,7 @@ public object {{ e|ffi_converter_name }} : FfiConverterRustBuffer<{{ type_name }
override fun write(value: {{ type_name }}, buf: ByteBuffer) {
when(value) {
{%- for variant in e.variants() %}
is {{ type_name }}.{{ variant|error_variant|type_name }} -> {
is {{ type_name }}.{{ variant|error_variant_name }} -> {
buf.putInt({{ loop.index }})
{%- for field in variant.fields() %}
{{ field|write_fn }}(value.{{ field.name()|var_name }}, buf)

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

@ -1,4 +1,4 @@
{%- let package_name=self.external_type_package_name(crate_name) %}
{%- let package_name=self.external_type_package_name(module_path, namespace) %}
{%- let fully_qualified_type_name = "{}.{}"|format(package_name, name) %}
{%- let fully_qualified_ffi_converter_name = "{}.FfiConverterType{}"|format(package_name, name) %}
{%- let fully_qualified_rustbuffer_name = "{}.RustBuffer"|format(package_name) %}

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

@ -1,24 +1,42 @@
{{ self.add_import("kotlinx.coroutines.CoroutineScope") }}
{{ self.add_import("kotlinx.coroutines.delay") }}
{{ self.add_import("kotlinx.coroutines.isActive") }}
{{ self.add_import("kotlinx.coroutines.launch") }}
internal const val UNIFFI_RUST_TASK_CALLBACK_SUCCESS = 0.toByte()
internal const val UNIFFI_RUST_TASK_CALLBACK_CANCELLED = 1.toByte()
internal const val UNIFFI_FOREIGN_EXECUTOR_CALLBACK_SUCCESS = 0.toByte()
internal const val UNIFFI_FOREIGN_EXECUTOR_CALLBACK_CANCELLED = 1.toByte()
internal const val UNIFFI_FOREIGN_EXECUTOR_CALLBACK_ERROR = 2.toByte()
// Callback function to execute a Rust task. The Kotlin code schedules these in a coroutine then
// invokes them.
internal interface UniFfiRustTaskCallback : com.sun.jna.Callback {
fun invoke(rustTaskData: Pointer?)
fun callback(rustTaskData: Pointer?, statusCode: Byte)
}
object UniFfiForeignExecutorCallback : com.sun.jna.Callback {
internal fun invoke(handle: USize, delayMs: Int, rustTask: UniFfiRustTaskCallback?, rustTaskData: Pointer?) {
internal object UniFfiForeignExecutorCallback : com.sun.jna.Callback {
fun callback(handle: USize, delayMs: Int, rustTask: UniFfiRustTaskCallback?, rustTaskData: Pointer?) : Byte {
if (rustTask == null) {
FfiConverterForeignExecutor.drop(handle)
return UNIFFI_FOREIGN_EXECUTOR_CALLBACK_SUCCESS
} else {
val coroutineScope = FfiConverterForeignExecutor.lift(handle)
coroutineScope.launch {
if (delayMs > 0) {
delay(delayMs.toLong())
if (coroutineScope.isActive) {
val job = coroutineScope.launch {
if (delayMs > 0) {
delay(delayMs.toLong())
}
rustTask.callback(rustTaskData, UNIFFI_RUST_TASK_CALLBACK_SUCCESS)
}
rustTask.invoke(rustTaskData)
job.invokeOnCompletion { cause ->
if (cause != null) {
rustTask.callback(rustTaskData, UNIFFI_RUST_TASK_CALLBACK_CANCELLED)
}
}
return UNIFFI_FOREIGN_EXECUTOR_CALLBACK_SUCCESS
} else {
return UNIFFI_FOREIGN_EXECUTOR_CALLBACK_CANCELLED
}
}
}
@ -32,7 +50,12 @@ public object FfiConverterForeignExecutor: FfiConverter<CoroutineScope, USize> {
}
internal fun register(lib: _UniFFILib) {
lib.uniffi_foreign_executor_callback_set(UniFfiForeignExecutorCallback)
{%- match ci.ffi_foreign_executor_callback_set() %}
{%- when Some with (fn) %}
lib.{{ fn.name() }}(UniFfiForeignExecutorCallback)
{%- when None %}
{#- No foreign executor, we don't set anything #}
{% endmatch %}
}
// Number of live handles, exposed so we can test the memory management

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

@ -77,6 +77,8 @@ private inline fun <U> rustCall(callback: (RustCallStatus) -> U): U {
public class USize(value: Long = 0) : IntegerType(Native.SIZE_T_SIZE, value, true) {
// This is needed to fill in the gaps of IntegerType's implementation of Number for Kotlin.
override fun toByte() = toInt().toByte()
// Needed until https://youtrack.jetbrains.com/issue/KT-47902 is fixed.
@Deprecated("`toInt().toChar()` is deprecated")
override fun toChar() = toInt().toChar()
override fun toShort() = toInt().toShort()
@ -148,7 +150,12 @@ internal class UniFfiHandleMap<T: Any> {
return map.get(handle)
}
fun remove(handle: USize) {
map.remove(handle)
fun remove(handle: USize): T? {
return map.remove(handle)
}
}
// FFI type for Rust future continuations
internal interface UniFffiRustFutureContinuationCallbackType : com.sun.jna.Callback {
fun callback(continuationHandle: USize, pollResult: Short);
}

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

@ -1,16 +1,15 @@
{%- let key_type_name = key_type|type_name %}
{%- let value_type_name = value_type|type_name %}
{%- let key_type_name = key_type|type_name(ci) %}
{%- let value_type_name = value_type|type_name(ci) %}
public object {{ ffi_converter_name }}: FfiConverterRustBuffer<Map<{{ key_type_name }}, {{ value_type_name }}>> {
override fun read(buf: ByteBuffer): Map<{{ key_type_name }}, {{ value_type_name }}> {
// TODO: Once Kotlin's `buildMap` API is stabilized we should use it here.
val items : MutableMap<{{ key_type_name }}, {{ value_type_name }}> = mutableMapOf()
val len = buf.getInt()
repeat(len) {
val k = {{ key_type|read_fn }}(buf)
val v = {{ value_type|read_fn }}(buf)
items[k] = v
return buildMap<{{ key_type_name }}, {{ value_type_name }}>(len) {
repeat(len) {
val k = {{ key_type|read_fn }}(buf)
val v = {{ value_type|read_fn }}(buf)
this[k] = v
}
}
return items
}
override fun allocationSize(value: Map<{{ key_type_name }}, {{ value_type_name }}>): Int {

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

@ -7,7 +7,7 @@ public interface {{ type_name }}Interface {
{% for meth in obj.methods() -%}
{%- match meth.throws_type() -%}
{%- when Some with (throwable) -%}
@Throws({{ throwable|error_type_name }}::class)
@Throws({{ throwable|type_name(ci) }}::class)
{%- when None -%}
{%- endmatch %}
{% if meth.is_async() -%}
@ -16,11 +16,12 @@ public interface {{ type_name }}Interface {
fun {{ meth.name()|fn_name }}({% call kt::arg_list_decl(meth) %})
{%- endif %}
{%- match meth.return_type() -%}
{%- when Some with (return_type) %}: {{ return_type|type_name -}}
{%- when Some with (return_type) %}: {{ return_type|type_name(ci) -}}
{%- when None -%}
{%- endmatch -%}
{% endfor %}
companion object
}
class {{ type_name }}(
@ -51,46 +52,42 @@ class {{ type_name }}(
{% for meth in obj.methods() -%}
{%- match meth.throws_type() -%}
{%- when Some with (throwable) %}
@Throws({{ throwable|error_type_name }}::class)
@Throws({{ throwable|type_name(ci) }}::class)
{%- else -%}
{%- endmatch -%}
{%- if meth.is_async() %}
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun {{ meth.name()|fn_name }}({%- call kt::arg_list_decl(meth) -%}){% match meth.return_type() %}{% when Some with (return_type) %} : {{ return_type|type_name }}{% when None %}{%- endmatch %} {
// Create a new `CoroutineScope` for this operation, suspend the coroutine, and call the
// scaffolding function, passing it one of the callback handlers from `AsyncTypes.kt`.
//
// Make sure to retain a reference to the callback handler to ensure that it's not GCed before
// it's invoked
var callbackHolder: {{ func.result_type().borrow()|future_callback_handler }}? = null
return coroutineScope {
val scope = this
return@coroutineScope suspendCoroutine { continuation ->
try {
val callback = {{ meth.result_type().borrow()|future_callback_handler }}(continuation)
callbackHolder = callback
callWithPointer { thisPtr ->
rustCall { status ->
_UniFFILib.INSTANCE.{{ meth.ffi_func().name() }}(
thisPtr,
{% call kt::arg_list_lowered(meth) %}
FfiConverterForeignExecutor.lower(scope),
callback,
USize(0),
status,
)
}
}
} catch (e: Exception) {
continuation.resumeWithException(e)
}
}
}
override suspend fun {{ meth.name()|fn_name }}({%- call kt::arg_list_decl(meth) -%}){% match meth.return_type() %}{% when Some with (return_type) %} : {{ return_type|type_name(ci) }}{% when None %}{%- endmatch %} {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
_UniFFILib.INSTANCE.{{ meth.ffi_func().name() }}(
thisPtr,
{% call kt::arg_list_lowered(meth) %}
)
},
{{ meth|async_poll(ci) }},
{{ meth|async_complete(ci) }},
{{ meth|async_free(ci) }},
// lift function
{%- match meth.return_type() %}
{%- when Some(return_type) %}
{ {{ return_type|lift_fn }}(it) },
{%- when None %}
{ Unit },
{% endmatch %}
// Error FFI converter
{%- match meth.throws_type() %}
{%- when Some(e) %}
{{ e|type_name(ci) }}.ErrorHandler,
{%- when None %}
NullCallStatusErrorHandler,
{%- endmatch %}
)
}
{%- else -%}
{%- match meth.return_type() -%}
{%- when Some with (return_type) -%}
override fun {{ meth.name()|fn_name }}({% call kt::arg_list_protocol(meth) %}): {{ return_type|type_name }} =
override fun {{ meth.name()|fn_name }}({% call kt::arg_list_protocol(meth) %}): {{ return_type|type_name(ci) }} =
callWithPointer {
{%- call kt::to_ffi_call_with_prefix("it", meth) %}
}.let {
@ -113,6 +110,8 @@ class {{ type_name }}(
{{ type_name }}({% call kt::to_ffi_call(cons) %})
{% endfor %}
}
{% else %}
companion object
{% endif %}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше