pub enum Effect<R: RoleId, M> {
Send {
to: R,
msg: M,
},
Recv {
from: R,
msg_tag: MessageTag,
},
Choose {
at: R,
label: <R as RoleId>::Label,
},
Offer {
from: R,
},
Branch {
choosing_role: R,
branches: Vec<(<R as RoleId>::Label, Program<R, M>)>,
},
Loop {
iterations: Option<usize>,
body: Box<Program<R, M>>,
},
Timeout {
at: R,
dur: Duration,
body: Box<Program<R, M>>,
on_timeout: Option<Box<Program<R, M>>>,
},
Parallel {
programs: Vec<Program<R, M>>,
},
Extension(Box<dyn ExtensionEffect<R>>),
End,
}Expand description
A choreographic effect that can be performed by a role
Variants§
Send
Send a message to another role
Recv
Receive a message from another role
Choose
Make an internal choice and broadcast the label
Offer
Wait for an external choice from another role
Fields
from: RBranch
Branch based on a choice - includes all possible continuations The choosing role has already selected via Choose effect Other roles use Offer to receive the label, then select matching branch
Loop
Loop that executes body a fixed number of times or until a condition
Fields
Timeout
Execute a sub-program with a timeout
If on_timeout is Some, executes that program when timeout occurs.
Otherwise, the handler decides what to do on timeout (typically error).
Fields
at: RParallel
Execute multiple programs using deterministic normalized ordering.
The interpreter executes sub-programs in declaration order. This keeps behavior reproducible across runtimes while preserving the high-level “parallel composition” intent.
Extension(Box<dyn ExtensionEffect<R>>)
Extension effect for domain-specific operations
Extensions are boxed trait objects that implement ExtensionEffect.
Use Effect::ext() or Program::ext() for construction.
§Type Safety
Extensions are identified by TypeId and use trait object downcasting
for type-safe access. Unknown extensions cause runtime errors (fail-fast).
§Projection
Extensions project based on participating_roles():
- Empty roles → appears in all projections
- Non-empty → appears only in specified role projections
End
End of program
Implementations§
Source§impl<R: RoleId, M> Effect<R, M>
Extension effect helper methods
impl<R: RoleId, M> Effect<R, M>
Extension effect helper methods
Sourcepub fn ext<E: ExtensionEffect<R> + 'static>(extension: E) -> Self
pub fn ext<E: ExtensionEffect<R> + 'static>(extension: E) -> Self
Create an extension effect from any type implementing ExtensionEffect
Sourcepub fn is_extension<E: ExtensionEffect<R> + 'static>(&self) -> bool
pub fn is_extension<E: ExtensionEffect<R> + 'static>(&self) -> bool
Check if this is an extension effect of a specific type
Sourcepub fn as_extension<E: ExtensionEffect<R> + 'static>(&self) -> Option<&E>
pub fn as_extension<E: ExtensionEffect<R> + 'static>(&self) -> Option<&E>
Extract extension data with type checking
Returns Some(&E) if this is an extension of type E, None otherwise.
Sourcepub fn as_extension_mut<E: ExtensionEffect<R> + 'static>(
&mut self,
) -> Option<&mut E>
pub fn as_extension_mut<E: ExtensionEffect<R> + 'static>( &mut self, ) -> Option<&mut E>
Extract mutable extension data with type checking
Sourcepub fn extension_type_id(&self) -> Option<TypeId>
pub fn extension_type_id(&self) -> Option<TypeId>
Get the TypeId of an extension effect