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>
impl<K: EventKind<S>, S> InterestSet<K, S>
Sourcepub fn new_filter(filtered: HashSet<K, S>) -> Self
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§
impl<K: Hash + Eq, S: BuildHasher> Eq for InterestSet<K, S>
Source§impl<T, S> HandlerDescription for InterestSet<T, S>
impl<T, S> HandlerDescription for InterestSet<T, S>
Source§fn user_defined() -> Self
fn user_defined() -> Self
Description for a user-defined handler that can do practically
everything.
Source§fn merge_chain(&self, other: &Self) -> Self
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
fn merge_branch(&self, other: &Self) -> Self
Merge descriptions to get a description for a branch handler.
Source§fn filter_async() -> Self
fn filter_async() -> Self
Description for
filter_async. Read moreSource§fn filter_map() -> Self
fn filter_map() -> Self
Description for
filter_map. Read moreSource§fn filter_map_async() -> Self
fn filter_map_async() -> Self
Description for
filter_map_async. Read moreSource§fn inspect_async() -> Self
fn inspect_async() -> Self
Description for
inspect_async. Read moreSource§fn try_filter() -> Self
fn try_filter() -> Self
Description for
try_filter. Read moreSource§fn try_filter_async() -> Self
fn try_filter_async() -> Self
Description for
try_filter_async. Read moreSource§fn try_filter_map() -> Self
fn try_filter_map() -> Self
Description for
try_filter_map. Read moreSource§fn try_filter_map_async() -> Self
fn try_filter_map_async() -> Self
Description for
try_filter_map_async. Read moreSource§fn try_map_async() -> Self
fn try_map_async() -> Self
Description for
try_map_async. Read moreAuto Trait Implementations§
impl<K, S> Freeze for InterestSet<K, S>
impl<K, S> RefUnwindSafe for InterestSet<K, S>where
HashSet<K, S>: RefUnwindSafe,
impl<K, S> Send for InterestSet<K, S>
impl<K, S> Sync for InterestSet<K, S>
impl<K, S> Unpin for InterestSet<K, S>
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> 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