pub struct CommunicationHub { /* private fields */ }Expand description
Communication hub for managing multiple agent channels
Implementations§
Source§impl CommunicationHub
impl CommunicationHub
Sourcepub async fn register_agent(&self, agent_id: String) -> Result<()>
pub async fn register_agent(&self, agent_id: String) -> Result<()>
Register an agent with the hub
Sourcepub async fn unregister_agent(&self, agent_id: &str) -> Result<()>
pub async fn unregister_agent(&self, agent_id: &str) -> Result<()>
Unregister an agent from the hub
Sourcepub async fn send_message(
&self,
from: String,
to: String,
message: AgentMessage,
) -> Result<()>
pub async fn send_message( &self, from: String, to: String, message: AgentMessage, ) -> Result<()>
Send a message from one agent to another
Sourcepub async fn broadcast(&self, from: String, message: AgentMessage) -> Result<()>
pub async fn broadcast(&self, from: String, message: AgentMessage) -> Result<()>
Broadcast a message to all agents
Sourcepub async fn receive_message(&self, agent_id: &str) -> Option<MessageEnvelope>
pub async fn receive_message(&self, agent_id: &str) -> Option<MessageEnvelope>
Receive a message for a specific agent
Sourcepub async fn try_receive_message(
&self,
agent_id: &str,
) -> Option<MessageEnvelope>
pub async fn try_receive_message( &self, agent_id: &str, ) -> Option<MessageEnvelope>
Try to receive a message without blocking
Sourcepub async fn agent_count(&self) -> usize
pub async fn agent_count(&self) -> usize
Get the number of registered agents
Sourcepub async fn list_agents(&self) -> Vec<String>
pub async fn list_agents(&self) -> Vec<String>
Get list of registered agent IDs
Sourcepub async fn is_registered(&self, agent_id: &str) -> bool
pub async fn is_registered(&self, agent_id: &str) -> bool
Check if an agent is registered
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CommunicationHub
impl !RefUnwindSafe for CommunicationHub
impl Send for CommunicationHub
impl Sync for CommunicationHub
impl Unpin for CommunicationHub
impl UnsafeUnpin for CommunicationHub
impl !UnwindSafe for CommunicationHub
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more