Filter

Struct Filter 

Source
pub struct Filter {
    pub ids: Option<BTreeSet<EventId>>,
    pub authors: Option<BTreeSet<PublicKey>>,
    pub kinds: Option<BTreeSet<Kind>>,
    pub search: Option<String>,
    pub since: Option<Timestamp>,
    pub until: Option<Timestamp>,
    pub limit: Option<usize>,
    pub generic_tags: BTreeMap<SingleLetterTag, BTreeSet<String>>,
}
Expand description

Fields§

§ids: Option<BTreeSet<EventId>>

List of EventId

§authors: Option<BTreeSet<PublicKey>>

List of PublicKey

§kinds: Option<BTreeSet<Kind>>

List of a kind numbers

§search: Option<String>

It’s a string describing a query in a human-readable form, i.e. “best nostr apps”

https://github.com/nostr-protocol/nips/blob/master/50.md

§since: Option<Timestamp>

An integer unix timestamp, events must be newer than this to pass

§until: Option<Timestamp>

An integer unix timestamp, events must be older than this to pass

§limit: Option<usize>

Maximum number of events to be returned in the initial query

§generic_tags: BTreeMap<SingleLetterTag, BTreeSet<String>>

Generic tag queries

Implementations§

Source§

impl Filter

Source

pub fn new() -> Self

Create new empty Filter

Source

pub fn id(self, id: EventId) -> Self

Add EventId

Source

pub fn ids<I>(self, ids: I) -> Self
where I: IntoIterator<Item = EventId>,

Add event ids or prefixes

Source

pub fn remove_ids<I>(self, ids: I) -> Self
where I: IntoIterator<Item = EventId>,

Remove event ids

Source

pub fn author(self, author: PublicKey) -> Self

Add author

Source

pub fn authors<I>(self, authors: I) -> Self
where I: IntoIterator<Item = PublicKey>,

Add authors

Source

pub fn remove_authors<I>(self, authors: I) -> Self
where I: IntoIterator<Item = PublicKey>,

Remove authors

Source

pub fn kind(self, kind: Kind) -> Self

Add kind

Source

pub fn kinds<I>(self, kinds: I) -> Self
where I: IntoIterator<Item = Kind>,

Add kinds

Source

pub fn remove_kinds<I>(self, kinds: I) -> Self
where I: IntoIterator<Item = Kind>,

Remove kinds

Source

pub fn event(self, id: EventId) -> Self

Add event

Source

pub fn events<I>(self, events: I) -> Self
where I: IntoIterator<Item = EventId>,

Add events

Source

pub fn remove_events<I>(self, events: I) -> Self
where I: IntoIterator<Item = EventId>,

Remove events

Source

pub fn pubkey(self, pubkey: PublicKey) -> Self

Add pubkey

Source

pub fn pubkeys<I>(self, pubkeys: I) -> Self
where I: IntoIterator<Item = PublicKey>,

Add pubkeys

Source

pub fn remove_pubkeys<I>(self, pubkeys: I) -> Self
where I: IntoIterator<Item = PublicKey>,

Remove pubkeys

Source

pub fn hashtag<S>(self, hashtag: S) -> Self
where S: Into<String>,

Source

pub fn hashtags<I, S>(self, hashtags: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn remove_hashtags<I, S>(self, hashtags: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Remove hashtags

Source

pub fn reference<S>(self, reference: S) -> Self
where S: Into<String>,

Source

pub fn references<I, S>(self, references: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn remove_references<I, S>(self, references: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Remove references

Source

pub fn identifier<S>(self, identifier: S) -> Self
where S: Into<String>,

Source

pub fn identifiers<I, S>(self, identifiers: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn remove_identifiers<I, S>(self, identifiers: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Source

pub fn coordinate(self, coordinate: &Coordinate) -> Self

Source

pub fn coordinates<'a, I>(self, coordinates: I) -> Self
where I: IntoIterator<Item = &'a Coordinate>,

Source

pub fn remove_coordinates<'a, I>(self, coordinates: I) -> Self
where I: IntoIterator<Item = &'a Coordinate>,

Source

pub fn search<S>(self, value: S) -> Self
where S: Into<String>,

Add search field

Remove search

Source

pub fn since(self, since: Timestamp) -> Self

Add since unix timestamp

Source

pub fn remove_since(self) -> Self

Remove since

Source

pub fn until(self, until: Timestamp) -> Self

Add until unix timestamp

Source

pub fn remove_until(self) -> Self

Remove until

Source

pub fn limit(self, limit: usize) -> Self

Add limit

Maximum number of events to be returned in the initial query

Source

pub fn remove_limit(self) -> Self

Remove limit

Source

pub fn custom_tag<S>(self, tag: SingleLetterTag, value: S) -> Self
where S: Into<String>,

Add custom tag

Source

pub fn custom_tags<I, S>(self, tag: SingleLetterTag, values: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Add custom tags

Source

pub fn remove_custom_tags<I, T>(self, tag: SingleLetterTag, values: I) -> Self
where I: IntoIterator<Item = T>, T: Into<String>,

Remove custom tag

Source

pub fn is_empty(&self) -> bool

Check if Filter is empty

Source

pub fn extract_public_keys(&self) -> BTreeSet<PublicKey>

Extract all public keys (both from authors and #p)

Source

pub fn match_event(&self, event: &Event, opts: MatchEventOptions) -> bool

Determine if Filter match given Event.

Trait Implementations§

Source§

impl Clone for Filter

Source§

fn clone(&self) -> Filter

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Filter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Filter

Source§

fn default() -> Filter

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Filter

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&Coordinate> for Filter

Source§

fn from(value: &Coordinate) -> Self

Converts to this type from the input type.
Source§

impl From<Coordinate> for Filter

Source§

fn from(value: Coordinate) -> Self

Converts to this type from the input type.
Source§

impl From<Filter> for Vec<Filter>

Source§

fn from(filter: Filter) -> Self

Converts to this type from the input type.
Source§

impl Hash for Filter

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl JsonUtil for Filter

Source§

type Err = Error

Error
Source§

fn from_json<T>(json: T) -> Result<Self, Self::Err>
where T: AsRef<[u8]>,

Deserialize JSON
Source§

fn as_json(&self) -> String

Serialize as JSON string Read more
Source§

fn try_as_json(&self) -> Result<String, Self::Err>

Serialize as JSON string
Source§

fn as_pretty_json(&self) -> String

Serialize as pretty JSON string Read more
Source§

fn try_as_pretty_json(&self) -> Result<String, Self::Err>

Serialize as pretty JSON string
Source§

impl Ord for Filter

Source§

fn cmp(&self, other: &Filter) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Filter

Source§

fn eq(&self, other: &Filter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Filter

Source§

fn partial_cmp(&self, other: &Filter) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Filter

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Filter

Source§

impl StructuralPartialEq for Filter

Auto Trait Implementations§

§

impl Freeze for Filter

§

impl RefUnwindSafe for Filter

§

impl Send for Filter

§

impl Sync for Filter

§

impl Unpin for Filter

§

impl UnwindSafe for Filter

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,