TaskSpawner

Struct TaskSpawner 

Source
pub struct TaskSpawner { /* private fields */ }
Expand description

Spawns and manages the lifecycle of a task

Implementations§

Source§

impl TaskSpawner

Source

pub async fn start_direct( &mut self, event_tx: Sender<TaskEvent>, ) -> Result<u32, TaskError>

Source§

impl TaskSpawner

Source

pub fn new(task_name: String, config: TaskConfig) -> Self

Create a new task spawner for the given task name and configuration

Source

pub fn set_stdin(self, stdin_rx: Receiver<String>) -> Self

Set the stdin receiver for the task, enabling asynchronous input

Has no effect if enable_stdin is false in the configuration

Source

pub async fn get_state(&self) -> TaskState

Get the current state of the task

Source

pub async fn is_running(&self) -> bool

Check if the task is currently running

Source

pub async fn is_ready(&self) -> bool

Check if the task is currently ready

Source

pub fn uptime(&self) -> Duration

Get the uptime of the task since creation

Source

pub async fn get_task_info(&self) -> TaskInfo

Get information about the task, including name, state, and uptime

Source

pub async fn send_terminate_signal( &self, reason: TaskTerminateReason, ) -> Result<(), TaskError>

Send a termination signal to the running task

Returns an error if the signal cannot be sent

Trait Implementations§

Source§

impl Debug for TaskSpawner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.