pub struct AgentHandle {
pub parent: Option<Box<AgentHandle>>,
pub broker: Box<Option<AgentHandle>>,
/* private fields */
}Expand description
Represents the context in which an actor operates.
Fields§
§parent: Option<Box<AgentHandle>>The actor’s optional parent context.
broker: Box<Option<AgentHandle>>The system broker for the actor.
Implementations§
Source§impl AgentHandle
impl AgentHandle
Sourcepub async fn supervise<State: Default + Send + Debug>(
&self,
child: ManagedAgent<Idle, State>,
) -> Result<AgentHandle>
pub async fn supervise<State: Default + Send + Debug>( &self, child: ManagedAgent<Idle, State>, ) -> Result<AgentHandle>
Supervises a child actor by activating it and tracking its context.
This asynchronous method adds a child actor to the supervision hierarchy managed by this
ActorRef. It performs the following steps:
- Logs the addition of the child actor with its unique identifier (
ern). - Activates the child actor by calling its
activatemethod asynchronously. - Retrieves the
ern(unique identifier) from the child’s context. - Inserts the child’s context into the
childrenmap of the supervising actor, using theernas the key.
§Type Parameters
State: Represents the state type associated with the child actor. It must implement theDefault,Send, andDebugtraits.
§Parameters
child: AManagedAgentinstance representing the child actor to be supervised.
§Returns
A Result which is:
Ok(())if the child actor was successfully supervised and added to the supervision hierarchy.- An error of type
anyhow::Errorif any step of the supervision process fails.
§Errors
This method will return an error if:
- The child actor fails to activate.
- Inserting the child context into the
childrenmap fails.
Trait Implementations§
Source§impl Actor for AgentHandle
impl Actor for AgentHandle
Source§fn reply_address(&self) -> MessageAddress
fn reply_address(&self) -> MessageAddress
Returns the message address for this agent.
Source§fn create_envelope(
&self,
recipient_address: Option<MessageAddress>,
) -> OutboundEnvelope
fn create_envelope( &self, recipient_address: Option<MessageAddress>, ) -> OutboundEnvelope
Returns an envelope for the specified recipient and message, ready to send.
Source§fn tracker(&self) -> TaskTracker
fn tracker(&self) -> TaskTracker
Returns the task tracker for the actor.
Source§fn find_child(&self, arn: &Ern) -> Option<AgentHandle>
fn find_child(&self, arn: &Ern) -> Option<AgentHandle>
Finds a child actor by its ERN. Read more
Source§fn clone_ref(&self) -> AgentHandle
fn clone_ref(&self) -> AgentHandle
Creates a clone of the actor’s reference.
Source§fn send(
&self,
message: impl ActonMessage,
) -> impl Future<Output = ()> + Send + Sync + '_where
Self: Sync,
fn send(
&self,
message: impl ActonMessage,
) -> impl Future<Output = ()> + Send + Sync + '_where
Self: Sync,
Emits a message from the actor, possibly to a pool item. Read more
Source§fn send_sync(
&self,
message: impl ActonMessage,
recipient: &AgentHandle,
) -> Result<()>where
Self: Actor,
fn send_sync(
&self,
message: impl ActonMessage,
recipient: &AgentHandle,
) -> Result<()>where
Self: Actor,
Send a message synchronously.
Source§impl Broker for AgentHandle
impl Broker for AgentHandle
Source§fn broadcast(
&self,
message: impl ActonMessage,
) -> impl Future<Output = ()> + Send + Sync + '_
fn broadcast( &self, message: impl ActonMessage, ) -> impl Future<Output = ()> + Send + Sync + '_
Broadcast a message from the broker.
Source§fn broadcast_sync(&self, message: impl ActonMessage) -> Result<()>where
Self: Actor,
fn broadcast_sync(&self, message: impl ActonMessage) -> Result<()>where
Self: Actor,
Broadcast a message from the broker synchronously.
Source§impl Clone for AgentHandle
impl Clone for AgentHandle
Source§fn clone(&self) -> AgentHandle
fn clone(&self) -> AgentHandle
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AgentHandle
impl Debug for AgentHandle
Source§impl Default for AgentHandle
impl Default for AgentHandle
Source§impl Hash for AgentHandle
impl Hash for AgentHandle
Source§impl PartialEq for AgentHandle
impl PartialEq for AgentHandle
Source§impl Subscriber for AgentHandle
impl Subscriber for AgentHandle
Source§fn get_broker(&self) -> Option<AgentHandle>
fn get_broker(&self) -> Option<AgentHandle>
Retrieves the broker associated with this subscriber. Read more
impl Eq for AgentHandle
Auto Trait Implementations§
impl Freeze for AgentHandle
impl !RefUnwindSafe for AgentHandle
impl Send for AgentHandle
impl Sync for AgentHandle
impl Unpin for AgentHandle
impl UnwindSafe for AgentHandle
Blanket Implementations§
Source§impl<T> ActonMessage for T
impl<T> ActonMessage for T
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