Struct dptree::description::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
sourceimpl<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 maplit::hashset;
filter_with_description(InterestSet::new_filter(hashset! {}), || {
println!("Filter called!"); // <-- bad
false
});
filter_with_description(InterestSet::new_filter(hashset! {}), |db: Db| {
let pass = db.fetch_enabled(); // <-- fine
pass
});
Trait Implementations
sourceimpl<K: Clone, S: Clone> Clone for InterestSet<K, S>
impl<K: Clone, S: Clone> Clone for InterestSet<K, S>
sourcefn clone(&self) -> InterestSet<K, S>
fn clone(&self) -> InterestSet<K, S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<K: Debug, S: Debug> Debug for InterestSet<K, S>
impl<K: Debug, S: Debug> Debug for InterestSet<K, S>
sourceimpl<T, S> HandlerDescription for InterestSet<T, S> where
T: EventKind<S> + Eq + Hash + Clone,
S: BuildHasher + Clone,
T: Send + Sync + 'static,
S: Send + Sync + 'static,
impl<T, S> HandlerDescription for InterestSet<T, S> where
T: EventKind<S> + Eq + Hash + Clone,
S: BuildHasher + Clone,
T: Send + Sync + 'static,
S: Send + Sync + 'static,
sourcefn user_defined() -> Self
fn user_defined() -> Self
Description for a user-defined handler that can do practically everything. Read more
sourcefn merge_chain(&self, other: &Self) -> Self
fn merge_chain(&self, other: &Self) -> Self
Merge descriptions to get a description for a chain handler.
sourcefn merge_branch(&self, other: &Self) -> Self
fn merge_branch(&self, other: &Self) -> Self
Merge descriptions to get a description for a branch handler.
sourcefn filter_async() -> Self
fn filter_async() -> Self
Description for filter_async
. Read more
sourcefn filter_map() -> Self
fn filter_map() -> Self
Description for filter_map
. Read more
sourcefn filter_map_async() -> Self
fn filter_map_async() -> Self
Description for filter_map_async
. Read more
sourcefn inspect_async() -> Self
fn inspect_async() -> Self
Description for inspect_async
. Read more
sourceimpl<K: Hash + Eq, S: BuildHasher> PartialEq<InterestSet<K, S>> for InterestSet<K, S>
impl<K: Hash + Eq, S: BuildHasher> PartialEq<InterestSet<K, S>> for InterestSet<K, S>
impl<K: Hash + Eq, S: BuildHasher> Eq for InterestSet<K, S>
Auto Trait Implementations
impl<K, S> RefUnwindSafe for InterestSet<K, S> where
K: RefUnwindSafe,
S: RefUnwindSafe,
impl<K, S> Send for InterestSet<K, S> where
K: Send,
S: Send,
impl<K, S> Sync for InterestSet<K, S> where
K: Sync,
S: Sync,
impl<K, S> Unpin for InterestSet<K, S> where
K: Unpin,
S: Unpin,
impl<K, S> UnwindSafe for InterestSet<K, S> where
K: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more