pub struct Filter<F, T, const BATCH: usize> { /* private fields */ }Expand description
A Listener which transforms or discards messages before passing them on to another
Listener.
Construct this by calling Listener::filter(); see its documentation for more information.
§Generic parameters
Fis the type of the filter function to use.Tis the type of the listener to pass filtered messages to.BATCHis the maximum number of filtered messages to gather before passing them on. It is used as the size of a stack-allocated array, so should be chosen with the size of the message type in mind.
Implementations§
Source§impl<F, T> Filter<F, T, 1>
impl<F, T> Filter<F, T, 1>
Sourcepub fn with_stack_buffer<const BATCH: usize>(self) -> Filter<F, T, BATCH>
pub fn with_stack_buffer<const BATCH: usize>(self) -> Filter<F, T, BATCH>
Request that the filter accumulate output messages into a batch.
This causes each receive operation to allocate an array [MO; BATCH]
on the stack, where MO is the output message type produced by F.
Therefore, the buffer size should be chosen keeping the size of MO in mind.
Also, the amount of buffer used cannot exceed the size of the input batch,
so it is not useful to choose a buffer size larger than the expected batch size.
If MO is a zero-sized type, then the buffer is always unbounded,
so with_stack_buffer() has no effect and is unnecessary in that case.
Trait Implementations§
Source§impl<MI, MO, F, T, const BATCH: usize> FromListener<Filter<F, T, BATCH>, MI> for Filter<F, T, BATCH>
impl<MI, MO, F, T, const BATCH: usize> FromListener<Filter<F, T, BATCH>, MI> for Filter<F, T, BATCH>
Source§fn from_listener(listener: Filter<F, T, BATCH>) -> Self
fn from_listener(listener: Filter<F, T, BATCH>) -> Self
No-op conversion returning the listener unchanged.
Source§impl<MI, MO, F, T, const BATCH: usize> Listener<MI> for Filter<F, T, BATCH>
impl<MI, MO, F, T, const BATCH: usize> Listener<MI> for Filter<F, T, BATCH>
Source§fn receive(&self, messages: &[MI]) -> bool
fn receive(&self, messages: &[MI]) -> bool
Auto Trait Implementations§
impl<F, T, const BATCH: usize> Freeze for Filter<F, T, BATCH>
impl<F, T, const BATCH: usize> RefUnwindSafe for Filter<F, T, BATCH>where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<F, T, const BATCH: usize> Send for Filter<F, T, BATCH>
impl<F, T, const BATCH: usize> Sync for Filter<F, T, BATCH>
impl<F, T, const BATCH: usize> Unpin for Filter<F, T, BATCH>
impl<F, T, const BATCH: usize> UnwindSafe for Filter<F, T, BATCH>where
F: UnwindSafe,
T: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<LIn, LOut, M> IntoListener<LOut, M> for LIn
impl<LIn, LOut, M> IntoListener<LOut, M> for LIn
Source§fn into_listener(self) -> LOut
fn into_listener(self) -> LOut
Listener into a type-erased form of type L.