pub struct MapSignal<T> { /* private fields */ }
Expand description
Block which applies a closure to every received Message
(e.g.
Signal
) before sending it further.
Note that this block doesn’t allow to specify how RecvError
s are
handled. Thus in in many cases, it is better to implement a custom type as
Consumer
/Producer
(see Nop
for an example) instead of using
this block.
See also MapSample
for a block which performs the operation on a
per-sample basis and may be better suited when wanting to apply a function
to each sample.
Implementations§
source§impl<T> MapSignal<T>where
T: Message + Send + 'static,
impl<T> MapSignal<T>where
T: Message + Send + 'static,
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a block which doesn’t modify the received messages (e.g. which
doesn’t modify the Signal
s)
sourcepub fn with_closure<F>(closure: F) -> Selfwhere
F: FnMut(T) -> T + Send + 'static,
pub fn with_closure<F>(closure: F) -> Selfwhere
F: FnMut(T) -> T + Send + 'static,
Creates a block which applies the given closure
to each message (e.g.
to each Signal
)
sourcepub fn set_closure<F>(&self, closure: F)where
F: FnMut(T) -> T + Send + 'static,
pub fn set_closure<F>(&self, closure: F)where
F: FnMut(T) -> T + Send + 'static,
Modifies the used closure
, which is applied to every sample
Trait Implementations§
source§impl<T> Consumer<T> for MapSignal<T>
impl<T> Consumer<T> for MapSignal<T>
source§fn receiver_connector(&self) -> &ReceiverConnector<T>
fn receiver_connector(&self) -> &ReceiverConnector<T>
Obtain reference to
ReceiverConnector
source§fn feed_from_none(&self)
fn feed_from_none(&self)
Disconnect
Consumer
from any connected Producer
if connectedsource§impl<T> Producer<T> for MapSignal<T>
impl<T> Producer<T> for MapSignal<T>
source§fn sender_connector(&self) -> &SenderConnector<T>
fn sender_connector(&self) -> &SenderConnector<T>
Obtain reference to
SenderConnector