Skip to main content

AsyncChildHandle

Trait AsyncChildHandle 

Source
pub trait AsyncChildHandle:
    Send
    + Sync
    + Debug {
    // Required methods
    fn id(&self) -> &str;
    fn status(&self) -> Status;
    fn run<'life0, 'async_trait>(
        &'life0 mut self,
        input: Value,
    ) -> Pin<Box<dyn Future<Output = Result<ChildResult, RunError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn abort(&mut self);
    fn is_finished(&self) -> bool;
}
Expand description

Async handle to a spawned child.

Provides async control over a child. Use this for children that perform I/O-bound operations like LLM API calls.

§Example

let mut handle = ctx.spawn_child_async(config).await?;

// Run the child (async)
let result = handle.run(input).await?;

// Check status
println!("Status: {:?}", handle.status());

// Abort if needed
handle.abort();

§When to Use

HandleUse Case
ChildHandleCPU-bound, quick sync tasks
AsyncChildHandleI/O-bound, network, LLM calls

Required Methods§

Source

fn id(&self) -> &str

Returns the child’s ID.

Source

fn status(&self) -> Status

Returns the child’s current status.

Source

fn run<'life0, 'async_trait>( &'life0 mut self, input: Value, ) -> Pin<Box<dyn Future<Output = Result<ChildResult, RunError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs the child with the given input (async).

§Arguments
  • input - Input data for the child
§Returns

The result of the child’s execution.

Source

fn abort(&mut self)

Aborts the child immediately.

Source

fn is_finished(&self) -> bool

Returns true if the child has completed (success, error, or aborted).

Implementors§