Skip to main content

StreamFn

Trait StreamFn 

Source
pub trait StreamFn:
    Send
    + Sync
    + 'static {
    // Required method
    fn stream<'life0, 'async_trait>(
        &'life0 self,
        request: StreamRequest,
        signal: CancellationToken,
    ) -> Pin<Box<dyn Future<Output = BoxStream<'static, StreamEvent>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The transport trait. One method, typed in/out.

Contract:

  • Must not panic on request/model/runtime failures. Encode failures in the returned stream as StreamEvent::Error with a partial message, not by returning Err.
  • The returned stream must yield exactly one terminal event (Done or Error). Apps that prefer non-streaming can yield a single Start + Done with the full final message.
  • Honor signal for cancellation. On cancel, yield Error with StreamError::Aborted-equivalent or simply drop the stream.

Required Methods§

Source

fn stream<'life0, 'async_trait>( &'life0 self, request: StreamRequest, signal: CancellationToken, ) -> Pin<Box<dyn Future<Output = BoxStream<'static, StreamEvent>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§