pub trait ReactorBehavior {
// Required methods
fn id(&self) -> ReactorId;
fn react(
&mut self,
ctx: &mut ReactionCtx<'_, '_>,
local_rid: LocalReactionId,
);
fn cleanup_tag(&mut self, ctx: &CleanupCtx);
}Expand description
The trait used by the framework to interact with the reactor during runtime.
Importantly, it’s object-safe and has no type parameters
or associated types. This allows us to wrap it into a
Box<dyn ReactorBehavior>.
Required Methods§
Sourcefn id(&self) -> ReactorId
fn id(&self) -> ReactorId
The unique ID of this reactor. This is given by the framework upon construction.
Sourcefn react(&mut self, ctx: &mut ReactionCtx<'_, '_>, local_rid: LocalReactionId)
fn react(&mut self, ctx: &mut ReactionCtx<'_, '_>, local_rid: LocalReactionId)
Execute a single user-written reaction. Dispatches on the reaction id, and unpacks parameters, which are the reactor components declared as fields of this struct.
It must always be the case that local_rid < Self::MAX_REACTION_ID,
where Self::MAX_REACTION_ID is defined by the assembly::ReactorInitializer,
because of object safety.
Sourcefn cleanup_tag(&mut self, ctx: &CleanupCtx)
fn cleanup_tag(&mut self, ctx: &CleanupCtx)
Acknowledge that the given tag is done executing and free resources if need be.