pub struct Fwd<M: 'static>(_);
Expand description
Forwarder for messages of type M
Typically this would be created using one of the fwd_*!
macros.
This may be called many times to forward different messages to the
same end-point. For situations where a callback can be used at
most one time, prefer Ret
, because it is less restrictive on
the types of data that may be captured by the closure.
This is a fat pointer to a ref-counted dynamic Fn
, so it
consumes two usize
locally, and the size of the Fn
closure
plus the ref-count (a usize
) on the heap. It may be cloned
cheaply if another identical Fwd
is required.
For zero arguments, use Fwd<()>
. For one argument, use
Fwd<type>
, where type
is the type of the argument. For two or
more use a tuple: Fwd<(type1, type2...)>
. Call the Fwd::fwd
method to send a message or use the fwd!
macro. Sending a
message typically results in the asynchronous execution of an
actor call, but may have other effects depending on the type of
forwarder.
Implementations§
source§impl<M> Fwd<M>
impl<M> Fwd<M>
sourcepub fn new(f: impl Fn(M) + 'static) -> Self
pub fn new(f: impl Fn(M) + 'static) -> Self
Create a Fwd
instance that performs an arbitrary action
with the message on being called. The call is made
synchronously at the point that the message is forwarded.