Skip to content

Commit f7d45d7

Browse files
committed
nostr: add Kind::from_u16
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 0dafd16 commit f7d45d7

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
* nostr: add `EventId::from_byte_array` ([Yuki Kishimoto])
9090
* nostr: add `Timestamp::min` and `Timestamp::max` ([Yuki Kishimoto])
9191
* nostr: add `nip65::extract_owned_relay_list` ([Yuki Kishimoto])
92+
* nostr: add `Kind::from_u16` ([Yuki Kishimoto])
9293
* database: add `DatabaseHelper::fast_query` ([Yuki Kishimoto])
9394
* database: add `NostrDatabase::check_id` ([Yuki Kishimoto])
9495
* database: add `NostrDatabaseExt::relay_lists` ([Yuki Kishimoto])

bindings/nostr-ffi/src/event/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Kind {
3131
#[uniffi::constructor]
3232
pub fn new(kind: u16) -> Self {
3333
Self {
34-
inner: nostr::Kind::from(kind),
34+
inner: nostr::Kind::from_u16(kind),
3535
}
3636
}
3737

bindings/nostr-js/src/event/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl JsKind {
3232
#[wasm_bindgen(constructor)]
3333
pub fn new(kind: u16) -> Self {
3434
Self {
35-
inner: Kind::from(kind),
35+
inner: Kind::from_u16(kind),
3636
}
3737
}
3838

crates/nostr/src/event/kind.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ impl Hash for Kind {
195195
}
196196

197197
impl Kind {
198+
/// Construct from 16-bit unsigned integer
199+
#[inline]
200+
pub fn from_u16(kind: u16) -> Self {
201+
Self::from(kind)
202+
}
203+
198204
/// Get as 16-bit unsigned integer
199205
#[inline]
200206
pub fn as_u16(&self) -> u16 {

0 commit comments

Comments
 (0)