pub struct SupervisorHandle { /* private fields */ }Expand description
Handle used to interact with the Supervisor.
Cloning this handle is cheap. All clones share the same connection to
the supervisor. Multiple clones can call wait() concurrently and all
will receive the result.
Implementations§
Source§impl SupervisorHandle
impl SupervisorHandle
Sourcepub async fn wait(&self) -> Result<(), SupervisorError>
pub async fn wait(&self) -> Result<(), SupervisorError>
Waits for the supervisor to complete its execution.
Multiple callers can wait() concurrently; all will receive the same result.
§Returns
Ok(())if the supervisor completed successfully.Err(SupervisorError)if the supervisor returned an error.
Sourcepub fn add_task<T: SupervisedTask + Clone>(
&self,
task_name: &str,
task: T,
) -> Result<(), SupervisorHandleError>
pub fn add_task<T: SupervisedTask + Clone>( &self, task_name: &str, task: T, ) -> Result<(), SupervisorHandleError>
Sourcepub fn shutdown(&self) -> Result<(), SupervisorHandleError>
pub fn shutdown(&self) -> Result<(), SupervisorHandleError>
Requests the supervisor to shut down all tasks and stop supervision.
§Returns
Ok(())if the message was sent successfully.Err(SendError)if the supervisor is no longer running.
Sourcepub async fn get_task_status(
&self,
task_name: &str,
) -> Result<Option<TaskStatus>, SupervisorHandleError>
pub async fn get_task_status( &self, task_name: &str, ) -> Result<Option<TaskStatus>, SupervisorHandleError>
Queries the status of a specific task asynchronously.
§Arguments
task_name: The name of the task to query.
§Returns
Ok(Some(TaskStatus))if the task exists and its status is returned.Ok(None)if the task does not exist.Err(RecvError)if communication with the supervisor fails (e.g., it has shut down).
Sourcepub async fn get_all_task_statuses(
&self,
) -> Result<HashMap<String, TaskStatus>, SupervisorHandleError>
pub async fn get_all_task_statuses( &self, ) -> Result<HashMap<String, TaskStatus>, SupervisorHandleError>
Queries the statuses of all tasks asynchronously.
§Returns
Ok(HashMap<TaskName, TaskStatus>)containing the statuses of all tasks.Err(RecvError)if communication with the supervisor fails (e.g., it has shut down).
Trait Implementations§
Source§impl Clone for SupervisorHandle
impl Clone for SupervisorHandle
Source§fn clone(&self) -> SupervisorHandle
fn clone(&self) -> SupervisorHandle
Returns a duplicate 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 SupervisorHandle
impl Debug for SupervisorHandle
Auto Trait Implementations§
impl Freeze for SupervisorHandle
impl RefUnwindSafe for SupervisorHandle
impl Send for SupervisorHandle
impl Sync for SupervisorHandle
impl Unpin for SupervisorHandle
impl UnsafeUnpin for SupervisorHandle
impl UnwindSafe for SupervisorHandle
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