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::Errorwith a partial message, not by returningErr. - The returned stream must yield exactly one terminal event
(
DoneorError). Apps that prefer non-streaming can yield a singleStart+Donewith the full final message. - Honor
signalfor cancellation. On cancel, yieldErrorwithStreamError::Aborted-equivalent or simply drop the stream.
Required Methods§
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".