pub struct MessageAdapterWithRoute<Input, Route>where
Route: DeliveryRoute,{ /* private fields */ }Expand description
A pure actor that maps one input protocol into one destination protocol.
For every accepted Input, the adapter invokes its function pointer exactly
once. If that invocation returns normally, the transition emits exactly one
effect selected by DeliveryRoute and continues with the same behavior.
A logical recipient produces Delivery and an established recipient
produces EstablishedDelivery. Initialization emits no effects; the
adapter cannot create actors, enter another phase, stop itself, or return a
controlled error. In particular, it cannot address a creator-local child:
its behavior::NoBirths algebra supplies no local binding for an
interpreter to resolve.
This is a derived Bombay protocol composition, not an additional actor-model primitive. Delivery is interpreted as an ordinary actor communication, so the destination observes the adapter actor as the sender. The adapter has no channel, runtime handle, task, I/O, or hidden effect.
The mapper is deliberately a function pointer rather than a closure or
erased callable. Consequently, the complete adapter type remains nameable
in birth products, child products, supervisors, and topology evidence. If
the mapper panics, unwinding follows the same runtime policy as a panic from
any other Behavior fold; no successful Actions value is returned.
A creator-local child route is not a valid standalone adapter destination:
struct Destination;
impl behavior::Protocol for Destination {
type Addr = behavior::MailAddr;
type Msg = u16;
}
fn adapt(value: u8) -> u16 { u16::from(value) }
let destination = behavior::Recipient::<Destination>::global(behavior::MailAddr(1));
let _ = behavior_actors::MessageAdapterWithRoute::new(destination, adapt);struct Destination;
impl behavior::Protocol for Destination {
type Addr = behavior::MailAddr;
type Msg = u16;
}
fn adapt(value: u8) -> u16 { u16::from(value) }
let mut sequence = behavior::CreationSequence::new();
let creation = sequence.issue().expect("fixture creation ID");
let child = behavior::ChildDelivery::<Destination, behavior::ChildHead>::after(creation, 1);
let _ = behavior_actors::MessageAdapterWithRoute::new(child, adapt);