Backed out 2 changesets (bug 1867639) for causing WR bustages

Backed out changeset b77038bd9fee (bug 1867639)
Backed out changeset cf885f915fdf (bug 1867639)
This commit is contained in:
Narcis Beleuzu 2023-12-05 22:35:09 +02:00
parent b473b42e01
commit 18393f328a
309 changed files with 9038 additions and 15538 deletions

View file

@ -15,11 +15,6 @@ git = "https://github.com/FirefoxGraphics/wpf-gpu-raster"
rev = "99979da091fd58fba8477e7fcdf5ec0727102916"
replace-with = "vendored-sources"
[source."git+https://github.com/bendk/oneshot?tag=v0.1.5-mozilla"]
git = "https://github.com/bendk/oneshot"
tag = "v0.1.5-mozilla"
replace-with = "vendored-sources"
[source."git+https://github.com/chris-zen/coremidi.git?rev=fc68464b5445caf111e41f643a2e69ccce0b4f83"]
git = "https://github.com/chris-zen/coremidi.git"
rev = "fc68464b5445caf111e41f643a2e69ccce0b4f83"
@ -60,9 +55,9 @@ git = "https://github.com/mozilla-spidermonkey/jsparagus"
rev = "64ba08e24749616de2344112f226d1ef4ba893ae"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822"]
[source."git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c"]
git = "https://github.com/mozilla/application-services"
rev = "5babdbc9756a879c906d12613bb764b3f99fe822"
rev = "c82bccfa500813f273f4db0ead64fc73bfa2b34c"
replace-with = "vendored-sources"
[source."git+https://github.com/mozilla/audioipc?rev=6be424d75f1367e70f2f5ddcacd6d0237e81a6a9"]
@ -95,9 +90,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=f2353fcbfde83207a0033301653bc69be86e4572"]
[source."git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21"]
git = "https://github.com/mozilla/uniffi-rs.git"
rev = "f2353fcbfde83207a0033301653bc69be86e4572"
rev = "c0e64b839018728d8153ce1758d391b7782e2e21"
replace-with = "vendored-sources"
[source."git+https://github.com/rust-lang/rust-bindgen?rev=86f3dbe846020e2ba573d6eb38d1434d0cbcbb40"]

100
Cargo.lock generated
View file

@ -1583,7 +1583,7 @@ dependencies = [
[[package]]
name = "error-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
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=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"proc-macro2",
"quote",
@ -2245,7 +2245,6 @@ dependencies = [
"uniffi-example-todolist",
"uniffi-fixture-callbacks",
"uniffi-fixture-external-types",
"uniffi_core",
"url",
"viaduct",
"webext_storage_bridge",
@ -2285,9 +2284,9 @@ dependencies = [
[[package]]
name = "glean"
version = "56.0.0"
version = "55.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd4421c9e77e098f774ce712128179069dd6a56904d3b95c9cf35b8418e3d6a"
checksum = "2082baa3ee5b327652819b7476e1a7dc75c03217382e15764a3284b90fb071e4"
dependencies = [
"chrono",
"crossbeam-channel",
@ -2305,9 +2304,9 @@ dependencies = [
[[package]]
name = "glean-core"
version = "56.0.0"
version = "55.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a39d53b7dd7b0b81325273cd601f7ae19fba48e0916413c72952a3cf2b82293e"
checksum = "ed16f55045cb3e210e6ce19c03597a77a2a086a36733eea9c332dcd696962995"
dependencies = [
"android_logger",
"bincode",
@ -2807,7 +2806,7 @@ dependencies = [
[[package]]
name = "interrupt-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"lazy_static",
"parking_lot",
@ -3985,7 +3984,7 @@ dependencies = [
[[package]]
name = "nss_build_common"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
[[package]]
name = "nsstring"
@ -4106,11 +4105,6 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "oneshot"
version = "0.1.5"
source = "git+https://github.com/bendk/oneshot?tag=v0.1.5-mozilla#1f3c657c8073aec4f0b6ebac7be33b4851644745"
[[package]]
name = "ordered-float"
version = "3.4.0"
@ -4655,7 +4649,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "remote_settings"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"parking_lot",
"serde",
@ -5186,7 +5180,7 @@ dependencies = [
[[package]]
name = "sql-support"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"ffi-support",
"interrupt-support",
@ -5367,7 +5361,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "suggest"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"anyhow",
"chrono",
@ -5413,7 +5407,7 @@ dependencies = [
[[package]]
name = "sync-guid"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"base64 0.21.3",
"rand",
@ -5424,7 +5418,7 @@ dependencies = [
[[package]]
name = "sync15"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"anyhow",
"error-support",
@ -5456,7 +5450,7 @@ dependencies = [
[[package]]
name = "tabs"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"anyhow",
"error-support",
@ -5835,9 +5829,9 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "uniffi"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32e192430644d99babe02bede25316eee84fa154b1e5f8cfe99406c028b8c577"
checksum = "7e835154c561cd75f253008093a908c06fb1f14327afb0ffea88eac72e534cc0"
dependencies = [
"anyhow",
"uniffi_build",
@ -5864,7 +5858,7 @@ dependencies = [
[[package]]
name = "uniffi-example-arithmetic"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=f2353fcbfde83207a0033301653bc69be86e4572#f2353fcbfde83207a0033301653bc69be86e4572"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
dependencies = [
"thiserror",
"uniffi",
@ -5884,7 +5878,7 @@ dependencies = [
[[package]]
name = "uniffi-example-geometry"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=f2353fcbfde83207a0033301653bc69be86e4572#f2353fcbfde83207a0033301653bc69be86e4572"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
dependencies = [
"uniffi",
]
@ -5892,7 +5886,7 @@ dependencies = [
[[package]]
name = "uniffi-example-rondpoint"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=f2353fcbfde83207a0033301653bc69be86e4572#f2353fcbfde83207a0033301653bc69be86e4572"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
dependencies = [
"uniffi",
]
@ -5900,7 +5894,7 @@ dependencies = [
[[package]]
name = "uniffi-example-sprites"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=f2353fcbfde83207a0033301653bc69be86e4572#f2353fcbfde83207a0033301653bc69be86e4572"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
dependencies = [
"uniffi",
]
@ -5908,7 +5902,7 @@ dependencies = [
[[package]]
name = "uniffi-example-todolist"
version = "0.22.0"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=f2353fcbfde83207a0033301653bc69be86e4572#f2353fcbfde83207a0033301653bc69be86e4572"
source = "git+https://github.com/mozilla/uniffi-rs.git?rev=c0e64b839018728d8153ce1758d391b7782e2e21#c0e64b839018728d8153ce1758d391b7782e2e21"
dependencies = [
"once_cell",
"thiserror",
@ -5934,9 +5928,9 @@ dependencies = [
[[package]]
name = "uniffi_bindgen"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c235355da41bc8347b2d5851e1060d4652dfbdc6d7d6ccddaabebe25e3c32a4"
checksum = "c2f91fdcd44de3aab35847bf80485f412879dcdd92b5140ee67f948e5eed750e"
dependencies = [
"anyhow",
"askama",
@ -5949,17 +5943,18 @@ dependencies = [
"once_cell",
"paste",
"serde",
"serde_json",
"toml",
"uniffi_meta",
"uniffi_testing",
"uniffi_udl",
"weedle2",
]
[[package]]
name = "uniffi_build"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81049ed7015a8a66b085aca3fb0c0011fdae4dd9ab8c38f5751f7861d60eb0f4"
checksum = "4b20f693fb51c21a21b9816bed5522f0231cc769d8ba38821a05ab7d39dad51d"
dependencies = [
"anyhow",
"camino",
@ -5968,9 +5963,9 @@ dependencies = [
[[package]]
name = "uniffi_checksum_derive"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce082833f0fcaf6fc221fbab26720440daf99381f5a71e89b6e23375eb6ea770"
checksum = "d1b354a9bd654cc6547d461ccd60a10eb6c7473178f12d8ff91cf4340ae947e8"
dependencies = [
"quote",
"syn",
@ -5978,25 +5973,25 @@ dependencies = [
[[package]]
name = "uniffi_core"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "389bbe4d8334b3370c7cc998788d7a9619e0b61b58f1cbcd4a6a8606ab0a6f7d"
checksum = "32793120650ceda4f4e0d8eacd784c1a736834b2cca7b12e2550d3a190553af4"
dependencies = [
"anyhow",
"bytes",
"camino",
"cargo_metadata",
"log",
"once_cell",
"oneshot",
"paste",
"static_assertions",
]
[[package]]
name = "uniffi_macros"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa170f970d42d8fbe205f5794b83f72d6617835a73b91ed1869e1eba5dd06c"
checksum = "c65987b46a026ab1dfff218963d34c45375355dd6f1995618262e1e038507ba3"
dependencies = [
"bincode",
"camino",
@ -6013,39 +6008,30 @@ dependencies = [
[[package]]
name = "uniffi_meta"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ef337c28a379ed6962eae0cb0824ab31202b21b8ae3bf6c2a706f5e7285f5f"
checksum = "f815bba89a6585954c089c53a775d166c0334c907be0e462bf0f0ac0494656e7"
dependencies = [
"anyhow",
"bytes",
"serde",
"siphasher",
"uniffi_checksum_derive",
]
[[package]]
name = "uniffi_testing"
version = "0.25.2"
version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f2e218997229b4ed6e08c1abc9e277dde817f68a633babd3ebbfc77e32db302"
checksum = "1048d7c54816dc27ed4041fe952d42c7cb88e711cf3299e36ee70df7692c4a39"
dependencies = [
"anyhow",
"camino",
"cargo_metadata",
"fs-err",
"once_cell",
]
[[package]]
name = "uniffi_udl"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb29909e50256f32986ea3b3c32d2c49dece14ae4b3428c047913696ed200b2a"
dependencies = [
"anyhow",
"uniffi_meta",
"uniffi_testing",
"weedle2",
"serde",
"serde_json",
]
[[package]]
@ -6104,7 +6090,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "viaduct"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"ffi-support",
"log",
@ -6250,7 +6236,7 @@ dependencies = [
[[package]]
name = "webext-storage"
version = "0.1.0"
source = "git+https://github.com/mozilla/application-services?rev=5babdbc9756a879c906d12613bb764b3f99fe822#5babdbc9756a879c906d12613bb764b3f99fe822"
source = "git+https://github.com/mozilla/application-services?rev=c82bccfa500813f273f4db0ead64fc73bfa2b34c#c82bccfa500813f273f4db0ead64fc73bfa2b34c"
dependencies = [
"anyhow",
"error-support",

View file

@ -51,7 +51,7 @@ resolver = "2"
[workspace.dependencies]
# Shared across multiple UniFFI consumers.
uniffi = "0.25.2"
uniffi = "0.24.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,17 +203,13 @@ warp = { git = "https://github.com/glandium/warp", rev = "4af45fae95bc98b0eba1ef
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 = "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 oneshot to disable the `loom` target, which we never use but causes many `loom` and many
# other dependencies to be pulled in when running `mach vendor rust`
oneshot = { git = "https://github.com/bendk/oneshot", tag = "v0.1.5-mozilla" }
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" }
# 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.
@ -221,8 +217,8 @@ oneshot = { git = "https://github.com/bendk/oneshot", tag = "v0.1.5-mozilla" }
path = "third_party/rust/mio-0.6.23"
[patch."https://github.com/mozilla/uniffi-rs.git"]
uniffi = "=0.25.2"
uniffi_bindgen = "=0.25.2"
uniffi_build = "=0.25.2"
uniffi_macros = "=0.25.2"
uniffi = "=0.24.3"
uniffi_bindgen = "=0.24.3"
uniffi_build = "=0.24.3"
uniffi_macros = "=0.24.3"
weedle2 = "=4.0.0"

View file

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

311
gfx/wr/Cargo.lock generated
View file

@ -952,19 +952,6 @@ dependencies = [
"byteorder",
]
[[package]]
name = "generator"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cc16584ff22b460a382b7feec54b23d2908d858152e5739a120b949293bd74e"
dependencies = [
"cc",
"libc",
"log",
"rustversion",
"windows",
]
[[package]]
name = "getrandom"
version = "0.2.6"
@ -1009,9 +996,9 @@ dependencies = [
[[package]]
name = "glean"
version = "56.0.0"
version = "55.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bd4421c9e77e098f774ce712128179069dd6a56904d3b95c9cf35b8418e3d6a"
checksum = "2082baa3ee5b327652819b7476e1a7dc75c03217382e15764a3284b90fb071e4"
dependencies = [
"chrono",
"crossbeam-channel",
@ -1029,9 +1016,9 @@ dependencies = [
[[package]]
name = "glean-core"
version = "56.0.0"
version = "55.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a39d53b7dd7b0b81325273cd601f7ae19fba48e0916413c72952a3cf2b82293e"
checksum = "ed16f55045cb3e210e6ce19c03597a77a2a086a36733eea9c332dcd696962995"
dependencies = [
"android_logger",
"bincode",
@ -1576,20 +1563,6 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "loom"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff50ecb28bb86013e935fb6683ab1f6d3a20016f123c76fd4c27470076ac30f5"
dependencies = [
"cfg-if 1.0.0",
"generator",
"pin-utils",
"scoped-tls",
"tracing",
"tracing-subscriber",
]
[[package]]
name = "malloc_buf"
version = "0.0.6"
@ -1610,15 +1583,6 @@ dependencies = [
"synstructure 0.12.6",
]
[[package]]
name = "matchers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558"
dependencies = [
"regex-automata",
]
[[package]]
name = "matches"
version = "0.1.9"
@ -1830,16 +1794,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num-integer"
version = "0.1.42"
@ -1927,15 +1881,6 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "oneshot"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f6640c6bda7731b1fdbab747981a0f896dd1fedaf9f4a53fa237a04a84431f4"
dependencies = [
"loom",
]
[[package]]
name = "ordered-float"
version = "3.4.0"
@ -1976,12 +1921,6 @@ dependencies = [
"shared_library",
]
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "parking_lot"
version = "0.11.2"
@ -2096,18 +2035,6 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db8bcd96cb740d03149cbad5518db9fd87126a10ab519c011893b1754134c468"
[[package]]
name = "pin-project-lite"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.17"
@ -2321,15 +2248,6 @@ dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.28"
@ -2512,15 +2430,6 @@ dependencies = [
"pkg-config",
]
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "shared_library"
version = "0.1.9"
@ -2732,16 +2641,6 @@ dependencies = [
"syn 1.0.91",
]
[[package]]
name = "thread_local"
version = "1.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152"
dependencies = [
"cfg-if 1.0.0",
"once_cell",
]
[[package]]
name = "time"
version = "0.1.44"
@ -2792,67 +2691,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa7c7f42dea4b1b99439786f5633aeb9c14c1b53f75e282803c2ec2ad545873c"
[[package]]
name = "tracing"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.25",
]
[[package]]
name = "tracing-core"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922"
dependencies = [
"lazy_static",
"log",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70"
dependencies = [
"matchers",
"nu-ansi-term",
"once_cell",
"regex",
"sharded-slab",
"smallvec",
"thread_local",
"tracing",
"tracing-core",
"tracing-log",
]
[[package]]
name = "tracy-rs"
version = "0.1.2"
@ -2900,9 +2738,9 @@ checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "uniffi"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32e192430644d99babe02bede25316eee84fa154b1e5f8cfe99406c028b8c577"
checksum = "6da26ba712a8547207ededc70f3e0952c09754be9516c320f71731d2f18daf3e"
dependencies = [
"anyhow",
"uniffi_build",
@ -2912,9 +2750,9 @@ dependencies = [
[[package]]
name = "uniffi_bindgen"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c235355da41bc8347b2d5851e1060d4652dfbdc6d7d6ccddaabebe25e3c32a4"
checksum = "29bff3ba24868022fc82e2f1558f3a0fdcc2655e1335459a35f25d1ec4ff1d0c"
dependencies = [
"anyhow",
"askama",
@ -2927,17 +2765,18 @@ dependencies = [
"once_cell",
"paste",
"serde",
"serde_json",
"toml",
"uniffi_meta",
"uniffi_testing",
"uniffi_udl",
"weedle2",
]
[[package]]
name = "uniffi_build"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81049ed7015a8a66b085aca3fb0c0011fdae4dd9ab8c38f5751f7861d60eb0f4"
checksum = "52b7cd03e17b997469e5438d1a491c3b9e2d41c2a87c86fd91ba96e87aecba6a"
dependencies = [
"anyhow",
"camino",
@ -2946,9 +2785,9 @@ dependencies = [
[[package]]
name = "uniffi_checksum_derive"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce082833f0fcaf6fc221fbab26720440daf99381f5a71e89b6e23375eb6ea770"
checksum = "af98d58e238b6aef9ff62a93b5c60caa710bdb49351434a639b9bd7b4c84c808"
dependencies = [
"quote",
"syn 2.0.25",
@ -2956,25 +2795,25 @@ dependencies = [
[[package]]
name = "uniffi_core"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "389bbe4d8334b3370c7cc998788d7a9619e0b61b58f1cbcd4a6a8606ab0a6f7d"
checksum = "68640fa1b5dfbb4ccc149057c81b40adc51a01d295ce798c15c6c76f7e899907"
dependencies = [
"anyhow",
"bytes",
"camino",
"cargo_metadata",
"log",
"once_cell",
"oneshot",
"paste",
"static_assertions",
]
[[package]]
name = "uniffi_macros"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34aa170f970d42d8fbe205f5794b83f72d6617835a73b91ed1869e1eba5dd06c"
checksum = "76f72684ff48a8ff0ee95fde6dbcfa687236ad1789dc18205cb3305432a7b35c"
dependencies = [
"bincode",
"camino",
@ -2991,39 +2830,31 @@ dependencies = [
[[package]]
name = "uniffi_meta"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22ef337c28a379ed6962eae0cb0824ab31202b21b8ae3bf6c2a706f5e7285f5f"
checksum = "fe3388a58b13dad8f0cdcbdee1c59af6408608ce8d85a3ef5d1429369ca7b217"
dependencies = [
"anyhow",
"bytes",
"serde",
"siphasher",
"uniffi_checksum_derive",
"uniffi_core",
]
[[package]]
name = "uniffi_testing"
version = "0.25.2"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f2e218997229b4ed6e08c1abc9e277dde817f68a633babd3ebbfc77e32db302"
checksum = "4fb437a2c8565249274e381fd88bc75b539897f321b79022c9fe7e275d2c2bbb"
dependencies = [
"anyhow",
"camino",
"cargo_metadata",
"fs-err",
"once_cell",
]
[[package]]
name = "uniffi_udl"
version = "0.25.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb29909e50256f32986ea3b3c32d2c49dece14ae4b3428c047913696ed200b2a"
dependencies = [
"anyhow",
"uniffi_meta",
"uniffi_testing",
"weedle2",
"serde",
"serde_json",
]
[[package]]
@ -3047,12 +2878,6 @@ dependencies = [
"getrandom",
]
[[package]]
name = "valuable"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
[[package]]
name = "version_check"
version = "0.9.1"
@ -3362,22 +3187,13 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f"
dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets 0.42.2",
"windows-targets",
]
[[package]]
@ -3386,28 +3202,13 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
"windows_aarch64_gnullvm 0.42.2",
"windows_aarch64_msvc 0.42.2",
"windows_i686_gnu 0.42.2",
"windows_i686_msvc 0.42.2",
"windows_x86_64_gnu 0.42.2",
"windows_x86_64_gnullvm 0.42.2",
"windows_x86_64_msvc 0.42.2",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
@ -3416,84 +3217,42 @@ version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "winit"
version = "0.26.1"

View file

@ -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 = "56.0.0"
glean = "55.0.0"
firefox-on-glean = { version = "0.1.0", optional = true }
swgl = { path = "../swgl", optional = true }
topological-sort = "0.1"

View file

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

View file

@ -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==56.0.0:telemetry will not be collected
pypi-optional:glean-sdk==55.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).

View file

@ -2655,23 +2655,6 @@ 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.ordered-float]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"

View file

@ -151,10 +151,6 @@ audit-as-crates-io = false
audit-as-crates-io = true
notes = "Part of the wgpu repository, pinned as the rest of wgpu crates."
[policy.oneshot]
audit-as-crates-io = true
notes = "Cloned from the official sources with an extra commit that doesn't affect moz-central"
[policy.peek-poke]
audit-as-crates-io = false

View file

@ -225,13 +225,6 @@ 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"
@ -239,13 +232,6 @@ 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"
@ -664,13 +650,6 @@ 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_bindgen]]
version = "0.24.3"
when = "2023-08-01"
@ -678,13 +657,6 @@ 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_build]]
version = "0.24.3"
when = "2023-08-01"
@ -692,13 +664,6 @@ 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_checksum_derive]]
version = "0.24.3"
when = "2023-08-01"
@ -706,13 +671,6 @@ 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_core]]
version = "0.24.3"
when = "2023-08-01"
@ -720,13 +678,6 @@ 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_macros]]
version = "0.24.3"
when = "2023-08-01"
@ -734,13 +685,6 @@ 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_meta]]
version = "0.24.3"
when = "2023-08-01"
@ -748,13 +692,6 @@ 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_testing]]
version = "0.24.3"
when = "2023-08-01"
@ -762,20 +699,6 @@ 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_udl]]
version = "0.25.2"
when = "2023-11-20"
user-id = 111105
user-login = "mhammond"
user-name = "Mark Hammond"
[[publisher.utf8_iter]]
version = "1.0.3"
when = "2022-09-09"
@ -1546,78 +1469,6 @@ 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"

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

File diff suppressed because one or more lines are too long

View file

@ -11,9 +11,9 @@
[package]
edition = "2021"
rust-version = "1.65"
rust-version = "1.63"
name = "glean-core"
version = "56.0.0"
version = "55.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.25.2"
version = "0.24.1"
default-features = false
[dependencies.uuid]
@ -105,7 +105,7 @@ version = "0.4"
version = "3.8.0"
[build-dependencies.uniffi]
version = "0.25.2"
version = "0.24.1"
features = ["build"]
default-features = false

View file

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

View file

@ -1 +1 @@
{"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"}
{"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"}

View file

@ -11,9 +11,9 @@
[package]
edition = "2021"
rust-version = "1.65"
rust-version = "1.63"
name = "glean"
version = "56.0.0"
version = "55.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 = "56.0.0"
version = "55.0.0"
[dependencies.inherent]
version = "1"

View file

@ -9,6 +9,8 @@ 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
@ -57,31 +59,6 @@ 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::*;
@ -93,7 +70,7 @@ mod test {
let _lock = lock_test();
let _t = new_glean(None, true);
let metric: EventMetric<traits::NoExtraKeys> = EventMetric::new(CommonMetricData {
let metric: EventMetric<NoExtraKeys> = EventMetric::new(CommonMetricData {
name: "event".into(),
category: "test".into(),
send_in_pings: vec!["test1".into()],
@ -219,3 +196,28 @@ 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)
}
}

View file

@ -1 +0,0 @@
{"files":{".github/workflows/build-and-test.yml":"67bf0acb023d29065648fa7e672304cd5f64b92a78af0cef5869e947bfbf3ef0",".github/workflows/style-sanity.yml":"a97b901d106a15272735fcc0e3989437f284e2d8378f3e5b1962cd12bb8f0149","CHANGELOG.md":"e1165d97c283b915d87e22f209494be39933723a0b544e725f69cfa5cef3876c","Cargo.toml":"03869d56d5a72ed9c3fae34979bf20042b8acee4b6c78c68d4e3b6418b51eadf","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":null}

View file

@ -1,42 +0,0 @@
name: Cargo build and test
on: [pull_request, workflow_dispatch]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: "--deny warnings "
jobs:
build-and-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
include:
- os: ubuntu-latest
rust: nightly
- os: ubuntu-latest
# MSRV. Not considered breaking when this has to be bumped.
# But should be mentioned in the changelog.
rust: 1.60.0
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Rust
uses: ATiltedTree/setup-rust@v1.0.4
with:
rust-version: ${{ matrix.rust }}
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: Build
run: cargo build
- name: Test
run: cargo hack --feature-powerset test
- name: Test with artificial delay
run: RUSTFLAGS+="--cfg oneshot_test_delay" cargo hack --feature-powerset test
- name: Test with loom
run: RUSTFLAGS+="--cfg loom" LOOM_MAX_BRANCHES=100000 cargo hack --feature-powerset test --test sync --test loom

View file

@ -1,55 +0,0 @@
name: Rust linting, formatting and audit
on:
pull_request:
paths:
- .github/workflows/*.yml
- '**/*.rs'
- Cargo.toml
- Cargo.lock
workflow_dispatch:
jobs:
clippy-linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.6
with:
toolchain: stable
components: clippy
override: true
- name: Clippy check
run: |
export RUSTFLAGS="--deny warnings"
time cargo clippy --verbose
check-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1.0.6
with:
toolchain: stable
components: rustfmt
override: true
- name: Check formatting
run: |
rustfmt --version
cargo fmt -- --check
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install cargo-audit
uses: actions-rs/install@v0.1.2
with:
crate: cargo-audit
version: latest
- name: Audit
run: cargo audit

View file

@ -1,62 +0,0 @@
# 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.

View file

@ -1,63 +0,0 @@
# 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"
version = "0.1.5"
authors = ["Linus Färnstrand <faern@faern.net>"]
description = """
Oneshot spsc channel with (potentially) lock-free non-blocking send and a receiver supporting
both thread blocking receive operations as well as Future based async polling.
"""
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]
criterion = "0.3"
[dev-dependencies.async-std]
version = "1"
features = ["attributes"]
[dev-dependencies.tokio]
version = "1"
features = [
"rt",
"rt-multi-thread",
"macros",
"time",
]
[features]
async = []
default = [
"std",
"async",
]
std = []

View file

@ -1,94 +0,0 @@
# 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

View file

@ -1,122 +0,0 @@
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())
});
}
}

View file

@ -1,13 +0,0 @@
#!/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

View file

@ -1,18 +0,0 @@
#[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");
}

View file

@ -1,18 +0,0 @@
#[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");
}

View file

@ -1,18 +0,0 @@
#[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");
}

View file

@ -1,18 +0,0 @@
#[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");
}

View file

@ -1,18 +0,0 @@
#[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");
}

View file

@ -1,18 +0,0 @@
#[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");
}

View file

@ -1,11 +0,0 @@
#[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");
}

View file

@ -1,11 +0,0 @@
#[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");
}

View file

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

View file

@ -1,8 +0,0 @@
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);
}

View file

@ -1,144 +0,0 @@
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 {}

File diff suppressed because it is too large Load diff

View file

@ -1,151 +0,0 @@
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);
}
}

View file

@ -1,37 +0,0 @@
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
);
}

View file

@ -1,128 +0,0 @@
#![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());
}

View file

@ -1,65 +0,0 @@
#![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);
});
}

View file

@ -1,63 +0,0 @@
#![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);
}
}

View file

@ -1,64 +0,0 @@
//! 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)
}

View file

@ -1,223 +0,0 @@
#![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();
})
}

View file

@ -1,343 +0,0 @@
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);
});
}

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -125,8 +125,7 @@ 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_lowercased = &query.keyword.to_lowercase();
let (keyword_prefix, keyword_suffix) = split_keyword(keyword_lowercased);
let (keyword_prefix, keyword_suffix) = split_keyword(&query.keyword);
let suggestions_limit = query.limit.unwrap_or(-1);
let (mut statement, params) = if query
@ -151,7 +150,7 @@ impl<'a> SuggestDao<'a> {
providers_to_sql_list(&query.providers),
),
)?, vec![
(":keyword", keyword_lowercased as &dyn ToSql),
(":keyword", &query.keyword as &dyn ToSql),
(":keyword_prefix", &keyword_prefix as &dyn ToSql),
(":suggestions_limit", &suggestions_limit as &dyn ToSql),
])
@ -168,7 +167,7 @@ impl<'a> SuggestDao<'a> {
providers_to_sql_list(&query.providers),
),
)?, vec![
(":keyword", keyword_lowercased as &dyn ToSql),
(":keyword", &query.keyword as &dyn ToSql),
(":suggestions_limit", &suggestions_limit as &dyn ToSql),
])
};
@ -211,7 +210,7 @@ impl<'a> SuggestDao<'a> {
title,
url: cooked_url,
raw_url,
full_keyword: full_keyword(keyword_lowercased, &keywords),
full_keyword: full_keyword(&query.keyword, &keywords),
icon: row.get("icon")?,
impression_url: row.get("impression_url")?,
click_url: cooked_click_url,
@ -234,7 +233,7 @@ impl<'a> SuggestDao<'a> {
Ok(Some(Suggestion::Wikipedia {
title,
url: raw_url,
full_keyword: full_keyword(keyword_lowercased, &keywords),
full_keyword: full_keyword(&query.keyword, &keywords),
icon,
}))
}

View file

@ -1691,62 +1691,6 @@ 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 {

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"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}
{"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}

View file

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

View file

@ -1 +1 @@
{"files":{"Cargo.toml":"86b07cc164a5c533ea4f7a69aab16fa3eee502ceb4c0d0296eba2afc48fbf8eb","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":"32e192430644d99babe02bede25316eee84fa154b1e5f8cfe99406c028b8c577"}
{"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"}

View file

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "uniffi"
version = "0.25.2"
version = "0.24.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.25.2"
version = "=0.24.3"
optional = true
[dependencies.uniffi_build]
version = "=0.25.2"
version = "=0.24.3"
optional = true
[dependencies.uniffi_core]
version = "=0.25.2"
version = "=0.24.3"
[dependencies.uniffi_macros]
version = "=0.25.2"
version = "=0.24.3"
[dev-dependencies.trybuild]
version = "1"

View file

@ -47,9 +47,7 @@ enum Commands {
#[clap(long = "library")]
library_mode: bool,
/// 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.
/// When `--library` is passed, only generate bindings for one crate
#[clap(long = "crate")]
crate_name: Option<String>,
@ -71,8 +69,8 @@ enum Commands {
udl_file: Utf8PathBuf,
},
/// Print a debug representation of the interface from a dynamic library
PrintRepr {
/// Print the JSON representation of the interface from a dynamic library
PrintJson {
/// Path to the library file (.so, .dll, .dylib, or .a)
path: Utf8PathBuf,
},
@ -106,13 +104,15 @@ 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::PrintRepr { path } => {
uniffi_bindgen::print_repr(&path)?;
Commands::PrintJson { path } => {
uniffi_bindgen::print_json(&path)?;
}
};
Ok(())

View file

@ -17,19 +17,13 @@ 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,
generate_component_scaffolding_for_crate, print_repr,
bindings::TargetLanguage, generate_bindings, generate_component_scaffolding, print_json,
};
#[cfg(feature = "build")]
pub use uniffi_build::{generate_scaffolding, generate_scaffolding_for_crate};
pub use uniffi_build::generate_scaffolding;
#[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]
@ -38,3 +32,8 @@ mod test {
t.compile_fail("tests/ui/*.rs");
}
}
#[cfg(feature = "cli")]
pub fn uniffi_bindgen_main() {
cli::run_main().unwrap();
}

View file

@ -1,22 +1,35 @@
error[E0277]: the trait bound `Foo: FfiConverterArc<UniFfiTag>` is not satisfied
error[E0277]: the trait bound `Foo: Interface<UniFfiTag>` is not satisfied
--> tests/ui/proc_macro_arc.rs:10:1
|
10 | #[uniffi::export]
| ^^^^^^^^^^^^^^^^^ the trait `FfiConverterArc<UniFfiTag>` is not implemented for `Foo`
| ^^^^^^^^^^^^^^^^^ the trait `Interface<UniFfiTag>` is not implemented for `Foo`
|
= help: the trait `LowerReturn<UT>` is implemented for `Arc<T>`
= help: the trait `FfiConverter<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)
error[E0277]: the trait bound `child::Foo: FfiConverterArc<UniFfiTag>` is not satisfied
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
--> tests/ui/proc_macro_arc.rs:20:5
|
20 | #[uniffi::export]
| ^^^^^^^^^^^^^^^^^ the trait `FfiConverterArc<UniFfiTag>` is not implemented for `child::Foo`
| ^^^^^^^^^^^^^^^^^ the trait `Interface<UniFfiTag>` is not implemented for `child::Foo`
|
= help: the trait `Lift<UT>` is implemented for `Arc<T>`
= help: the trait `FfiConverter<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)

File diff suppressed because one or more lines are too long

View file

@ -12,7 +12,7 @@
[package]
edition = "2021"
name = "uniffi_bindgen"
version = "0.25.2"
version = "0.24.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,14 +68,17 @@ version = "1.0"
[dependencies.serde]
version = "1"
[dependencies.serde_json]
version = "1.0.80"
[dependencies.toml]
version = "0.5"
[dependencies.uniffi_meta]
version = "=0.25.2"
version = "=0.24.3"
[dependencies.uniffi_testing]
version = "=0.25.2"
version = "=0.24.3"
[dependencies.uniffi_udl]
version = "=0.25.2"
[dependencies.weedle2]
version = "4.0.0"

View file

@ -4,9 +4,7 @@
//! Backend-agnostic askama filters
use crate::interface::{
AsType, CallbackInterface, ComponentInterface, Enum, FfiType, Function, Object, Record,
};
use crate::interface::{CallbackInterface, ComponentInterface, Enum, Function, Object, Record};
use askama::Result;
use std::fmt;
@ -69,8 +67,3 @@ 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())
}

View file

@ -10,10 +10,6 @@
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

View file

@ -2,8 +2,7 @@
* 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::CodeType;
use crate::ComponentInterface;
use crate::backend::{CodeType, Literal};
#[derive(Debug)]
pub struct CallbackInterfaceCodeType {
@ -17,14 +16,18 @@ impl CallbackInterfaceCodeType {
}
impl CodeType for CallbackInterfaceCodeType {
fn type_label(&self, ci: &ComponentInterface) -> String {
super::KotlinCodeOracle.class_name(ci, &self.id)
fn type_label(&self) -> String {
super::KotlinCodeOracle.class_name(&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()))
}

View file

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

View file

@ -2,8 +2,7 @@
* 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::CodeType;
use crate::ComponentInterface;
use crate::backend::{CodeType, Literal};
#[derive(Debug)]
pub struct CustomCodeType {
@ -17,11 +16,15 @@ impl CustomCodeType {
}
impl CodeType for CustomCodeType {
fn type_label(&self, _ci: &ComponentInterface) -> String {
fn type_label(&self) -> 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");
}
}

View file

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

View file

@ -0,0 +1,31 @@
/* 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!();
}
}

View file

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

View file

@ -2,8 +2,7 @@
* 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::CodeType;
use crate::ComponentInterface;
use crate::backend::{CodeType, Literal};
#[derive(Debug)]
pub struct ExternalCodeType {
@ -17,11 +16,15 @@ impl ExternalCodeType {
}
impl CodeType for ExternalCodeType {
fn type_label(&self, _ci: &ComponentInterface) -> String {
fn type_label(&self) -> 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");
}
}

View file

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

View file

@ -5,14 +5,13 @@
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::TemplateExpression;
use crate::backend::{CodeType, TemplateExpression};
use crate::interface::*;
use crate::BindingsConfig;
@ -20,6 +19,7 @@ mod callback_interface;
mod compounds;
mod custom;
mod enum_;
mod error;
mod executor;
mod external;
mod miscellany;
@ -28,46 +28,6 @@ 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 {
@ -106,6 +66,8 @@ 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()));
@ -163,7 +125,7 @@ impl ImportRequirement {
#[derive(Template)]
#[template(syntax = "kt", escape = "none", path = "Types.kt")]
pub struct TypeRenderer<'a> {
config: &'a Config,
kotlin_config: &'a Config,
ci: &'a ComponentInterface,
// Track included modules for the `include_once()` macro
include_once_names: RefCell<HashSet<String>>,
@ -172,9 +134,9 @@ pub struct TypeRenderer<'a> {
}
impl<'a> TypeRenderer<'a> {
fn new(config: &'a Config, ci: &'a ComponentInterface) -> Self {
fn new(kotlin_config: &'a Config, ci: &'a ComponentInterface) -> Self {
Self {
config,
kotlin_config,
ci,
include_once_names: RefCell::new(HashSet::new()),
imports: RefCell::new(BTreeSet::new()),
@ -182,13 +144,10 @@ impl<'a> TypeRenderer<'a> {
}
// Get the package name for an external type
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) {
fn external_type_package_name(&self, crate_name: &str) -> String {
match self.kotlin_config.external_packages.get(crate_name) {
Some(name) => name.clone(),
// unreachable in library mode - all deps are in our config with correct namespace.
None => format!("uniffi.{namespace}"),
None => crate_name.to_string(),
}
}
@ -236,7 +195,6 @@ pub struct KotlinWrapper<'a> {
ci: &'a ComponentInterface,
type_helper_code: String,
type_imports: BTreeSet<ImportRequirement>,
has_async_fns: bool,
}
impl<'a> KotlinWrapper<'a> {
@ -249,7 +207,6 @@ impl<'a> KotlinWrapper<'a> {
ci,
type_helper_code,
type_imports,
has_async_fns: ci.has_async_fns(),
}
}
@ -258,10 +215,6 @@ 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()
}
@ -278,20 +231,17 @@ impl KotlinCodeOracle {
type_.clone().as_type().as_codetype()
}
/// 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)
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_:?}"),
}
}
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 class name (for enums, records, errors, etc).
fn class_name(&self, nm: &str) -> String {
nm.to_string().to_upper_camel_case()
}
/// Get the idiomatic Kotlin rendering of a function name.
@ -309,6 +259,20 @@ 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)),
@ -335,16 +299,15 @@ impl KotlinCodeOracle {
FfiType::ForeignCallback => "ForeignCallback".to_string(),
FfiType::ForeignExecutorHandle => "USize".to_string(),
FfiType::ForeignExecutorCallback => "UniFfiForeignExecutorCallback".to_string(),
FfiType::RustFutureHandle => "Pointer".to_string(),
FfiType::RustFutureContinuationCallback => {
"UniFffiRustFutureContinuationCallbackType".to_string()
FfiType::FutureCallback { return_type } => {
format!("UniFfiFutureCallback{}", Self::ffi_type_label(return_type))
}
FfiType::RustFutureContinuationData => "USize".to_string(),
FfiType::FutureCallbackData => "USize".to_string(),
}
}
}
trait AsCodeType {
pub trait AsCodeType {
fn as_codetype(&self) -> Box<dyn CodeType>;
}
@ -375,89 +338,128 @@ impl<T: AsType> AsCodeType for T {
Type::Timestamp => Box::new(miscellany::TimestampCodeType),
Type::Duration => Box::new(miscellany::DurationCodeType),
Type::Enum { name, .. } => Box::new(enum_::EnumCodeType::new(name)),
Type::Enum(id) => Box::new(enum_::EnumCodeType::new(id)),
Type::Object { name, .. } => Box::new(object::ObjectCodeType::new(name)),
Type::Record { name, .. } => Box::new(record::RecordCodeType::new(name)),
Type::CallbackInterface { name, .. } => {
Box::new(callback_interface::CallbackInterfaceCodeType::new(name))
Type::Record(id) => Box::new(record::RecordCodeType::new(id)),
Type::CallbackInterface(id) => {
Box::new(callback_interface::CallbackInterfaceCodeType::new(id))
}
Type::ForeignExecutor => Box::new(executor::ForeignExecutorCodeType),
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::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::External { name, .. } => Box::new(external::ExternalCodeType::new(name)),
Type::Custom { name, .. } => Box::new(custom::CustomCodeType::new(name)),
}
}
}
mod filters {
pub mod filters {
use super::*;
pub use crate::backend::filters::*;
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 type_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().type_label())
}
pub(super) fn canonical_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub fn canonical_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().canonical_name())
}
pub(super) fn ffi_converter_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub fn ffi_converter_name(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().ffi_converter_name())
}
pub(super) fn lower_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub fn lower_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!(
"{}.lower",
as_ct.as_codetype().ffi_converter_name()
))
}
pub(super) fn allocation_size_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub fn allocation_size_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!(
"{}.allocationSize",
as_ct.as_codetype().ffi_converter_name()
))
}
pub(super) fn write_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub fn write_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!(
"{}.write",
as_ct.as_codetype().ffi_converter_name()
))
}
pub(super) fn lift_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub fn lift_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
Ok(format!("{}.lift", as_ct.as_codetype().ffi_converter_name()))
}
pub(super) fn read_fn(as_ct: &impl AsCodeType) -> Result<String, askama::Error> {
pub 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 AsType,
ci: &ComponentInterface,
as_ct: &impl AsCodeType,
) -> Result<String, askama::Error> {
Ok(as_ct.as_codetype().literal(literal, ci))
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_))
}
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))
@ -468,55 +470,39 @@ 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()))
}
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.
pub fn enum_variant(v: &Variant) -> Result<impl AsCodeType, askama::Error> {
Ok(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) }}"
))
/// 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_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} }}"))
/// 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_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) }}"
))
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())
}
/// Remove the "`" chars we put around function/variable names

View file

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

View file

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

View file

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

View file

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

View file

@ -1,44 +0,0 @@
// 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)
}
}

View file

@ -0,0 +1,43 @@
// 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 %}

View file

@ -35,7 +35,7 @@ internal class ConcurrentHandleMap<T>(
}
interface ForeignCallback : com.sun.jna.Callback {
public fun callback(handle: Handle, method: Int, argsData: Pointer, argsLen: Int, outBuf: RustBufferByReference): Int
public fun invoke(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,

View file

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

View file

@ -1,4 +1,4 @@
{%- match config.custom_types.get(name.as_str()) %}
{%- match kotlin_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(ci) }}
public typealias {{ name }} = {{ builtin|type_name }}
public typealias {{ ffi_converter_name }} = {{ builtin|ffi_converter_name }}
{%- when Some with (config) %}
{%- let ffi_type_name=builtin|ffi_type|ffi_type_name_by_value %}
{%- let ffi_type_name=builtin.ffi_type().borrow()|ffi_type_name_by_value %}
{# When the config specifies a different type name, create a typealias for it #}
{%- match config.type_name %}

View file

@ -11,7 +11,6 @@ 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 }}> {
@ -33,15 +32,13 @@ 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|type_name(ci) }} : {{ type_name }}()
object {{ variant|enum_variant|type_name }} : {{ type_name }}()
{% else -%}
data class {{ variant|type_name(ci) }}(
data class {{ variant|enum_variant|type_name }}(
{% for field in variant.fields() -%}
val {{ field.name()|var_name }}: {{ field|type_name(ci) }}{% if loop.last %}{% else %}, {% endif %}
val {{ field.name()|var_name }}: {{ field|type_name}}{% if loop.last %}{% else %}, {% endif %}
{% endfor -%}
) : {{ type_name }}() {
companion object
}
) : {{ type_name }}()
{%- endif %}
{% endfor %}
@ -50,7 +47,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|type_name(ci) }} -> {
is {{ type_name }}.{{ variant|enum_variant|type_name }} -> {
{%- if variant.has_fields() %}
{% call kt::destroy_fields(variant) %}
{% else -%}
@ -61,14 +58,13 @@ 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|type_name(ci) }}{% if variant.has_fields() %}(
{{ loop.index }} -> {{ type_name }}.{{ variant|enum_variant|type_name }}{% if variant.has_fields() %}(
{% for field in variant.fields() -%}
{{ field|read_fn }}(buf),
{% endfor -%}
@ -80,7 +76,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|type_name(ci) }} -> {
is {{ type_name }}.{{ variant|enum_variant|type_name }} -> {
// Add the size for the Int that specifies the variant plus the size needed for all fields
(
4
@ -95,7 +91,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|type_name(ci) }} -> {
is {{ type_name }}.{{ variant|enum_variant|type_name }} -> {
buf.putInt({{ loop.index }})
{%- for field in variant.fields() %}
{{ field|write_fn }}(value.{{ field.name()|var_name }}, buf)

View file

@ -1,13 +1,13 @@
{%- let type_name = type_|type_name(ci) %}
{%- let ffi_converter_name = type_|ffi_converter_name %}
{%- let canonical_type_name = type_|canonical_name %}
{%- let type_name = type_|error_type_name %}
{%- let ffi_converter_name = type_|error_ffi_converter_name %}
{%- let canonical_type_name = type_|error_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_name }}(message: String) : {{ type_name }}(message)
class {{ variant|error_variant|type_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_name %}
{%- let variant_name = variant|error_variant|type_name %}
class {{ variant_name }}(
{% for field in variant.fields() -%}
val {{ field.name()|var_name }}: {{ field|type_name(ci) }}{% if loop.last %}{% else %}, {% endif %}
val {{ field.name()|var_name }}: {{ field|type_name}}{% 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_name }} -> {
is {{ type_name }}.{{ variant|error_variant|type_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_name }}({{ Type::String.borrow()|read_fn }}(buf))
{{ loop.index }} -> {{ type_name }}.{{ variant|error_variant|type_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_name }}({% if variant.has_fields() %}
{{ loop.index }} -> {{ type_name }}.{{ variant|error_variant|type_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_name }} -> (
is {{ type_name }}.{{ variant|error_variant|type_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_name }} -> {
is {{ type_name }}.{{ variant|error_variant|type_name }} -> {
buf.putInt({{ loop.index }})
{%- for field in variant.fields() %}
{{ field|write_fn }}(value.{{ field.name()|var_name }}, buf)

View file

@ -1,4 +1,4 @@
{%- let package_name=self.external_type_package_name(module_path, namespace) %}
{%- let package_name=self.external_type_package_name(crate_name) %}
{%- 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) %}

View file

@ -1,42 +1,24 @@
{{ 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 callback(rustTaskData: Pointer?, statusCode: Byte)
fun invoke(rustTaskData: Pointer?)
}
internal object UniFfiForeignExecutorCallback : com.sun.jna.Callback {
fun callback(handle: USize, delayMs: Int, rustTask: UniFfiRustTaskCallback?, rustTaskData: Pointer?) : Byte {
object UniFfiForeignExecutorCallback : com.sun.jna.Callback {
internal fun invoke(handle: USize, delayMs: Int, rustTask: UniFfiRustTaskCallback?, rustTaskData: Pointer?) {
if (rustTask == null) {
FfiConverterForeignExecutor.drop(handle)
return UNIFFI_FOREIGN_EXECUTOR_CALLBACK_SUCCESS
} else {
val coroutineScope = FfiConverterForeignExecutor.lift(handle)
if (coroutineScope.isActive) {
val job = coroutineScope.launch {
if (delayMs > 0) {
delay(delayMs.toLong())
}
rustTask.callback(rustTaskData, UNIFFI_RUST_TASK_CALLBACK_SUCCESS)
coroutineScope.launch {
if (delayMs > 0) {
delay(delayMs.toLong())
}
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
rustTask.invoke(rustTaskData)
}
}
}
@ -50,12 +32,7 @@ public object FfiConverterForeignExecutor: FfiConverter<CoroutineScope, USize> {
}
internal fun register(lib: _UniFFILib) {
{%- 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 %}
lib.uniffi_foreign_executor_callback_set(UniFfiForeignExecutorCallback)
}
// Number of live handles, exposed so we can test the memory management

View file

@ -77,8 +77,6 @@ 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()
@ -150,12 +148,7 @@ internal class UniFfiHandleMap<T: Any> {
return map.get(handle)
}
fun remove(handle: USize): T? {
return map.remove(handle)
fun remove(handle: USize) {
map.remove(handle)
}
}
// FFI type for Rust future continuations
internal interface UniFffiRustFutureContinuationCallbackType : com.sun.jna.Callback {
fun callback(continuationHandle: USize, pollResult: Short);
}

Some files were not shown because too many files have changed in this diff Show more