Skip to main content

Session

Trait Session 

Source
pub trait Session: Send {
    // Required methods
    fn turn_stream(
        &mut self,
        input: Input,
        options: TurnOptions,
    ) -> Pin<Box<dyn Future<Output = Result<EventStream, AgentError>> + Send + '_>>;
    fn session_id(&self) -> Option<&str>;
    fn interrupt(
        &mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>;

    // Provided method
    fn turn(
        &mut self,
        input: Input,
        options: TurnOptions,
    ) -> Pin<Box<dyn Future<Output = Result<TurnOutput, AgentError>> + Send + '_>> { ... }
}

Required Methods§

Source

fn turn_stream( &mut self, input: Input, options: TurnOptions, ) -> Pin<Box<dyn Future<Output = Result<EventStream, AgentError>> + Send + '_>>

Run a turn and return a stream of events.

Source

fn session_id(&self) -> Option<&str>

Session ID (populated after the first turn completes).

Source

fn interrupt( &mut self, ) -> Pin<Box<dyn Future<Output = Result<(), AgentError>> + Send + '_>>

Interrupt the current turn. No-op if idle.

Provided Methods§

Source

fn turn( &mut self, input: Input, options: TurnOptions, ) -> Pin<Box<dyn Future<Output = Result<TurnOutput, AgentError>> + Send + '_>>

Run a turn and return the buffered result.

Default implementation calls turn_stream then collect_turn.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§