pub trait Mesh: Send + Sync {
// Required methods
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn add_agent<'life0, 'async_trait>(
&'life0 self,
agent: Box<dyn Agent>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
message: Message,
target: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
}Expand description
Trait for agent coordination and message routing.
A mesh manages a collection of agents and handles communication between them.
The primary implementation is [ceylon_local::LocalMesh] for single-process scenarios.
§Lifecycle
- Create a mesh with
new() - Add agents with
add_agent() - Start the mesh with
start()- callson_startfor all agents - Send messages with
send() - Stop the mesh with
stop()- callson_stopfor all agents
§Example
use ceylon_local::LocalMesh;
use ceylon_core::Mesh;
let mesh = LocalMesh::new("my-mesh");
// mesh.add_agent(Box::new(my_agent)).await?;
mesh.start().await?;
// ... use the mesh ...
mesh.stop().await?;Required Methods§
Sourcefn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn start<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Start the mesh and all registered agents.
Calls on_start for each agent.
Sourcefn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn stop<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Stop the mesh and all agents.
Calls on_stop for each agent.
Sourcefn add_agent<'life0, 'async_trait>(
&'life0 self,
agent: Box<dyn Agent>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn add_agent<'life0, 'async_trait>(
&'life0 self,
agent: Box<dyn Agent>,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Add an agent to the mesh.
The agent will be started when start() is called, or immediately
if the mesh is already running.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".