pub trait Engine {
type Writer;
type Reader;
type Channel: Send + Sync + Clone;
// Required methods
fn schedule<B: Block<Writer = Self::Writer, Reader = Self::Reader> + 'static>(
&mut self,
block: B,
);
fn load_blocks_and_links(
&mut self,
blocks: &[BlockData],
links: &[LinkData],
) -> Result<()>;
async fn run(&mut self);
fn create_message_channel(
&mut self,
sender_id: Uuid,
sender_channel: Self::Channel,
) -> Self::Channel;
}
Expand description
Specifies the interface for an engine that implements the block execution logic.
Required Associated Types§
Required Methods§
Sourcefn schedule<B: Block<Writer = Self::Writer, Reader = Self::Reader> + 'static>(
&mut self,
block: B,
)
fn schedule<B: Block<Writer = Self::Writer, Reader = Self::Reader> + 'static>( &mut self, block: B, )
Schedule a block to be executed by this engine. This operation can be performed while the engine is running.
Sourcefn load_blocks_and_links(
&mut self,
blocks: &[BlockData],
links: &[LinkData],
) -> Result<()>
fn load_blocks_and_links( &mut self, blocks: &[BlockData], links: &[LinkData], ) -> Result<()>
Load the blocks and links into the engine. This operation should be performed before the engine is run.
Sourceasync fn run(&mut self)
async fn run(&mut self)
Runs the event loop of this engine an execute the blocks that where scheduled
Sourcefn create_message_channel(
&mut self,
sender_id: Uuid,
sender_channel: Self::Channel,
) -> Self::Channel
fn create_message_channel( &mut self, sender_id: Uuid, sender_channel: Self::Channel, ) -> Self::Channel
Get a handle to this engines messaging system so external systems can communicate with this engine once the engine will run.
§Arguments
- sender_id The sender unique id.
- sender_channel The sender chanel to send notifications from the engine.
§Returns
A sender chanel that is used to send messages to the engine.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.