pub struct SearchQuery {
pub free_text: String,
pub extensions: Vec<SearchExtension>,
}Expand description
Typed NIP-50 query: free text + zero or more extension tokens.
Fields§
§free_text: StringWhatever the relay’s search backend interprets as a natural language query. Whitespace is preserved as-is (the wire format does the same).
extensions: Vec<SearchExtension>Spec-named or forward-compatible extension tokens, in the order they were inserted / parsed.
Implementations§
Source§impl SearchQuery
impl SearchQuery
Sourcepub fn with_extension(self, ext: SearchExtension) -> Self
pub fn with_extension(self, ext: SearchExtension) -> Self
Append one extension. Order is preserved on render.
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render to the NIP-50 wire form. Extensions follow the free text, single-spaced.
Sourcepub fn parse(query: &str) -> Self
pub fn parse(query: &str) -> Self
Parse a NIP-50 wire string into a typed query.
The parser is lenient: tokens that do not look like
extensions flow into free_text, and unknown extension keys
surface as SearchExtension::Other so a relay’s bespoke
extension never lands in the free-text bucket by accident.
The only token-level error is a malformed known extension
(currently only nsfw:), which is silently dropped after
emitting a tracing event so callers cannot lose the
surrounding query.
Trait Implementations§
Source§impl Clone for SearchQuery
impl Clone for SearchQuery
Source§fn clone(&self) -> SearchQuery
fn clone(&self) -> SearchQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SearchQuery
impl Debug for SearchQuery
Source§impl Default for SearchQuery
impl Default for SearchQuery
Source§fn default() -> SearchQuery
fn default() -> SearchQuery
impl Eq for SearchQuery
Source§impl PartialEq for SearchQuery
impl PartialEq for SearchQuery
Source§fn eq(&self, other: &SearchQuery) -> bool
fn eq(&self, other: &SearchQuery) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for SearchQuery
Auto Trait Implementations§
impl Freeze for SearchQuery
impl RefUnwindSafe for SearchQuery
impl Send for SearchQuery
impl Sync for SearchQuery
impl Unpin for SearchQuery
impl UnsafeUnpin for SearchQuery
impl UnwindSafe for SearchQuery
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
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
key and return true if they are equal.