#[non_exhaustive]pub enum Token<'a> {
Text(&'a str),
Nostr(Nip21),
Url(Url),
Hashtag(&'a str),
LineBreak,
}Expand description
One unit produced by NostrParser::parse.
Lifetimes:
TextandHashtagborrow directly from the input string so the parser can operate without copying.NostrandUrlare owned because their parsed form requires an allocation (Nip21’s relay-hint vectors,Url’s normalised string).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Text(&'a str)
Plain text run that did not match any other token. Empty strings are never emitted; the parser collapses zero-length gaps between adjacent matches.
Nostr(Nip21)
A successfully-decoded NIP-21 nostr: URI.
Url(Url)
A successfully-parsed URL.
Hashtag(&'a str)
A #hashtag whose body is the slice without the leading
#. Empty hashtags (a bare #) fall through as text.
LineBreak
A \n byte at the current position.
Trait Implementations§
impl<'a> Eq for Token<'a>
impl<'a> StructuralPartialEq for Token<'a>
Auto Trait Implementations§
impl<'a> Freeze for Token<'a>
impl<'a> RefUnwindSafe for Token<'a>
impl<'a> Send for Token<'a>
impl<'a> Sync for Token<'a>
impl<'a> Unpin for Token<'a>
impl<'a> UnsafeUnpin for Token<'a>
impl<'a> UnwindSafe for Token<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.