From 24a53bc3a3c81f6549f6d4698476eabd9a218f8e Mon Sep 17 00:00:00 2001 From: DanGould Date: Fri, 15 Nov 2024 13:21:07 -0500 Subject: [PATCH] Define custom String type with complete macro Separate `uniffi::custom_type` and `impl_string_custom_typedef` calls were made to define uniffi String types. This combines them into one macro. --- src/lib.rs | 6 ++---- src/macros.rs | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3a2c4fb..69ac1f1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -330,9 +330,7 @@ impl From for Network { } } -uniffi::custom_type!(Txid, String); -impl_string_custom_typedef!(Txid); -uniffi::custom_type!(BlockHash, String); -impl_string_custom_typedef!(BlockHash); +define_custom_string_type!(Txid); +define_custom_string_type!(BlockHash); uniffi::setup_scaffolding!("bitcoin"); diff --git a/src/macros.rs b/src/macros.rs index 7816ab4..cfd2371 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -18,8 +18,10 @@ macro_rules! impl_from_ffi_type { }; } -macro_rules! impl_string_custom_typedef { +macro_rules! define_custom_string_type { ($ffi_type:ident) => { + uniffi::custom_type!($ffi_type, String); + impl UniffiCustomTypeConverter for $ffi_type { type Builtin = String; fn into_custom(val: Self::Builtin) -> uniffi::Result {