Skip to main content

InterestSet

Struct InterestSet 

Source
pub struct InterestSet<K, S = RandomState> {
    pub observed: HashSet<K, S>,
    pub filtered: HashSet<K, S>,
}
Expand description

Description for a handler that describes what event kinds are interesting to the handler.

This can be useful if you can filter events before they are passed to dptree. In this case you should keep updates that are in the observed set.

Fields§

§observed: HashSet<K, S>

Event kinds that are of interested for a given handler.

I.e. the ones that can cause meaningful side-effects.

§filtered: HashSet<K, S>

Event kinds that can be observed by handlers chained to this one.

Implementations§

Source§

impl<K: EventKind<S>, S> InterestSet<K, S>

Source

pub fn new_filter(filtered: HashSet<K, S>) -> Self

Constructs an InterestSet for a filter that allows to pass through it only updates with kinds in the filtered set.

Note that the filter should not have observable side-effects, for example:

use dptree::{description::{InterestSet, EventKind}, filter_with_description};
use std::collections::HashSet;

filter_with_description(InterestSet::new_filter(HashSet::new()), || {
    println!("Filter called!"); // <-- bad

    false
});

filter_with_description(InterestSet::new_filter(HashSet::new()), |db: Db| {
    let pass = db.fetch_enabled(); // <-- fine

    pass
});

Trait Implementations§

Source§

impl<K: Clone, S: Clone> Clone for InterestSet<K, S>

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<K: Debug, S: Debug> Debug for InterestSet<K, S>

Source§

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

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

impl<K: Hash + Eq, S: BuildHasher> Eq for InterestSet<K, S>

Source§

impl<T, S> HandlerDescription for InterestSet<T, S>
where T: EventKind<S> + Eq + Hash + Clone + Send + Sync + 'static, S: BuildHasher + Clone + Send + Sync + 'static,

Source§

fn entry() -> Self

Description for entry.
Source§

fn user_defined() -> Self

Description for a user-defined handler that can do practically everything.
Source§

fn endpoint() -> Self

Description for endpoint. Read more
Source§

fn merge_chain(&self, other: &Self) -> Self

Merge descriptions to get a description for a chain handler.
Source§

fn merge_branch(&self, other: &Self) -> Self

Merge descriptions to get a description for a branch handler.
Source§

fn map() -> Self

Description for map. Read more
Source§

fn map_async() -> Self

Description for map_async. Read more
Source§

fn filter() -> Self

Description for filter. Read more
Source§

fn filter_async() -> Self

Description for filter_async. Read more
Source§

fn filter_map() -> Self

Description for filter_map. Read more
Source§

fn filter_map_async() -> Self

Description for filter_map_async. Read more
Source§

fn inspect() -> Self

Description for inspect. Read more
Source§

fn inspect_async() -> Self

Description for inspect_async. Read more
Source§

fn try_filter() -> Self

Description for try_filter. Read more
Source§

fn try_filter_async() -> Self

Description for try_filter_async. Read more
Source§

fn try_filter_map() -> Self

Description for try_filter_map. Read more
Source§

fn try_filter_map_async() -> Self

Source§

fn try_map() -> Self

Description for try_map. Read more
Source§

fn try_map_async() -> Self

Description for try_map_async. Read more
Source§

impl<K: Hash + Eq, S: BuildHasher> PartialEq for InterestSet<K, S>

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

Auto Trait Implementations§

§

impl<K, S> Freeze for InterestSet<K, S>
where HashSet<K, S>: Freeze,

§

impl<K, S> RefUnwindSafe for InterestSet<K, S>
where HashSet<K, S>: RefUnwindSafe,

§

impl<K, S> Send for InterestSet<K, S>
where HashSet<K, S>: Send,

§

impl<K, S> Sync for InterestSet<K, S>
where HashSet<K, S>: Sync,

§

impl<K, S> Unpin for InterestSet<K, S>
where HashSet<K, S>: Unpin,

§

impl<K, S> UnsafeUnpin for InterestSet<K, S>
where HashSet<K, S>: UnsafeUnpin,

§

impl<K, S> UnwindSafe for InterestSet<K, S>
where HashSet<K, S>: 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> 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> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSync for T
where T: Sync + ?Sized,

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.