Function dptree::filter_map_async
source · [−]pub fn filter_map_async<'a, Projection, Input, Output, NewType, Args, Descr>(
proj: Projection
) -> Handler<'a, Input, Output, Descr> where
Input: Clone,
Projection: Injectable<Input, Option<NewType>, Args> + Send + Sync + 'a,
Input: Insert<NewType> + Send + 'a,
Output: 'a,
Descr: HandlerDescription,
NewType: Send,
Expand description
The asynchronous version of filter_map
.
Examples found in repository?
examples/simple_dispatcher.rs (lines 91-96)
90 91 92 93 94 95 96 97 98 99 100 101
fn set_value_handler() -> CommandHandler {
dptree::filter_map_async(|event: Event| async move {
match event {
Event::SetValue(value) => Some(value),
_ => None,
}
})
.endpoint(move |value: i32, store: Arc<AtomicI32>| async move {
store.store(value, Ordering::SeqCst);
format!("{} stored", value)
})
}