pub struct ActorCell { /* private fields */ }
Expand description
An ActorCell is a reference to an Actor’s communication channels and provides external access to send messages, stop, kill, and generally interactor with the underlying Actor process.
The input ports contained in the cell will return an error should the underlying actor have terminated and no longer exist.
Implementations§
source§impl ActorCell
impl ActorCell
sourcepub fn get_id(&self) -> ActorId
pub fn get_id(&self) -> ActorId
Retrieve the super::Actor’s unique identifier ActorId
sourcepub fn get_name(&self) -> Option<ActorName>
pub fn get_name(&self) -> Option<ActorName>
Retrieve the super::Actor’s name
sourcepub fn get_status(&self) -> ActorStatus
pub fn get_status(&self) -> ActorStatus
Retrieve the current status of an super::Actor
Returns the super::Actor’s current ActorStatus
sourcepub fn link(&self, supervisor: ActorCell)
pub fn link(&self, supervisor: ActorCell)
Link this super::Actor to the provided supervisor
supervisor
- The supervisor super::Actor of this actor
sourcepub fn unlink(&self, supervisor: ActorCell)
pub fn unlink(&self, supervisor: ActorCell)
Unlink this super::Actor from the supervisor if it’s
currently linked (if self’s supervisor is supervisor
)
supervisor
- The supervisor to unlink this super::Actor from
sourcepub fn kill(&self)
pub fn kill(&self)
Kill this super::Actor forcefully (terminates async work)
sourcepub async fn kill_and_wait(
&self,
timeout: Option<Duration>,
) -> Result<(), RactorErr<()>>
pub async fn kill_and_wait( &self, timeout: Option<Duration>, ) -> Result<(), RactorErr<()>>
Kill this super::Actor forcefully (terminates async work) and wait for the actor shutdown to complete
timeout
- An optional timeout duration to wait for shutdown to occur
Returns [Ok(())] upon the actor being stopped/shutdown. [Err(RactorErr::Messaging(_))] if the channel is closed or dropped (which may indicate some other process is trying to shutdown this actor) or [Err(RactorErr::Timeout)] if timeout was hit before the actor was successfully shut down (when set)
sourcepub fn stop(&self, reason: Option<String>)
pub fn stop(&self, reason: Option<String>)
Stop this super::Actor gracefully (stopping message processing)
reason
- An optional string reason why the stop is occurring
sourcepub async fn stop_and_wait(
&self,
reason: Option<String>,
timeout: Option<Duration>,
) -> Result<(), RactorErr<StopMessage>>
pub async fn stop_and_wait( &self, reason: Option<String>, timeout: Option<Duration>, ) -> Result<(), RactorErr<StopMessage>>
Stop the super::Actor gracefully (stopping messaging processing) and wait for the actor shutdown to complete
reason
- An optional string reason why the stop is occurringtimeout
- An optional timeout duration to wait for shutdown to occur
Returns [Ok(())] upon the actor being stopped/shutdown. [Err(RactorErr::Messaging(_))] if the channel is closed or dropped (which may indicate some other process is trying to shutdown this actor) or [Err(RactorErr::Timeout)] if timeout was hit before the actor was successfully shut down (when set)
sourcepub fn send_message<TMessage>(
&self,
message: TMessage,
) -> Result<(), MessagingErr<TMessage>>where
TMessage: Message,
pub fn send_message<TMessage>(
&self,
message: TMessage,
) -> Result<(), MessagingErr<TMessage>>where
TMessage: Message,
Send a strongly-typed message, constructing the boxed message on the fly
Note: The type requirement of TActor
assures that TMsg
is the supported
message type for TActor
such that we can’t send boxed messages of an unsupported
type to the specified actor.
message
- The message to send
Returns [Ok(())] on successful message send, [Err(MessagingErr)] otherwise
sourcepub fn notify_supervisor(&self, evt: SupervisionEvent)
pub fn notify_supervisor(&self, evt: SupervisionEvent)
Notify the supervisor and all monitors that a supervision event occurred. Monitors receive a reduced copy of the supervision event which won’t contain the crate::actor::BoxedState and collapses the crate::ActorProcessingErr exception to a String
evt
- The event to send to this super::Actor’s supervisors
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ActorCell
impl RefUnwindSafe for ActorCell
impl Send for ActorCell
impl Sync for ActorCell
impl Unpin for ActorCell
impl UnwindSafe for ActorCell
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)