Skip to main content

IdSet

Struct IdSet 

Source
pub struct IdSet<Id: Ord> { /* private fields */ }
Expand description

A membership predicate over a set of ids — the canonical pub/sub filter. contains is true when the set holds id; as a SendPipe it admits (Ok(id)) or rejects (Err(id)) the id flowing through it. Build one as the initial for live_filter and grow it live with FilterUpdate.

Serde-transparent: it round-trips as a bare array of ids, so a subscription’s set is exactly what you load from config or ship over the wire (the config mirror; the layered conflaguration loader attaches at the service that composes this, per the workspace config principle’s layering caveat).

Implementations§

Source§

impl<Id: Ord> IdSet<Id>

Source

pub fn new() -> Self

An empty set — matches nothing.

Source

pub fn from_ids(ids: impl IntoIterator<Item = Id>) -> Self

A set seeded from ids.

Source

pub fn contains(&self, id: &Id) -> bool

Whether id is a member.

Source

pub fn len(&self) -> usize

The number of ids in the set.

Source

pub fn is_empty(&self) -> bool

Whether the set is empty (matches nothing).

Source

pub fn iter(&self) -> impl Iterator<Item = &Id> + '_

Iterate the member ids in sorted order.

Source§

impl<Id: Ord + Clone> IdSet<Id>

Source

pub fn with(&self, id: Id) -> Self

A copy with id added — the copy-on-write step for FilterControl::update.

Source

pub fn without(&self, id: &Id) -> Self

A copy with id removed.

Trait Implementations§

Source§

impl<Id: Clone + Ord> Clone for IdSet<Id>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Id: Debug + Ord> Debug for IdSet<Id>

Source§

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

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

impl<Id: Ord> Default for IdSet<Id>

Source§

fn default() -> Self

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

impl<'de, Id> Deserialize<'de> for IdSet<Id>
where Id: Deserialize<'de> + Ord,

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<Id: Eq + Ord> Eq for IdSet<Id>

Source§

impl<Id: Ord> FromIterator<Id> for IdSet<Id>

Source§

fn from_iter<Iter: IntoIterator<Item = Id>>(iter: Iter) -> Self

Creates a value from an iterator. Read more
Source§

impl<Id: PartialEq + Ord> PartialEq for IdSet<Id>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<Id: Ord + Clone + Debug + Send + Sync + 'static> SendPipe for IdSet<Id>

Source§

type In = Id

Input the pipe consumes.
Source§

type Out = Id

Output the pipe produces.
Source§

type Err = Id

Error the pipe can fail with — Send here so it can cross cores.
Source§

fn call(&self, id: Id) -> impl Future<Output = Result<Id, Id>> + Send

Apply the pipe. The returned future IS Send.
Source§

impl<Id> Serialize for IdSet<Id>
where Id: Serialize + Ord,

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<Id: PartialEq + Ord> StructuralPartialEq for IdSet<Id>

Auto Trait Implementations§

§

impl<Id> Freeze for IdSet<Id>
where BTreeSet<Id>: Freeze,

§

impl<Id> RefUnwindSafe for IdSet<Id>

§

impl<Id> Send for IdSet<Id>
where BTreeSet<Id>: Send,

§

impl<Id> Sync for IdSet<Id>
where BTreeSet<Id>: Sync,

§

impl<Id> Unpin for IdSet<Id>
where BTreeSet<Id>: Unpin,

§

impl<Id> UnsafeUnpin for IdSet<Id>
where BTreeSet<Id>: UnsafeUnpin,

§

impl<Id> UnwindSafe for IdSet<Id>
where BTreeSet<Id>: UnwindSafe,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more