nostrdb-rs

nostrdb in rust!
git clone git://jb55.com/nostrdb-rs
Log | Files | Refs | Submodules | README | LICENSE

commit 2fbcd1bf318c0121af108bcb7f8e4d43b8c166f0
parent 785b618816cc8e6aee467d8688b0813416d63c84
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 24 Jul 2025 12:03:36 -0700

nip10: a few cleanups

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/util/nip10.rs | 24+++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/src/util/nip10.rs b/src/util/nip10.rs @@ -187,9 +187,7 @@ fn tags_to_note_reply<'a>(tags: Tags<'a>) -> NoteReply<'a> { break; } - let note_ref = if let Ok(note_ref) = tag_to_noteid_ref(tag, index as u16) { - note_ref - } else { + let Ok(note_ref) = tag_to_noteid_ref(tag, index as u16) else { continue; }; @@ -220,25 +218,13 @@ pub fn tag_to_noteid_ref(tag: Tag<'_>, index: u16) -> Result<NoteIdRef<'_>, Erro return Err(Error::DecodeError); } - if tag.get_unchecked(0).variant().str() != Some("e") { + if tag.get_str(0) != Some("e") { return Err(Error::DecodeError); } - let id = tag - .get_unchecked(1) - .variant() - .id() - .ok_or(Error::DecodeError)?; - - let relay = tag - .get(2) - .and_then(|t| t.variant().str()) - .filter(|x| !x.is_empty()); - - let marker = tag - .get(3) - .and_then(|t| t.variant().str()) - .and_then(Marker::new); + let id = tag.get_id(1).ok_or(Error::DecodeError)?; + let relay = tag.get_str(2).filter(|x| !x.is_empty()); + let marker = tag.get_str(3).and_then(Marker::new); Ok(NoteIdRef { index,