Skip to content

Commit

Permalink
ffi(nostr): add tag_kind_to_string func
Browse files Browse the repository at this point in the history
Closes #577

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Sep 26, 2024
1 parent c114b3a commit 33caa68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* relay-builder: add min POW difficulty option to `RelayBuilder` ([Yuki Kishimoto])
* pool: add `RelayPool::force_remove_relay` method ([Yuki Kishimoto])
* zapper: add `WebLNZapper` struct (moved from `nostr-webln` crate) ([Yuki Kishimoto])
* ffi(nostr): add `tag_kind_to_string` func ([Yuki Kishimoto])
* book: add some examples ([RydalWater])

### Fixed
Expand Down
7 changes: 7 additions & 0 deletions bindings/nostr-ffi/src/event/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ impl<'a> From<TagKind> for tag::TagKind<'a> {
}
}

/// Convert tag kind to string
#[uniffi::export]
pub fn tag_kind_to_string(kind: TagKind) -> String {
let kind: tag::TagKind<'_> = kind.into();
kind.to_string()
}

/// Tag
#[derive(Debug, PartialEq, Eq, Hash, Object)]
#[uniffi::export(Debug, Eq, Hash)]
Expand Down
3 changes: 3 additions & 0 deletions bindings/nostr-ffi/tests/test_to_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
addr = "30023:aa4fc8665f5696e33db7e1a572e3b0f5b3d615837b0f362dcb1c8068b098c7b4:ipsum"
coordinate = Coordinate.parse(addr)
assert addr == coordinate.__str__()

t_kind = TagKind.NONCE()
assert tag_kind_to_string(t_kind) == "nonce"

0 comments on commit 33caa68

Please sign in to comment.