Skip to content

Commit

Permalink
Update UniFFI (#130)
Browse files Browse the repository at this point in the history
Update UniFFI to 0.27.1+ with github.com/mozilla/uniffi-rs/pull/2098 fix giving 230x speed up of Swift calls to Rust.
  • Loading branch information
matiasbzurovski authored May 9, 2024
1 parent 0c46ed7 commit e4e8e46
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 67 deletions.
79 changes: 32 additions & 47 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sargon"
version = "0.7.8"
version = "0.7.9"
edition = "2021"
build = "build.rs"

Expand Down Expand Up @@ -109,8 +109,8 @@ itertools = { git = "https://github.com/rust-itertools/itertools/", rev = "98eca
# enum-as-inner = "0.6.0"
enum-as-inner = { git = "https://github.com/bluejekyll/enum-as-inner/", rev = "c15f6e5c4f98ec865e181ae1fff9fc13a1a2e4e2" }

# uniffi = "0.27.0"
uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "d52c5460ae42ecad1e73a5b394ac96d48f4769de", features = [
# uniffi = "0.27.1"
uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "6f33088e8100a2ea9586c8c3ecf98ab51d5aba62", features = [
"cli",
] }

Expand Down Expand Up @@ -177,8 +177,8 @@ aes-gcm = { git = "https://github.com/RustCrypto/AEADs", rev = "7e82b01cd4901f6a
hkdf = { git = "https://github.com/RustCrypto/KDFs/", rev = "1ac16e8b9d4ee7a67613c9396c6cc1327652eaba" }

[dev-dependencies]
# uniffi = "0.27.0"
uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "d52c5460ae42ecad1e73a5b394ac96d48f4769de", features = [
# uniffi = "0.27.1"
uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "6f33088e8100a2ea9586c8c3ecf98ab51d5aba62", features = [
"bindgen-tests",
] }

Expand All @@ -191,8 +191,8 @@ reqwest = { git = "https://github.com/seanmonstar/reqwest", rev = "0720159f6369f
actix-rt = { git = "https://github.com/actix/actix-net", rev = "57fd6ea8098d1f2d281c305fc331216c4fe1992e" }

[build-dependencies]
# uniffi = "0.27.0"
uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "d52c5460ae42ecad1e73a5b394ac96d48f4769de", features = [
# uniffi = "0.27.1"
uniffi = { git = "https://github.com/mozilla/uniffi-rs/", rev = "6f33088e8100a2ea9586c8c3ecf98ab51d5aba62", features = [
"build",
] }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension Profile {
}
}

public typealias ProfileID = ProfileId
extension Profile: Identifiable {
public typealias ID = ProfileID
public var id: ID {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.radixdlt.sargon.extensions

import com.radixdlt.sargon.BIP39Passphrase
import com.radixdlt.sargon.Bip39Passphrase
import com.radixdlt.sargon.CommonException
import com.radixdlt.sargon.DerivationPath
import com.radixdlt.sargon.Hash
Expand All @@ -21,7 +21,7 @@ import kotlinx.serialization.json.Json
@Throws(SargonException::class)
fun MnemonicWithPassphrase.Companion.init(phrase: String) = MnemonicWithPassphrase(
mnemonic = Mnemonic.init(phrase = phrase),
passphrase = BIP39Passphrase()
passphrase = Bip39Passphrase()
)

@Throws(SargonException::class)
Expand Down Expand Up @@ -77,7 +77,7 @@ fun MnemonicWithPassphrase.sign(
private data class AndroidMnemonicWithPassphrase(
@SerialName("mnemonic")
val phrase: String,
@SerialName("bip39Passphrase")
@SerialName("Bip39Passphrase")
val passphrase: String
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MnemonicWithPassphraseTest {
@Test
fun testFromAndroidJson() {
val androidJsonWithoutPassphrase =
"""{"mnemonic":"remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track","bip39Passphrase":""}""".trimIndent()
"""{"mnemonic":"remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track","Bip39Passphrase":""}""".trimIndent()
assertEquals(
MnemonicWithPassphrase(
mnemonic = Mnemonic.init(phrase = "remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track"),
Expand All @@ -52,7 +52,7 @@ class MnemonicWithPassphraseTest {

val androidJsonWithoutPassphrasePrettyPrinted = """{
"mnemonic": "remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track",
"bip39Passphrase": ""
"Bip39Passphrase": ""
}""".trimIndent()
assertEquals(
MnemonicWithPassphrase(
Expand All @@ -63,7 +63,7 @@ class MnemonicWithPassphraseTest {
)

val androidJsonWithPassphrase =
"""{"mnemonic":"remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track","bip39Passphrase":"super secret"}""".trimIndent()
"""{"mnemonic":"remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track","Bip39Passphrase":"super secret"}""".trimIndent()
assertEquals(
MnemonicWithPassphrase(
mnemonic = Mnemonic.init(phrase = "remind index lift gun sleep inner double leopard exist sugar item whisper coast duty leopard law radar neutral odor tape finger position capital track"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::prelude::*;
use indexmap::IndexMap;
use std::any::TypeId;
use std::any::TypeId as StdTypeId;
use uniffi::TypeId as UFTypeId;
use uniffi::{
check_remaining,
deps::bytes::{Buf, BufMut},
Expand All @@ -27,10 +28,6 @@ unsafe impl<UT, V: Debug + Eq + Clone + Identifiable + Lower<UT>> Lower<UT>
fn lower(obj: Self) -> RustBuffer {
Self::lower_into_rust_buffer(obj)
}

const TYPE_ID_META: MetadataBuffer =
MetadataBuffer::from_code(metadata::codes::TYPE_VEC)
.concat(V::TYPE_ID_META);
}

unsafe impl<UT, V: Debug + Eq + Clone + Identifiable + Lower<UT>>
Expand All @@ -41,8 +38,6 @@ unsafe impl<UT, V: Debug + Eq + Clone + Identifiable + Lower<UT>>
fn lower_return(obj: Self) -> uniffi::Result<Self::ReturnType, RustBuffer> {
Ok(<Self as Lower<UT>>::lower(obj))
}

const TYPE_ID_META: MetadataBuffer = <Self as Lower<UT>>::TYPE_ID_META;
}
unsafe impl<UT, V: Debug + Eq + Clone + Identifiable + Lift<UT> + 'static>
Lift<UT> for IdentifiedVecOf<V>
Expand All @@ -62,7 +57,11 @@ unsafe impl<UT, V: Debug + Eq + Clone + Identifiable + Lift<UT> + 'static>
fn try_lift(buf: RustBuffer) -> uniffi::Result<Self> {
Self::try_lift_from_rust_buffer(buf)
}
}

impl<UT, V: Debug + Eq + Clone + Identifiable + UFTypeId<UT>> UFTypeId<UT>
for IdentifiedVecOf<V>
{
const TYPE_ID_META: MetadataBuffer =
MetadataBuffer::from_code(metadata::codes::TYPE_VEC)
.concat(V::TYPE_ID_META);
Expand Down

0 comments on commit e4e8e46

Please sign in to comment.