Trait Streaming Codec

View as Markdown

Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-pii-redaction -p nemo-relay-ffi -p nemo-relay-types -p nemo-relay-plugin -p nemo-relay-worker-proto -p nemo-relay-worker.

pub trait StreamingCodec: Send + Sync {
    // Required methods
    fn collector(&self) -> LlmCollectorFn;
    fn finalizer(&self) -> LlmFinalizerFn;
}

Per-provider streaming codec used with crate::api::llm::llm_stream_call_execute.

collector() and finalizer() produce owned closures that share the codec’s internal accumulation state. Implementations typically wrap that state in Arc<Mutex<...>> so each &self-produced closure captures a clone of the handle.

LlmFinalizerFn is FnOnce, so a StreamingCodec instance is single-use: callers construct a fresh instance per managed-lifecycle call and discard it after the stream completes.

Required Methods

collector

fn collector(&self) -> LlmCollectorFn

Returns a closure that consumes one decoded provider event per call.

finalizer

fn finalizer(&self) -> LlmFinalizerFn

Returns a closure that, when called once at end of stream, produces the assembled response payload in the shape the matching crate::codec::traits::LlmResponseCodec can decode.

Implementors

impl StreamingCodec for AnthropicMessagesStreamingCodec

impl StreamingCodec for AnthropicMessagesStreamingCodec

impl StreamingCodec for GeminiGenerateContentStreamingCodec

impl StreamingCodec for GeminiGenerateContentStreamingCodec

impl StreamingCodec for OCIGenAIStreamingCodec

impl StreamingCodec for OCIGenAIStreamingCodec

impl StreamingCodec for OpenAIChatStreamingCodec

impl StreamingCodec for OpenAIChatStreamingCodec

impl StreamingCodec for OpenAIResponsesStreamingCodec

impl StreamingCodec for OpenAIResponsesStreamingCodec