Skip to content

Commit 89c1384

Browse files
kasugamiraiyukibtc
authored andcommitted
nostr: add Tag::is_root method
Closes #431 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 1540e88 commit 89c1384

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
<!-- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), -->
66
<!-- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -->
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
* nostr: add `Tag::is_root` method ([Xiao Yu])
13+
814
## [v0.31.0]
915

1016
### Summary

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,11 @@ impl Tag {
408408
}
409409
}
410410

411+
/// Check if `Tag` is an event `root`
412+
pub fn is_root(&self) -> bool {
413+
self.inner.is_root()
414+
}
415+
411416
/// Check if `Tag` is an event `reply`
412417
pub fn is_reply(&self) -> bool {
413418
self.inner.is_reply()

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,16 @@ impl JsTag {
313313
}
314314
}
315315

316+
/// Check if `Tag` is an event `root`
317+
#[inline]
318+
#[wasm_bindgen(js_name = isRoot)]
319+
pub fn is_root(&self) -> bool {
320+
self.inner.is_root()
321+
}
322+
316323
/// Check if `Tag` is an event `reply`
317324
#[inline]
325+
#[wasm_bindgen(js_name = isReply)]
318326
pub fn is_reply(&self) -> bool {
319327
self.inner.is_reply()
320328
}

crates/nostr/src/event/tag/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,18 @@ impl Tag {
277277
Self::new_with_empty_cell(buf)
278278
}
279279

280+
/// Check if tag is an event `root`
281+
#[inline]
282+
pub fn is_root(&self) -> bool {
283+
matches!(
284+
self.as_standardized(),
285+
Some(TagStandard::Event {
286+
marker: Some(Marker::Root),
287+
..
288+
})
289+
)
290+
}
291+
280292
/// Check if tag is an event `reply`
281293
#[inline]
282294
pub fn is_reply(&self) -> bool {

0 commit comments

Comments
 (0)