Trait Streaming Codec
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;
// Provided method
fn validate_stream(&self, stream: LlmJsonStream) -> LlmJsonStream { ... }
}
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.
Provided Methods
validate_stream
fn validate_stream(&self, stream: LlmJsonStream) -> LlmJsonStream
Wraps the source stream to check provider completion rules.
Feed the returned stream to this instance’s collector and finalizer. The default leaves the stream unchanged. An override must forward close and cleanup operations.
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