Skip to content

Commit

Permalink
Define custom String type with complete macro
Browse files Browse the repository at this point in the history
Separate `uniffi::custom_type` and `impl_string_custom_typedef`
calls were made to define uniffi String types. This combines them
into one macro.
  • Loading branch information
DanGould committed Nov 15, 2024
1 parent 6e3b595 commit 24a53bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 2 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ impl From<bitcoin::Network> 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");
4 changes: 3 additions & 1 deletion src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
Expand Down

0 comments on commit 24a53bc

Please sign in to comment.