macro_rules! fwd_to { ($($x:tt)*) => { ... }; }
Expand description
Create a Fwd
instance for actor calls
The syntax is similar to that used for call!
, except that the
call is followed by as
and a tuple of argument types (which may
be empty). These types are the types of the arguments accepted by
the Fwd
instance when it is called, and which are appended to
the argument list of the method call. So each call to a method is
made up of first the fixed arguments (if any) provided at the time
the Fwd
instance was created, followed by the variable arguments
(if any) provided when the Fwd
instance was called. This must
match the signature of the method itself.
as
is used here because this is a standard Rust token that can
introduce a tuple and so rustfmt
can format the code, although
something like with
would make more sense.
// Forward to a method in this actor or in another actor
fwd_to!([cx], method(arg1, arg2...) as (type1, type2...));
fwd_to!([actorxx], method(arg1, arg2...) as (type1, type2...));
// Forward to a method whilst in the 'Prep' state
fwd_to!([cx], Self::method(arg1, arg2...) as (type1, type2...));
fwd_to!([cx], <path::Type>::method(arg1, arg2...) as (type1, type2...));
fwd_to!([actoryy], Type::method(arg1, arg2...) as (type1, type2...));
fwd_to!([actorzz], <path::Type>::method(arg1, arg2...) as (type1, type2...));
// Forward a call to inline code which refers to this actor. In
// this case the `Fwd` argument list is extracted from the closure
// argument list and no `as` section is required. Closure is
// always treated as a `move` closure.
fwd_to!([cx], |this, cx, arg1: type1, arg2: type2...| ...code...);
Implemented using Fwd::to_actor
or Fwd::to_actor_prep
.