mirror of
https://github.com/aljazceru/react-native-pubky.git
synced 2025-12-17 22:54:29 +01:00
fix: fix name conflict
Resolves name conflicts with other native modules. Bump version to 0.1.1.
This commit is contained in:
306
rust/Cargo.lock
generated
306
rust/Cargo.lock
generated
@@ -4,18 +4,18 @@ version = 3
|
||||
|
||||
[[package]]
|
||||
name = "addr2line"
|
||||
version = "0.22.0"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678"
|
||||
checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375"
|
||||
dependencies = [
|
||||
"gimli",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "adler"
|
||||
version = "1.0.2"
|
||||
name = "adler2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
|
||||
|
||||
[[package]]
|
||||
name = "aead"
|
||||
@@ -87,9 +87,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.87"
|
||||
version = "1.0.88"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8"
|
||||
checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356"
|
||||
|
||||
[[package]]
|
||||
name = "argon2"
|
||||
@@ -105,9 +105,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "arrayref"
|
||||
version = "0.3.8"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a"
|
||||
checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
@@ -277,25 +277,19 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "backtrace"
|
||||
version = "0.3.73"
|
||||
version = "0.3.74"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a"
|
||||
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
|
||||
dependencies = [
|
||||
"addr2line",
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base16ct"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf"
|
||||
|
||||
[[package]]
|
||||
name = "base32"
|
||||
version = "0.5.1"
|
||||
@@ -329,12 +323,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bech32"
|
||||
version = "0.10.0-beta"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98f7eed2b2781a6f0b5c903471d48e15f56fb4e1165df8a9a2337fd1a59d45ea"
|
||||
|
||||
[[package]]
|
||||
name = "bincode"
|
||||
version = "1.3.3"
|
||||
@@ -344,71 +332,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bip32"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa13fae8b6255872fd86f7faf4b41168661d7d78609f7bfe6771b85c6739a15b"
|
||||
dependencies = [
|
||||
"bs58",
|
||||
"hmac",
|
||||
"k256",
|
||||
"once_cell",
|
||||
"pbkdf2",
|
||||
"rand_core",
|
||||
"ripemd",
|
||||
"sha2",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bip39"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93f2635620bf0b9d4576eb7bb9a38a55df78bd1205d26fa994b25911a69f212f"
|
||||
dependencies = [
|
||||
"bitcoin_hashes 0.11.0",
|
||||
"serde",
|
||||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitcoin"
|
||||
version = "0.31.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c85783c2fe40083ea54a33aa2f0ba58831d90fcd190f5bdc47e74e84d2a96ae"
|
||||
dependencies = [
|
||||
"bech32",
|
||||
"bitcoin-internals",
|
||||
"bitcoin_hashes 0.13.0",
|
||||
"hex-conservative",
|
||||
"hex_lit",
|
||||
"secp256k1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitcoin-internals"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb"
|
||||
|
||||
[[package]]
|
||||
name = "bitcoin_hashes"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4"
|
||||
|
||||
[[package]]
|
||||
name = "bitcoin_hashes"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b"
|
||||
dependencies = [
|
||||
"bitcoin-internals",
|
||||
"hex-conservative",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
@@ -449,15 +372,6 @@ dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bs58"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4"
|
||||
dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.16.0"
|
||||
@@ -671,18 +585,6 @@ version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-bigint"
|
||||
version = "0.5.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"rand_core",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
@@ -762,7 +664,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"const-oid",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
@@ -812,19 +713,6 @@ version = "1.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
|
||||
|
||||
[[package]]
|
||||
name = "ecdsa"
|
||||
version = "0.16.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca"
|
||||
dependencies = [
|
||||
"der",
|
||||
"digest",
|
||||
"elliptic-curve",
|
||||
"rfc6979",
|
||||
"signature",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519"
|
||||
version = "2.2.3"
|
||||
@@ -851,24 +739,6 @@ dependencies = [
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "elliptic-curve"
|
||||
version = "0.13.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"crypto-bigint",
|
||||
"digest",
|
||||
"ff",
|
||||
"generic-array",
|
||||
"group",
|
||||
"rand_core",
|
||||
"sec1",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-io"
|
||||
version = "0.4.0"
|
||||
@@ -887,16 +757,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "ff"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fiat-crypto"
|
||||
version = "0.2.9"
|
||||
@@ -1054,9 +914,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.29.0"
|
||||
version = "0.31.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd"
|
||||
checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64"
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
@@ -1075,17 +935,6 @@ dependencies = [
|
||||
"scroll",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "group"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63"
|
||||
dependencies = [
|
||||
"ff",
|
||||
"rand_core",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hash32"
|
||||
version = "0.2.1"
|
||||
@@ -1201,27 +1050,6 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "hex-conservative"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20"
|
||||
|
||||
[[package]]
|
||||
name = "hex_lit"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3011d1213f159867b13cfd6ac92d2cd5f1345762c63be3554e84092d85a50bbd"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "1.1.0"
|
||||
@@ -1392,18 +1220,6 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "k256"
|
||||
version = "0.13.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"ecdsa",
|
||||
"elliptic-curve",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
@@ -1530,11 +1346,11 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.7.4"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
|
||||
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
|
||||
dependencies = [
|
||||
"adler",
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1595,9 +1411,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
version = "1.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe"
|
||||
|
||||
[[package]]
|
||||
name = "oneshot-uniffi"
|
||||
@@ -1667,16 +1483,6 @@ version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"hmac",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
@@ -1760,7 +1566,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
[[package]]
|
||||
name = "pkarr"
|
||||
version = "2.2.0"
|
||||
source = "git+https://github.com/Pubky/pkarr?branch=v3#17975121c809d97dcad907fbb2ffc782e994d270"
|
||||
source = "git+https://github.com/Pubky/pkarr?branch=v3#2d1abb4d28624c298a38996ee3f40914676cd5d1"
|
||||
dependencies = [
|
||||
"base32",
|
||||
"bytes",
|
||||
@@ -2016,15 +1822,11 @@ dependencies = [
|
||||
name = "react_native_pubky"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bip32",
|
||||
"bip39",
|
||||
"bitcoin",
|
||||
"hex",
|
||||
"pkarr",
|
||||
"pubky",
|
||||
"pubky-common",
|
||||
"pubky_homeserver",
|
||||
"secp256k1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
@@ -2035,9 +1837,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.3"
|
||||
version = "0.5.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
|
||||
checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
@@ -2141,16 +1943,6 @@ dependencies = [
|
||||
"windows-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rfc6979"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2"
|
||||
dependencies = [
|
||||
"hmac",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.8"
|
||||
@@ -2166,15 +1958,6 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ripemd"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.24"
|
||||
@@ -2198,9 +1981,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustls"
|
||||
version = "0.23.12"
|
||||
version = "0.23.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
|
||||
checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"ring",
|
||||
@@ -2284,38 +2067,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sec1"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc"
|
||||
dependencies = [
|
||||
"base16ct",
|
||||
"der",
|
||||
"generic-array",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "secp256k1"
|
||||
version = "0.28.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d24b59d129cdadea20aea4fb2352fa053712e5d713eee47d700cd4b2bc002f10"
|
||||
dependencies = [
|
||||
"bitcoin_hashes 0.13.0",
|
||||
"secp256k1-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "secp256k1-sys"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5d1746aae42c19d583c3c1a8c646bfad910498e2051c551a7f2e3c0c9fbb7eb"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "self_cell"
|
||||
version = "1.0.4"
|
||||
@@ -2471,7 +2222,6 @@ version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
@@ -2918,15 +2668,15 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.22"
|
||||
version = "0.1.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
|
||||
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
@@ -6,21 +6,20 @@ edition = "2021"
|
||||
|
||||
[lib]
|
||||
crate_type = ["cdylib", "staticlib"]
|
||||
name = "mobile"
|
||||
name = "pubkymobile"
|
||||
|
||||
[net]
|
||||
git-fetch-with-cli = true
|
||||
|
||||
[dependencies]
|
||||
uniffi = { version = "0.25.3", features = [ "cli" ] }
|
||||
bitcoin = "0.31.1"
|
||||
bip39 = "2.0.0"
|
||||
secp256k1 = "0.28.2"
|
||||
bip32 = "0.5.1"
|
||||
serde_json = "1.0.114"
|
||||
hex = "0.4.3"
|
||||
sha2 = "0.10.8"
|
||||
serde = { version = "^1.0.209", features = ["derive"] }
|
||||
tokio = "1.40.0"
|
||||
url = "2.5.2"
|
||||
pkarr = { git = "https://github.com/Pubky/pkarr", branch = "v3", package = "pkarr", features = ["async", "rand"] }
|
||||
pubky = { version = "0.1.0", path = "pubky/pubky" }
|
||||
pubky-common = { version = "0.1.0", path = "pubky/pubky-common" }
|
||||
pubky_homeserver = { version = "0.1.0", path = "pubky/pubky-homeserver" }
|
||||
tokio = "1.40.0"
|
||||
url = "2.5.2"
|
||||
|
||||
@@ -1,688 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
|
||||
@file:Suppress("NAME_SHADOWING")
|
||||
|
||||
package uniffi.mobile;
|
||||
|
||||
// Common helper code.
|
||||
//
|
||||
// Ideally this would live in a separate .kt file where it can be unittested etc
|
||||
// in isolation, and perhaps even published as a re-useable package.
|
||||
//
|
||||
// However, it's important that the details of how this helper code works (e.g. the
|
||||
// way that different builtin types are passed across the FFI) exactly match what's
|
||||
// expected by the Rust code on the other side of the interface. In practice right
|
||||
// now that means coming from the exact some version of `uniffi` that was used to
|
||||
// compile the Rust component. The easiest way to ensure this is to bundle the Kotlin
|
||||
// helpers directly inline like we're doing here.
|
||||
|
||||
import com.sun.jna.Library
|
||||
import com.sun.jna.IntegerType
|
||||
import com.sun.jna.Native
|
||||
import com.sun.jna.Pointer
|
||||
import com.sun.jna.Structure
|
||||
import com.sun.jna.Callback
|
||||
import com.sun.jna.ptr.*
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
import java.nio.CharBuffer
|
||||
import java.nio.charset.CodingErrorAction
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import kotlin.coroutines.resume
|
||||
import kotlinx.coroutines.CancellableContinuation
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
|
||||
// This is a helper for safely working with byte buffers returned from the Rust code.
|
||||
// A rust-owned buffer is represented by its capacity, its current length, and a
|
||||
// pointer to the underlying data.
|
||||
|
||||
@Structure.FieldOrder("capacity", "len", "data")
|
||||
open class RustBuffer : Structure() {
|
||||
@JvmField var capacity: Int = 0
|
||||
@JvmField var len: Int = 0
|
||||
@JvmField var data: Pointer? = null
|
||||
|
||||
class ByValue: RustBuffer(), Structure.ByValue
|
||||
class ByReference: RustBuffer(), Structure.ByReference
|
||||
|
||||
companion object {
|
||||
internal fun alloc(size: Int = 0) = rustCall() { status ->
|
||||
_UniFFILib.INSTANCE.ffi_mobile_rustbuffer_alloc(size, status)
|
||||
}.also {
|
||||
if(it.data == null) {
|
||||
throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})")
|
||||
}
|
||||
}
|
||||
|
||||
internal fun create(capacity: Int, len: Int, data: Pointer?): RustBuffer.ByValue {
|
||||
var buf = RustBuffer.ByValue()
|
||||
buf.capacity = capacity
|
||||
buf.len = len
|
||||
buf.data = data
|
||||
return buf
|
||||
}
|
||||
|
||||
internal fun free(buf: RustBuffer.ByValue) = rustCall() { status ->
|
||||
_UniFFILib.INSTANCE.ffi_mobile_rustbuffer_free(buf, status)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionThrown")
|
||||
fun asByteBuffer() =
|
||||
this.data?.getByteBuffer(0, this.len.toLong())?.also {
|
||||
it.order(ByteOrder.BIG_ENDIAN)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The equivalent of the `*mut RustBuffer` type.
|
||||
* Required for callbacks taking in an out pointer.
|
||||
*
|
||||
* Size is the sum of all values in the struct.
|
||||
*/
|
||||
class RustBufferByReference : ByReference(16) {
|
||||
/**
|
||||
* Set the pointed-to `RustBuffer` to the given value.
|
||||
*/
|
||||
fun setValue(value: RustBuffer.ByValue) {
|
||||
// NOTE: The offsets are as they are in the C-like struct.
|
||||
val pointer = getPointer()
|
||||
pointer.setInt(0, value.capacity)
|
||||
pointer.setInt(4, value.len)
|
||||
pointer.setPointer(8, value.data)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a `RustBuffer.ByValue` from this reference.
|
||||
*/
|
||||
fun getValue(): RustBuffer.ByValue {
|
||||
val pointer = getPointer()
|
||||
val value = RustBuffer.ByValue()
|
||||
value.writeField("capacity", pointer.getInt(0))
|
||||
value.writeField("len", pointer.getInt(4))
|
||||
value.writeField("data", pointer.getPointer(8))
|
||||
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
// This is a helper for safely passing byte references into the rust code.
|
||||
// It's not actually used at the moment, because there aren't many things that you
|
||||
// can take a direct pointer to in the JVM, and if we're going to copy something
|
||||
// then we might as well copy it into a `RustBuffer`. But it's here for API
|
||||
// completeness.
|
||||
|
||||
@Structure.FieldOrder("len", "data")
|
||||
open class ForeignBytes : Structure() {
|
||||
@JvmField var len: Int = 0
|
||||
@JvmField var data: Pointer? = null
|
||||
|
||||
class ByValue : ForeignBytes(), Structure.ByValue
|
||||
}
|
||||
// The FfiConverter interface handles converter types to and from the FFI
|
||||
//
|
||||
// All implementing objects should be public to support external types. When a
|
||||
// type is external we need to import it's FfiConverter.
|
||||
public interface FfiConverter<KotlinType, FfiType> {
|
||||
// Convert an FFI type to a Kotlin type
|
||||
fun lift(value: FfiType): KotlinType
|
||||
|
||||
// Convert an Kotlin type to an FFI type
|
||||
fun lower(value: KotlinType): FfiType
|
||||
|
||||
// Read a Kotlin type from a `ByteBuffer`
|
||||
fun read(buf: ByteBuffer): KotlinType
|
||||
|
||||
// Calculate bytes to allocate when creating a `RustBuffer`
|
||||
//
|
||||
// This must return at least as many bytes as the write() function will
|
||||
// write. It can return more bytes than needed, for example when writing
|
||||
// Strings we can't know the exact bytes needed until we the UTF-8
|
||||
// encoding, so we pessimistically allocate the largest size possible (3
|
||||
// bytes per codepoint). Allocating extra bytes is not really a big deal
|
||||
// because the `RustBuffer` is short-lived.
|
||||
fun allocationSize(value: KotlinType): Int
|
||||
|
||||
// Write a Kotlin type to a `ByteBuffer`
|
||||
fun write(value: KotlinType, buf: ByteBuffer)
|
||||
|
||||
// Lower a value into a `RustBuffer`
|
||||
//
|
||||
// This method lowers a value into a `RustBuffer` rather than the normal
|
||||
// FfiType. It's used by the callback interface code. Callback interface
|
||||
// returns are always serialized into a `RustBuffer` regardless of their
|
||||
// normal FFI type.
|
||||
fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue {
|
||||
val rbuf = RustBuffer.alloc(allocationSize(value))
|
||||
try {
|
||||
val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity.toLong()).also {
|
||||
it.order(ByteOrder.BIG_ENDIAN)
|
||||
}
|
||||
write(value, bbuf)
|
||||
rbuf.writeField("len", bbuf.position())
|
||||
return rbuf
|
||||
} catch (e: Throwable) {
|
||||
RustBuffer.free(rbuf)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
// Lift a value from a `RustBuffer`.
|
||||
//
|
||||
// This here mostly because of the symmetry with `lowerIntoRustBuffer()`.
|
||||
// It's currently only used by the `FfiConverterRustBuffer` class below.
|
||||
fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType {
|
||||
val byteBuf = rbuf.asByteBuffer()!!
|
||||
try {
|
||||
val item = read(byteBuf)
|
||||
if (byteBuf.hasRemaining()) {
|
||||
throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!")
|
||||
}
|
||||
return item
|
||||
} finally {
|
||||
RustBuffer.free(rbuf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FfiConverter that uses `RustBuffer` as the FfiType
|
||||
public interface FfiConverterRustBuffer<KotlinType>: FfiConverter<KotlinType, RustBuffer.ByValue> {
|
||||
override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value)
|
||||
override fun lower(value: KotlinType) = lowerIntoRustBuffer(value)
|
||||
}
|
||||
// A handful of classes and functions to support the generated data structures.
|
||||
// This would be a good candidate for isolating in its own ffi-support lib.
|
||||
// Error runtime.
|
||||
@Structure.FieldOrder("code", "error_buf")
|
||||
internal open class RustCallStatus : Structure() {
|
||||
@JvmField var code: Byte = 0
|
||||
@JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()
|
||||
|
||||
class ByValue: RustCallStatus(), Structure.ByValue
|
||||
|
||||
fun isSuccess(): Boolean {
|
||||
return code == 0.toByte()
|
||||
}
|
||||
|
||||
fun isError(): Boolean {
|
||||
return code == 1.toByte()
|
||||
}
|
||||
|
||||
fun isPanic(): Boolean {
|
||||
return code == 2.toByte()
|
||||
}
|
||||
}
|
||||
|
||||
class InternalException(message: String) : Exception(message)
|
||||
|
||||
// Each top-level error class has a companion object that can lift the error from the call status's rust buffer
|
||||
interface CallStatusErrorHandler<E> {
|
||||
fun lift(error_buf: RustBuffer.ByValue): E;
|
||||
}
|
||||
|
||||
// Helpers for calling Rust
|
||||
// In practice we usually need to be synchronized to call this safely, so it doesn't
|
||||
// synchronize itself
|
||||
|
||||
// Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
|
||||
private inline fun <U, E: Exception> rustCallWithError(errorHandler: CallStatusErrorHandler<E>, callback: (RustCallStatus) -> U): U {
|
||||
var status = RustCallStatus();
|
||||
val return_value = callback(status)
|
||||
checkCallStatus(errorHandler, status)
|
||||
return return_value
|
||||
}
|
||||
|
||||
// Check RustCallStatus and throw an error if the call wasn't successful
|
||||
private fun<E: Exception> checkCallStatus(errorHandler: CallStatusErrorHandler<E>, status: RustCallStatus) {
|
||||
if (status.isSuccess()) {
|
||||
return
|
||||
} else if (status.isError()) {
|
||||
throw errorHandler.lift(status.error_buf)
|
||||
} else if (status.isPanic()) {
|
||||
// when the rust code sees a panic, it tries to construct a rustbuffer
|
||||
// with the message. but if that code panics, then it just sends back
|
||||
// an empty buffer.
|
||||
if (status.error_buf.len > 0) {
|
||||
throw InternalException(FfiConverterString.lift(status.error_buf))
|
||||
} else {
|
||||
throw InternalException("Rust panic")
|
||||
}
|
||||
} else {
|
||||
throw InternalException("Unknown rust call status: $status.code")
|
||||
}
|
||||
}
|
||||
|
||||
// CallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR
|
||||
object NullCallStatusErrorHandler: CallStatusErrorHandler<InternalException> {
|
||||
override fun lift(error_buf: RustBuffer.ByValue): InternalException {
|
||||
RustBuffer.free(error_buf)
|
||||
return InternalException("Unexpected CALL_ERROR")
|
||||
}
|
||||
}
|
||||
|
||||
// Call a rust function that returns a plain value
|
||||
private inline fun <U> rustCall(callback: (RustCallStatus) -> U): U {
|
||||
return rustCallWithError(NullCallStatusErrorHandler, callback);
|
||||
}
|
||||
|
||||
// IntegerType that matches Rust's `usize` / C's `size_t`
|
||||
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()
|
||||
|
||||
fun writeToBuffer(buf: ByteBuffer) {
|
||||
// Make sure we always write usize integers using native byte-order, since they may be
|
||||
// casted to pointer values
|
||||
buf.order(ByteOrder.nativeOrder())
|
||||
try {
|
||||
when (Native.SIZE_T_SIZE) {
|
||||
4 -> buf.putInt(toInt())
|
||||
8 -> buf.putLong(toLong())
|
||||
else -> throw RuntimeException("Invalid SIZE_T_SIZE: ${Native.SIZE_T_SIZE}")
|
||||
}
|
||||
} finally {
|
||||
buf.order(ByteOrder.BIG_ENDIAN)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val size: Int
|
||||
get() = Native.SIZE_T_SIZE
|
||||
|
||||
fun readFromBuffer(buf: ByteBuffer) : USize {
|
||||
// Make sure we always read usize integers using native byte-order, since they may be
|
||||
// casted from pointer values
|
||||
buf.order(ByteOrder.nativeOrder())
|
||||
try {
|
||||
return when (Native.SIZE_T_SIZE) {
|
||||
4 -> USize(buf.getInt().toLong())
|
||||
8 -> USize(buf.getLong())
|
||||
else -> throw RuntimeException("Invalid SIZE_T_SIZE: ${Native.SIZE_T_SIZE}")
|
||||
}
|
||||
} finally {
|
||||
buf.order(ByteOrder.BIG_ENDIAN)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Map handles to objects
|
||||
//
|
||||
// This is used when the Rust code expects an opaque pointer to represent some foreign object.
|
||||
// Normally we would pass a pointer to the object, but JNA doesn't support getting a pointer from an
|
||||
// object reference , nor does it support leaking a reference to Rust.
|
||||
//
|
||||
// Instead, this class maps USize values to objects so that we can pass a pointer-sized type to
|
||||
// Rust when it needs an opaque pointer.
|
||||
//
|
||||
// TODO: refactor callbacks to use this class
|
||||
internal class UniFfiHandleMap<T: Any> {
|
||||
private val map = ConcurrentHashMap<USize, T>()
|
||||
// Use AtomicInteger for our counter, since we may be on a 32-bit system. 4 billion possible
|
||||
// values seems like enough. If somehow we generate 4 billion handles, then this will wrap
|
||||
// around back to zero and we can assume the first handle generated will have been dropped by
|
||||
// then.
|
||||
private val counter = java.util.concurrent.atomic.AtomicInteger(0)
|
||||
|
||||
val size: Int
|
||||
get() = map.size
|
||||
|
||||
fun insert(obj: T): USize {
|
||||
val handle = USize(counter.getAndAdd(1).toLong())
|
||||
map.put(handle, obj)
|
||||
return handle
|
||||
}
|
||||
|
||||
fun get(handle: USize): T? {
|
||||
return map.get(handle)
|
||||
}
|
||||
|
||||
fun remove(handle: USize): T? {
|
||||
return map.remove(handle)
|
||||
}
|
||||
}
|
||||
|
||||
// FFI type for Rust future continuations
|
||||
internal interface UniFffiRustFutureContinuationCallbackType : com.sun.jna.Callback {
|
||||
fun callback(continuationHandle: USize, pollResult: Short);
|
||||
}
|
||||
|
||||
// Contains loading, initialization code,
|
||||
// and the FFI Function declarations in a com.sun.jna.Library.
|
||||
@Synchronized
|
||||
private fun findLibraryName(componentName: String): String {
|
||||
val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride")
|
||||
if (libOverride != null) {
|
||||
return libOverride
|
||||
}
|
||||
return "mobile"
|
||||
}
|
||||
|
||||
private inline fun <reified Lib : Library> loadIndirect(
|
||||
componentName: String
|
||||
): Lib {
|
||||
return Native.load<Lib>(findLibraryName(componentName), Lib::class.java)
|
||||
}
|
||||
|
||||
// A JNA Library to expose the extern-C FFI definitions.
|
||||
// This is an implementation detail which will be called internally by the public API.
|
||||
|
||||
internal interface _UniFFILib : Library {
|
||||
companion object {
|
||||
internal val INSTANCE: _UniFFILib by lazy {
|
||||
loadIndirect<_UniFFILib>(componentName = "mobile")
|
||||
.also { lib: _UniFFILib ->
|
||||
uniffiCheckContractApiVersion(lib)
|
||||
uniffiCheckApiChecksums(lib)
|
||||
uniffiRustFutureContinuationCallback.register(lib)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun uniffi_mobile_fn_func_auth(`url`: RustBuffer.ByValue,`secretKey`: RustBuffer.ByValue,
|
||||
): Pointer
|
||||
fun uniffi_mobile_fn_func_myexample(_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun ffi_mobile_rustbuffer_alloc(`size`: Int,_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun ffi_mobile_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun ffi_mobile_rustbuffer_free(`buf`: RustBuffer.ByValue,_uniffi_out_err: RustCallStatus,
|
||||
): Unit
|
||||
fun ffi_mobile_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Int,_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun ffi_mobile_rust_future_continuation_callback_set(`callback`: UniFffiRustFutureContinuationCallbackType,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_poll_u8(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_u8(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_u8(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_u8(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Byte
|
||||
fun ffi_mobile_rust_future_poll_i8(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_i8(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_i8(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_i8(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Byte
|
||||
fun ffi_mobile_rust_future_poll_u16(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_u16(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_u16(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_u16(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Short
|
||||
fun ffi_mobile_rust_future_poll_i16(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_i16(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_i16(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_i16(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Short
|
||||
fun ffi_mobile_rust_future_poll_u32(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_u32(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_u32(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_u32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Int
|
||||
fun ffi_mobile_rust_future_poll_i32(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_i32(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_i32(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_i32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Int
|
||||
fun ffi_mobile_rust_future_poll_u64(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_u64(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_u64(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_u64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Long
|
||||
fun ffi_mobile_rust_future_poll_i64(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_i64(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_i64(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_i64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Long
|
||||
fun ffi_mobile_rust_future_poll_f32(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_f32(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_f32(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_f32(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Float
|
||||
fun ffi_mobile_rust_future_poll_f64(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_f64(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_f64(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_f64(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Double
|
||||
fun ffi_mobile_rust_future_poll_pointer(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_pointer(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_pointer(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_pointer(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Pointer
|
||||
fun ffi_mobile_rust_future_poll_rust_buffer(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_rust_buffer(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_rust_buffer(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_rust_buffer(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): RustBuffer.ByValue
|
||||
fun ffi_mobile_rust_future_poll_void(`handle`: Pointer,`uniffiCallback`: USize,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_cancel_void(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_free_void(`handle`: Pointer,
|
||||
): Unit
|
||||
fun ffi_mobile_rust_future_complete_void(`handle`: Pointer,_uniffi_out_err: RustCallStatus,
|
||||
): Unit
|
||||
fun uniffi_mobile_checksum_func_auth(
|
||||
): Short
|
||||
fun uniffi_mobile_checksum_func_myexample(
|
||||
): Short
|
||||
fun ffi_mobile_uniffi_contract_version(
|
||||
): Int
|
||||
|
||||
}
|
||||
|
||||
private fun uniffiCheckContractApiVersion(lib: _UniFFILib) {
|
||||
// Get the bindings contract version from our ComponentInterface
|
||||
val bindings_contract_version = 24
|
||||
// Get the scaffolding contract version by calling the into the dylib
|
||||
val scaffolding_contract_version = lib.ffi_mobile_uniffi_contract_version()
|
||||
if (bindings_contract_version != scaffolding_contract_version) {
|
||||
throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
|
||||
if (lib.uniffi_mobile_checksum_func_auth() != 55720.toShort()) {
|
||||
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
if (lib.uniffi_mobile_checksum_func_myexample() != 65225.toShort()) {
|
||||
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
}
|
||||
|
||||
// Async support
|
||||
// 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.ffi_mobile_rust_future_continuation_callback_set(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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Public interface members begin here.
|
||||
|
||||
|
||||
public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
|
||||
// Note: we don't inherit from FfiConverterRustBuffer, because we use a
|
||||
// special encoding when lowering/lifting. We can use `RustBuffer.len` to
|
||||
// store our length and avoid writing it out to the buffer.
|
||||
override fun lift(value: RustBuffer.ByValue): String {
|
||||
try {
|
||||
val byteArr = ByteArray(value.len)
|
||||
value.asByteBuffer()!!.get(byteArr)
|
||||
return byteArr.toString(Charsets.UTF_8)
|
||||
} finally {
|
||||
RustBuffer.free(value)
|
||||
}
|
||||
}
|
||||
|
||||
override fun read(buf: ByteBuffer): String {
|
||||
val len = buf.getInt()
|
||||
val byteArr = ByteArray(len)
|
||||
buf.get(byteArr)
|
||||
return byteArr.toString(Charsets.UTF_8)
|
||||
}
|
||||
|
||||
fun toUtf8(value: String): ByteBuffer {
|
||||
// Make sure we don't have invalid UTF-16, check for lone surrogates.
|
||||
return Charsets.UTF_8.newEncoder().run {
|
||||
onMalformedInput(CodingErrorAction.REPORT)
|
||||
encode(CharBuffer.wrap(value))
|
||||
}
|
||||
}
|
||||
|
||||
override fun lower(value: String): RustBuffer.ByValue {
|
||||
val byteBuf = toUtf8(value)
|
||||
// Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us
|
||||
// to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`.
|
||||
val rbuf = RustBuffer.alloc(byteBuf.limit())
|
||||
rbuf.asByteBuffer()!!.put(byteBuf)
|
||||
return rbuf
|
||||
}
|
||||
|
||||
// We aren't sure exactly how many bytes our string will be once it's UTF-8
|
||||
// encoded. Allocate 3 bytes per UTF-16 code unit which will always be
|
||||
// enough.
|
||||
override fun allocationSize(value: String): Int {
|
||||
val sizeForLength = 4
|
||||
val sizeForString = value.length * 3
|
||||
return sizeForLength + sizeForString
|
||||
}
|
||||
|
||||
override fun write(value: String, buf: ByteBuffer) {
|
||||
val byteBuf = toUtf8(value)
|
||||
buf.putInt(byteBuf.limit())
|
||||
buf.put(byteBuf)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public object FfiConverterSequenceString: FfiConverterRustBuffer<List<String>> {
|
||||
override fun read(buf: ByteBuffer): List<String> {
|
||||
val len = buf.getInt()
|
||||
return List<String>(len) {
|
||||
FfiConverterString.read(buf)
|
||||
}
|
||||
}
|
||||
|
||||
override fun allocationSize(value: List<String>): Int {
|
||||
val sizeForLength = 4
|
||||
val sizeForItems = value.map { FfiConverterString.allocationSize(it) }.sum()
|
||||
return sizeForLength + sizeForItems
|
||||
}
|
||||
|
||||
override fun write(value: List<String>, buf: ByteBuffer) {
|
||||
buf.putInt(value.size)
|
||||
value.forEach {
|
||||
FfiConverterString.write(it, buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
|
||||
suspend fun `auth`(`url`: String, `secretKey`: String) : List<String> {
|
||||
return uniffiRustCallAsync(
|
||||
_UniFFILib.INSTANCE.uniffi_mobile_fn_func_auth(FfiConverterString.lower(`url`),FfiConverterString.lower(`secretKey`),),
|
||||
{ future, continuation -> _UniFFILib.INSTANCE.ffi_mobile_rust_future_poll_rust_buffer(future, continuation) },
|
||||
{ future, continuation -> _UniFFILib.INSTANCE.ffi_mobile_rust_future_complete_rust_buffer(future, continuation) },
|
||||
{ future -> _UniFFILib.INSTANCE.ffi_mobile_rust_future_free_rust_buffer(future) },
|
||||
// lift function
|
||||
{ FfiConverterSequenceString.lift(it) },
|
||||
// Error FFI converter
|
||||
NullCallStatusErrorHandler,
|
||||
)
|
||||
}
|
||||
|
||||
fun `myexample`(): List<String> {
|
||||
return FfiConverterSequenceString.lift(
|
||||
rustCall() { _status ->
|
||||
_UniFFILib.INSTANCE.uniffi_mobile_fn_func_myexample(_status)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,484 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
import Foundation
|
||||
|
||||
// Depending on the consumer's build setup, the low-level FFI code
|
||||
// might be in a separate module, or it might be compiled inline into
|
||||
// this module. This is a bit of light hackery to work with both.
|
||||
#if canImport(mobileFFI)
|
||||
import mobileFFI
|
||||
#endif
|
||||
|
||||
fileprivate extension RustBuffer {
|
||||
// Allocate a new buffer, copying the contents of a `UInt8` array.
|
||||
init(bytes: [UInt8]) {
|
||||
let rbuf = bytes.withUnsafeBufferPointer { ptr in
|
||||
RustBuffer.from(ptr)
|
||||
}
|
||||
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
|
||||
}
|
||||
|
||||
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
|
||||
try! rustCall { ffi_mobile_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
|
||||
}
|
||||
|
||||
// Frees the buffer in place.
|
||||
// The buffer must not be used after this is called.
|
||||
func deallocate() {
|
||||
try! rustCall { ffi_mobile_rustbuffer_free(self, $0) }
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate extension ForeignBytes {
|
||||
init(bufferPointer: UnsafeBufferPointer<UInt8>) {
|
||||
self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
|
||||
}
|
||||
}
|
||||
|
||||
// For every type used in the interface, we provide helper methods for conveniently
|
||||
// lifting and lowering that type from C-compatible data, and for reading and writing
|
||||
// values of that type in a buffer.
|
||||
|
||||
// Helper classes/extensions that don't change.
|
||||
// Someday, this will be in a library of its own.
|
||||
|
||||
fileprivate extension Data {
|
||||
init(rustBuffer: RustBuffer) {
|
||||
// TODO: This copies the buffer. Can we read directly from a
|
||||
// Rust buffer?
|
||||
self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len))
|
||||
}
|
||||
}
|
||||
|
||||
// Define reader functionality. Normally this would be defined in a class or
|
||||
// struct, but we use standalone functions instead in order to make external
|
||||
// types work.
|
||||
//
|
||||
// With external types, one swift source file needs to be able to call the read
|
||||
// method on another source file's FfiConverter, but then what visibility
|
||||
// should Reader have?
|
||||
// - If Reader is fileprivate, then this means the read() must also
|
||||
// be fileprivate, which doesn't work with external types.
|
||||
// - If Reader is internal/public, we'll get compile errors since both source
|
||||
// files will try define the same type.
|
||||
//
|
||||
// Instead, the read() method and these helper functions input a tuple of data
|
||||
|
||||
fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
|
||||
(data: data, offset: 0)
|
||||
}
|
||||
|
||||
// Reads an integer at the current offset, in big-endian order, and advances
|
||||
// the offset on success. Throws if reading the integer would move the
|
||||
// offset past the end of the buffer.
|
||||
fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
|
||||
let range = reader.offset..<reader.offset + MemoryLayout<T>.size
|
||||
guard reader.data.count >= range.upperBound else {
|
||||
throw UniffiInternalError.bufferOverflow
|
||||
}
|
||||
if T.self == UInt8.self {
|
||||
let value = reader.data[reader.offset]
|
||||
reader.offset += 1
|
||||
return value as! T
|
||||
}
|
||||
var value: T = 0
|
||||
let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
|
||||
reader.offset = range.upperBound
|
||||
return value.bigEndian
|
||||
}
|
||||
|
||||
// Reads an arbitrary number of bytes, to be used to read
|
||||
// raw bytes, this is useful when lifting strings
|
||||
fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
|
||||
let range = reader.offset..<(reader.offset+count)
|
||||
guard reader.data.count >= range.upperBound else {
|
||||
throw UniffiInternalError.bufferOverflow
|
||||
}
|
||||
var value = [UInt8](repeating: 0, count: count)
|
||||
value.withUnsafeMutableBufferPointer({ buffer in
|
||||
reader.data.copyBytes(to: buffer, from: range)
|
||||
})
|
||||
reader.offset = range.upperBound
|
||||
return value
|
||||
}
|
||||
|
||||
// Reads a float at the current offset.
|
||||
fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
|
||||
return Float(bitPattern: try readInt(&reader))
|
||||
}
|
||||
|
||||
// Reads a float at the current offset.
|
||||
fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
|
||||
return Double(bitPattern: try readInt(&reader))
|
||||
}
|
||||
|
||||
// Indicates if the offset has reached the end of the buffer.
|
||||
fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
|
||||
return reader.offset < reader.data.count
|
||||
}
|
||||
|
||||
// Define writer functionality. Normally this would be defined in a class or
|
||||
// struct, but we use standalone functions instead in order to make external
|
||||
// types work. See the above discussion on Readers for details.
|
||||
|
||||
fileprivate func createWriter() -> [UInt8] {
|
||||
return []
|
||||
}
|
||||
|
||||
fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
|
||||
writer.append(contentsOf: byteArr)
|
||||
}
|
||||
|
||||
// Writes an integer in big-endian order.
|
||||
//
|
||||
// Warning: make sure what you are trying to write
|
||||
// is in the correct type!
|
||||
fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
|
||||
var value = value.bigEndian
|
||||
withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
|
||||
}
|
||||
|
||||
fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
|
||||
writeInt(&writer, value.bitPattern)
|
||||
}
|
||||
|
||||
fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
|
||||
writeInt(&writer, value.bitPattern)
|
||||
}
|
||||
|
||||
// Protocol for types that transfer other types across the FFI. This is
|
||||
// analogous go the Rust trait of the same name.
|
||||
fileprivate protocol FfiConverter {
|
||||
associatedtype FfiType
|
||||
associatedtype SwiftType
|
||||
|
||||
static func lift(_ value: FfiType) throws -> SwiftType
|
||||
static func lower(_ value: SwiftType) -> FfiType
|
||||
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
|
||||
static func write(_ value: SwiftType, into buf: inout [UInt8])
|
||||
}
|
||||
|
||||
// Types conforming to `Primitive` pass themselves directly over the FFI.
|
||||
fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
|
||||
|
||||
extension FfiConverterPrimitive {
|
||||
public static func lift(_ value: FfiType) throws -> SwiftType {
|
||||
return value
|
||||
}
|
||||
|
||||
public static func lower(_ value: SwiftType) -> FfiType {
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
|
||||
// Used for complex types where it's hard to write a custom lift/lower.
|
||||
fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
|
||||
|
||||
extension FfiConverterRustBuffer {
|
||||
public static func lift(_ buf: RustBuffer) throws -> SwiftType {
|
||||
var reader = createReader(data: Data(rustBuffer: buf))
|
||||
let value = try read(from: &reader)
|
||||
if hasRemaining(reader) {
|
||||
throw UniffiInternalError.incompleteData
|
||||
}
|
||||
buf.deallocate()
|
||||
return value
|
||||
}
|
||||
|
||||
public static func lower(_ value: SwiftType) -> RustBuffer {
|
||||
var writer = createWriter()
|
||||
write(value, into: &writer)
|
||||
return RustBuffer(bytes: writer)
|
||||
}
|
||||
}
|
||||
// An error type for FFI errors. These errors occur at the UniFFI level, not
|
||||
// the library level.
|
||||
fileprivate enum UniffiInternalError: LocalizedError {
|
||||
case bufferOverflow
|
||||
case incompleteData
|
||||
case unexpectedOptionalTag
|
||||
case unexpectedEnumCase
|
||||
case unexpectedNullPointer
|
||||
case unexpectedRustCallStatusCode
|
||||
case unexpectedRustCallError
|
||||
case unexpectedStaleHandle
|
||||
case rustPanic(_ message: String)
|
||||
|
||||
public var errorDescription: String? {
|
||||
switch self {
|
||||
case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
|
||||
case .incompleteData: return "The buffer still has data after lifting its containing value"
|
||||
case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
|
||||
case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
|
||||
case .unexpectedNullPointer: return "Raw pointer value was null"
|
||||
case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
|
||||
case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
|
||||
case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
|
||||
case let .rustPanic(message): return message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let CALL_SUCCESS: Int8 = 0
|
||||
fileprivate let CALL_ERROR: Int8 = 1
|
||||
fileprivate let CALL_PANIC: Int8 = 2
|
||||
fileprivate let CALL_CANCELLED: Int8 = 3
|
||||
|
||||
fileprivate extension RustCallStatus {
|
||||
init() {
|
||||
self.init(
|
||||
code: CALL_SUCCESS,
|
||||
errorBuf: RustBuffer.init(
|
||||
capacity: 0,
|
||||
len: 0,
|
||||
data: nil
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
||||
try makeRustCall(callback, errorHandler: nil)
|
||||
}
|
||||
|
||||
private func rustCallWithError<T>(
|
||||
_ errorHandler: @escaping (RustBuffer) throws -> Error,
|
||||
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
|
||||
try makeRustCall(callback, errorHandler: errorHandler)
|
||||
}
|
||||
|
||||
private func makeRustCall<T>(
|
||||
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
|
||||
errorHandler: ((RustBuffer) throws -> Error)?
|
||||
) throws -> T {
|
||||
uniffiEnsureInitialized()
|
||||
var callStatus = RustCallStatus.init()
|
||||
let returnedVal = callback(&callStatus)
|
||||
try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
|
||||
return returnedVal
|
||||
}
|
||||
|
||||
private func uniffiCheckCallStatus(
|
||||
callStatus: RustCallStatus,
|
||||
errorHandler: ((RustBuffer) throws -> Error)?
|
||||
) throws {
|
||||
switch callStatus.code {
|
||||
case CALL_SUCCESS:
|
||||
return
|
||||
|
||||
case CALL_ERROR:
|
||||
if let errorHandler = errorHandler {
|
||||
throw try errorHandler(callStatus.errorBuf)
|
||||
} else {
|
||||
callStatus.errorBuf.deallocate()
|
||||
throw UniffiInternalError.unexpectedRustCallError
|
||||
}
|
||||
|
||||
case CALL_PANIC:
|
||||
// When the rust code sees a panic, it tries to construct a RustBuffer
|
||||
// with the message. But if that code panics, then it just sends back
|
||||
// an empty buffer.
|
||||
if callStatus.errorBuf.len > 0 {
|
||||
throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
|
||||
} else {
|
||||
callStatus.errorBuf.deallocate()
|
||||
throw UniffiInternalError.rustPanic("Rust panic")
|
||||
}
|
||||
|
||||
case CALL_CANCELLED:
|
||||
throw CancellationError()
|
||||
|
||||
default:
|
||||
throw UniffiInternalError.unexpectedRustCallStatusCode
|
||||
}
|
||||
}
|
||||
|
||||
// Public interface members begin here.
|
||||
|
||||
|
||||
fileprivate struct FfiConverterString: FfiConverter {
|
||||
typealias SwiftType = String
|
||||
typealias FfiType = RustBuffer
|
||||
|
||||
public static func lift(_ value: RustBuffer) throws -> String {
|
||||
defer {
|
||||
value.deallocate()
|
||||
}
|
||||
if value.data == nil {
|
||||
return String()
|
||||
}
|
||||
let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
|
||||
return String(bytes: bytes, encoding: String.Encoding.utf8)!
|
||||
}
|
||||
|
||||
public static func lower(_ value: String) -> RustBuffer {
|
||||
return value.utf8CString.withUnsafeBufferPointer { ptr in
|
||||
// The swift string gives us int8_t, we want uint8_t.
|
||||
ptr.withMemoryRebound(to: UInt8.self) { ptr in
|
||||
// The swift string gives us a trailing null byte, we don't want it.
|
||||
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
|
||||
return RustBuffer.from(buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
|
||||
let len: Int32 = try readInt(&buf)
|
||||
return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
|
||||
}
|
||||
|
||||
public static func write(_ value: String, into buf: inout [UInt8]) {
|
||||
let len = Int32(value.utf8.count)
|
||||
writeInt(&buf, len)
|
||||
writeBytes(&buf, value.utf8)
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
|
||||
typealias SwiftType = [String]
|
||||
|
||||
public static func write(_ value: [String], into buf: inout [UInt8]) {
|
||||
let len = Int32(value.count)
|
||||
writeInt(&buf, len)
|
||||
for item in value {
|
||||
FfiConverterString.write(item, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
|
||||
let len: Int32 = try readInt(&buf)
|
||||
var seq = [String]()
|
||||
seq.reserveCapacity(Int(len))
|
||||
for _ in 0 ..< len {
|
||||
seq.append(try FfiConverterString.read(from: &buf))
|
||||
}
|
||||
return seq
|
||||
}
|
||||
}
|
||||
private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0
|
||||
private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1
|
||||
|
||||
fileprivate func uniffiRustCallAsync<F, T>(
|
||||
rustFutureFunc: () -> UnsafeMutableRawPointer,
|
||||
pollFunc: (UnsafeMutableRawPointer, UnsafeMutableRawPointer) -> (),
|
||||
completeFunc: (UnsafeMutableRawPointer, UnsafeMutablePointer<RustCallStatus>) -> F,
|
||||
freeFunc: (UnsafeMutableRawPointer) -> (),
|
||||
liftFunc: (F) throws -> T,
|
||||
errorHandler: ((RustBuffer) throws -> Error)?
|
||||
) async throws -> T {
|
||||
// Make sure to call uniffiEnsureInitialized() since future creation doesn't have a
|
||||
// RustCallStatus param, so doesn't use makeRustCall()
|
||||
uniffiEnsureInitialized()
|
||||
let rustFuture = rustFutureFunc()
|
||||
defer {
|
||||
freeFunc(rustFuture)
|
||||
}
|
||||
var pollResult: Int8;
|
||||
repeat {
|
||||
pollResult = await withUnsafeContinuation {
|
||||
pollFunc(rustFuture, ContinuationHolder($0).toOpaque())
|
||||
}
|
||||
} while pollResult != UNIFFI_RUST_FUTURE_POLL_READY
|
||||
|
||||
return try liftFunc(makeRustCall(
|
||||
{ completeFunc(rustFuture, $0) },
|
||||
errorHandler: errorHandler
|
||||
))
|
||||
}
|
||||
|
||||
// Callback handlers for an async calls. These are invoked by Rust when the future is ready. They
|
||||
// lift the return value or error and resume the suspended function.
|
||||
fileprivate func uniffiFutureContinuationCallback(ptr: UnsafeMutableRawPointer, pollResult: Int8) {
|
||||
ContinuationHolder.fromOpaque(ptr).resume(pollResult)
|
||||
}
|
||||
|
||||
// Wraps UnsafeContinuation in a class so that we can use reference counting when passing it across
|
||||
// the FFI
|
||||
fileprivate class ContinuationHolder {
|
||||
let continuation: UnsafeContinuation<Int8, Never>
|
||||
|
||||
init(_ continuation: UnsafeContinuation<Int8, Never>) {
|
||||
self.continuation = continuation
|
||||
}
|
||||
|
||||
func resume(_ pollResult: Int8) {
|
||||
self.continuation.resume(returning: pollResult)
|
||||
}
|
||||
|
||||
func toOpaque() -> UnsafeMutableRawPointer {
|
||||
return Unmanaged<ContinuationHolder>.passRetained(self).toOpaque()
|
||||
}
|
||||
|
||||
static func fromOpaque(_ ptr: UnsafeRawPointer) -> ContinuationHolder {
|
||||
return Unmanaged<ContinuationHolder>.fromOpaque(ptr).takeRetainedValue()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func uniffiInitContinuationCallback() {
|
||||
ffi_mobile_rust_future_continuation_callback_set(uniffiFutureContinuationCallback)
|
||||
}
|
||||
|
||||
public func auth(url: String, secretKey: String) async -> [String] {
|
||||
return try! await uniffiRustCallAsync(
|
||||
rustFutureFunc: {
|
||||
uniffi_mobile_fn_func_auth(
|
||||
FfiConverterString.lower(url),
|
||||
FfiConverterString.lower(secretKey)
|
||||
)
|
||||
},
|
||||
pollFunc: ffi_mobile_rust_future_poll_rust_buffer,
|
||||
completeFunc: ffi_mobile_rust_future_complete_rust_buffer,
|
||||
freeFunc: ffi_mobile_rust_future_free_rust_buffer,
|
||||
liftFunc: FfiConverterSequenceString.lift,
|
||||
errorHandler: nil
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
public func myexample() -> [String] {
|
||||
return try! FfiConverterSequenceString.lift(
|
||||
try! rustCall() {
|
||||
uniffi_mobile_fn_func_myexample($0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private enum InitializationResult {
|
||||
case ok
|
||||
case contractVersionMismatch
|
||||
case apiChecksumMismatch
|
||||
}
|
||||
// Use a global variables to perform the versioning checks. Swift ensures that
|
||||
// the code inside is only computed once.
|
||||
private var initializationResult: InitializationResult {
|
||||
// Get the bindings contract version from our ComponentInterface
|
||||
let bindings_contract_version = 24
|
||||
// Get the scaffolding contract version by calling the into the dylib
|
||||
let scaffolding_contract_version = ffi_mobile_uniffi_contract_version()
|
||||
if bindings_contract_version != scaffolding_contract_version {
|
||||
return InitializationResult.contractVersionMismatch
|
||||
}
|
||||
if (uniffi_mobile_checksum_func_auth() != 55720) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_mobile_checksum_func_myexample() != 65225) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
|
||||
uniffiInitContinuationCallback()
|
||||
return InitializationResult.ok
|
||||
}
|
||||
|
||||
private func uniffiEnsureInitialized() {
|
||||
switch initializationResult {
|
||||
case .ok:
|
||||
break
|
||||
case .contractVersionMismatch:
|
||||
fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
|
||||
case .apiChecksumMismatch:
|
||||
fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
|
||||
}
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// The following structs are used to implement the lowest level
|
||||
// of the FFI, and thus useful to multiple uniffied crates.
|
||||
// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H.
|
||||
#ifdef UNIFFI_SHARED_H
|
||||
// We also try to prevent mixing versions of shared uniffi header structs.
|
||||
// If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4
|
||||
#ifndef UNIFFI_SHARED_HEADER_V4
|
||||
#error Combining helper code from multiple versions of uniffi is not supported
|
||||
#endif // ndef UNIFFI_SHARED_HEADER_V4
|
||||
#else
|
||||
#define UNIFFI_SHARED_H
|
||||
#define UNIFFI_SHARED_HEADER_V4
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
|
||||
typedef struct RustBuffer
|
||||
{
|
||||
int32_t capacity;
|
||||
int32_t len;
|
||||
uint8_t *_Nullable data;
|
||||
} RustBuffer;
|
||||
|
||||
typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull);
|
||||
|
||||
// Task defined in Rust that Swift executes
|
||||
typedef void (*UniFfiRustTaskCallback)(const void * _Nullable, int8_t);
|
||||
|
||||
// Callback to execute Rust tasks using a Swift Task
|
||||
//
|
||||
// Args:
|
||||
// executor: ForeignExecutor lowered into a size_t value
|
||||
// delay: Delay in MS
|
||||
// task: UniFfiRustTaskCallback to call
|
||||
// task_data: data to pass the task callback
|
||||
typedef int8_t (*UniFfiForeignExecutorCallback)(size_t, uint32_t, UniFfiRustTaskCallback _Nullable, const void * _Nullable);
|
||||
|
||||
typedef struct ForeignBytes
|
||||
{
|
||||
int32_t len;
|
||||
const uint8_t *_Nullable data;
|
||||
} ForeignBytes;
|
||||
|
||||
// Error definitions
|
||||
typedef struct RustCallStatus {
|
||||
int8_t code;
|
||||
RustBuffer errorBuf;
|
||||
} RustCallStatus;
|
||||
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
#endif // def UNIFFI_SHARED_H
|
||||
|
||||
// Continuation callback for UniFFI Futures
|
||||
typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
|
||||
|
||||
// Scaffolding functions
|
||||
void* _Nonnull uniffi_mobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
|
||||
);
|
||||
RustBuffer uniffi_mobile_fn_func_myexample(RustCallStatus *_Nonnull out_status
|
||||
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_continuation_callback_set(UniFfiRustFutureContinuation _Nonnull callback
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u8(void* _Nonnull handle
|
||||
);
|
||||
uint8_t ffi_mobile_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i8(void* _Nonnull handle
|
||||
);
|
||||
int8_t ffi_mobile_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u16(void* _Nonnull handle
|
||||
);
|
||||
uint16_t ffi_mobile_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i16(void* _Nonnull handle
|
||||
);
|
||||
int16_t ffi_mobile_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u32(void* _Nonnull handle
|
||||
);
|
||||
uint32_t ffi_mobile_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i32(void* _Nonnull handle
|
||||
);
|
||||
int32_t ffi_mobile_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u64(void* _Nonnull handle
|
||||
);
|
||||
uint64_t ffi_mobile_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i64(void* _Nonnull handle
|
||||
);
|
||||
int64_t ffi_mobile_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_f32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_f32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_f32(void* _Nonnull handle
|
||||
);
|
||||
float ffi_mobile_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_f64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_f64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_f64(void* _Nonnull handle
|
||||
);
|
||||
double ffi_mobile_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_pointer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_pointer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_pointer(void* _Nonnull handle
|
||||
);
|
||||
void*_Nonnull ffi_mobile_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_rust_buffer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
RustBuffer ffi_mobile_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_void(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
uint16_t uniffi_mobile_checksum_func_auth(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mobile_checksum_func_myexample(void
|
||||
|
||||
);
|
||||
uint32_t ffi_mobile_uniffi_contract_version(void
|
||||
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
module mobileFFI {
|
||||
header "mobileFFI.h"
|
||||
module pubkymobileFFI {
|
||||
header "pubkymobileFFI.h"
|
||||
export *
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>AvailableLibraries</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libmobile.a</string>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libmobile.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BinaryPath</key>
|
||||
<string>libmobile.a</string>
|
||||
<key>HeadersPath</key>
|
||||
<string>Headers</string>
|
||||
<key>LibraryIdentifier</key>
|
||||
<string>ios-arm64-simulator</string>
|
||||
<key>LibraryPath</key>
|
||||
<string>libmobile.a</string>
|
||||
<key>SupportedArchitectures</key>
|
||||
<array>
|
||||
<string>arm64</string>
|
||||
</array>
|
||||
<key>SupportedPlatform</key>
|
||||
<string>ios</string>
|
||||
<key>SupportedPlatformVariant</key>
|
||||
<string>simulator</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>XFWK</string>
|
||||
<key>XCFrameworkFormatVersion</key>
|
||||
<string>1.0</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,194 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// The following structs are used to implement the lowest level
|
||||
// of the FFI, and thus useful to multiple uniffied crates.
|
||||
// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H.
|
||||
#ifdef UNIFFI_SHARED_H
|
||||
// We also try to prevent mixing versions of shared uniffi header structs.
|
||||
// If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4
|
||||
#ifndef UNIFFI_SHARED_HEADER_V4
|
||||
#error Combining helper code from multiple versions of uniffi is not supported
|
||||
#endif // ndef UNIFFI_SHARED_HEADER_V4
|
||||
#else
|
||||
#define UNIFFI_SHARED_H
|
||||
#define UNIFFI_SHARED_HEADER_V4
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
|
||||
typedef struct RustBuffer
|
||||
{
|
||||
int32_t capacity;
|
||||
int32_t len;
|
||||
uint8_t *_Nullable data;
|
||||
} RustBuffer;
|
||||
|
||||
typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull);
|
||||
|
||||
// Task defined in Rust that Swift executes
|
||||
typedef void (*UniFfiRustTaskCallback)(const void * _Nullable, int8_t);
|
||||
|
||||
// Callback to execute Rust tasks using a Swift Task
|
||||
//
|
||||
// Args:
|
||||
// executor: ForeignExecutor lowered into a size_t value
|
||||
// delay: Delay in MS
|
||||
// task: UniFfiRustTaskCallback to call
|
||||
// task_data: data to pass the task callback
|
||||
typedef int8_t (*UniFfiForeignExecutorCallback)(size_t, uint32_t, UniFfiRustTaskCallback _Nullable, const void * _Nullable);
|
||||
|
||||
typedef struct ForeignBytes
|
||||
{
|
||||
int32_t len;
|
||||
const uint8_t *_Nullable data;
|
||||
} ForeignBytes;
|
||||
|
||||
// Error definitions
|
||||
typedef struct RustCallStatus {
|
||||
int8_t code;
|
||||
RustBuffer errorBuf;
|
||||
} RustCallStatus;
|
||||
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
#endif // def UNIFFI_SHARED_H
|
||||
|
||||
// Continuation callback for UniFFI Futures
|
||||
typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
|
||||
|
||||
// Scaffolding functions
|
||||
void* _Nonnull uniffi_mobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
|
||||
);
|
||||
RustBuffer uniffi_mobile_fn_func_myexample(RustCallStatus *_Nonnull out_status
|
||||
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_continuation_callback_set(UniFfiRustFutureContinuation _Nonnull callback
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u8(void* _Nonnull handle
|
||||
);
|
||||
uint8_t ffi_mobile_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i8(void* _Nonnull handle
|
||||
);
|
||||
int8_t ffi_mobile_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u16(void* _Nonnull handle
|
||||
);
|
||||
uint16_t ffi_mobile_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i16(void* _Nonnull handle
|
||||
);
|
||||
int16_t ffi_mobile_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u32(void* _Nonnull handle
|
||||
);
|
||||
uint32_t ffi_mobile_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i32(void* _Nonnull handle
|
||||
);
|
||||
int32_t ffi_mobile_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u64(void* _Nonnull handle
|
||||
);
|
||||
uint64_t ffi_mobile_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i64(void* _Nonnull handle
|
||||
);
|
||||
int64_t ffi_mobile_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_f32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_f32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_f32(void* _Nonnull handle
|
||||
);
|
||||
float ffi_mobile_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_f64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_f64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_f64(void* _Nonnull handle
|
||||
);
|
||||
double ffi_mobile_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_pointer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_pointer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_pointer(void* _Nonnull handle
|
||||
);
|
||||
void*_Nonnull ffi_mobile_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_rust_buffer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
RustBuffer ffi_mobile_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_void(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
uint16_t uniffi_mobile_checksum_func_auth(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mobile_checksum_func_myexample(void
|
||||
|
||||
);
|
||||
uint32_t ffi_mobile_uniffi_contract_version(void
|
||||
|
||||
);
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
module mobileFFI {
|
||||
header "mobileFFI.h"
|
||||
export *
|
||||
}
|
||||
Binary file not shown.
@@ -1,194 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// The following structs are used to implement the lowest level
|
||||
// of the FFI, and thus useful to multiple uniffied crates.
|
||||
// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H.
|
||||
#ifdef UNIFFI_SHARED_H
|
||||
// We also try to prevent mixing versions of shared uniffi header structs.
|
||||
// If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4
|
||||
#ifndef UNIFFI_SHARED_HEADER_V4
|
||||
#error Combining helper code from multiple versions of uniffi is not supported
|
||||
#endif // ndef UNIFFI_SHARED_HEADER_V4
|
||||
#else
|
||||
#define UNIFFI_SHARED_H
|
||||
#define UNIFFI_SHARED_HEADER_V4
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
|
||||
typedef struct RustBuffer
|
||||
{
|
||||
int32_t capacity;
|
||||
int32_t len;
|
||||
uint8_t *_Nullable data;
|
||||
} RustBuffer;
|
||||
|
||||
typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull);
|
||||
|
||||
// Task defined in Rust that Swift executes
|
||||
typedef void (*UniFfiRustTaskCallback)(const void * _Nullable, int8_t);
|
||||
|
||||
// Callback to execute Rust tasks using a Swift Task
|
||||
//
|
||||
// Args:
|
||||
// executor: ForeignExecutor lowered into a size_t value
|
||||
// delay: Delay in MS
|
||||
// task: UniFfiRustTaskCallback to call
|
||||
// task_data: data to pass the task callback
|
||||
typedef int8_t (*UniFfiForeignExecutorCallback)(size_t, uint32_t, UniFfiRustTaskCallback _Nullable, const void * _Nullable);
|
||||
|
||||
typedef struct ForeignBytes
|
||||
{
|
||||
int32_t len;
|
||||
const uint8_t *_Nullable data;
|
||||
} ForeignBytes;
|
||||
|
||||
// Error definitions
|
||||
typedef struct RustCallStatus {
|
||||
int8_t code;
|
||||
RustBuffer errorBuf;
|
||||
} RustCallStatus;
|
||||
|
||||
// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️
|
||||
// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️
|
||||
#endif // def UNIFFI_SHARED_H
|
||||
|
||||
// Continuation callback for UniFFI Futures
|
||||
typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t);
|
||||
|
||||
// Scaffolding functions
|
||||
void* _Nonnull uniffi_mobile_fn_func_auth(RustBuffer url, RustBuffer secret_key
|
||||
);
|
||||
RustBuffer uniffi_mobile_fn_func_myexample(RustCallStatus *_Nonnull out_status
|
||||
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
RustBuffer ffi_mobile_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_continuation_callback_set(UniFfiRustFutureContinuation _Nonnull callback
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u8(void* _Nonnull handle
|
||||
);
|
||||
uint8_t ffi_mobile_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i8(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i8(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i8(void* _Nonnull handle
|
||||
);
|
||||
int8_t ffi_mobile_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u16(void* _Nonnull handle
|
||||
);
|
||||
uint16_t ffi_mobile_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i16(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i16(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i16(void* _Nonnull handle
|
||||
);
|
||||
int16_t ffi_mobile_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u32(void* _Nonnull handle
|
||||
);
|
||||
uint32_t ffi_mobile_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i32(void* _Nonnull handle
|
||||
);
|
||||
int32_t ffi_mobile_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_u64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_u64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_u64(void* _Nonnull handle
|
||||
);
|
||||
uint64_t ffi_mobile_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_i64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_i64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_i64(void* _Nonnull handle
|
||||
);
|
||||
int64_t ffi_mobile_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_f32(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_f32(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_f32(void* _Nonnull handle
|
||||
);
|
||||
float ffi_mobile_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_f64(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_f64(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_f64(void* _Nonnull handle
|
||||
);
|
||||
double ffi_mobile_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_pointer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_pointer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_pointer(void* _Nonnull handle
|
||||
);
|
||||
void*_Nonnull ffi_mobile_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_rust_buffer(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_rust_buffer(void* _Nonnull handle
|
||||
);
|
||||
RustBuffer ffi_mobile_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
void ffi_mobile_rust_future_poll_void(void* _Nonnull handle, void* _Nonnull uniffi_callback
|
||||
);
|
||||
void ffi_mobile_rust_future_cancel_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_free_void(void* _Nonnull handle
|
||||
);
|
||||
void ffi_mobile_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status
|
||||
);
|
||||
uint16_t uniffi_mobile_checksum_func_auth(void
|
||||
|
||||
);
|
||||
uint16_t uniffi_mobile_checksum_func_myexample(void
|
||||
|
||||
);
|
||||
uint32_t ffi_mobile_uniffi_contract_version(void
|
||||
|
||||
);
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
// This file was autogenerated by some hot garbage in the `uniffi` crate.
|
||||
// Trust me, you don't want to mess with it!
|
||||
module mobileFFI {
|
||||
header "mobileFFI.h"
|
||||
export *
|
||||
}
|
||||
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
uniffi::setup_scaffolding!();
|
||||
|
||||
use url::Url;
|
||||
use pubky::PubkyClient;
|
||||
use hex;
|
||||
use url::Url;
|
||||
|
||||
#[uniffi::export]
|
||||
async fn auth(url: String, secret_key: String) -> Vec<String> {
|
||||
|
||||
Reference in New Issue
Block a user