pub trait Decoder<'id, Op: Operation, Frame = WireFrame> {
type Event;
// Required methods
fn classify(&self, frame: Frame) -> WireEvent<Self::Event>;
fn decode(
&mut self,
event: Self::Event,
out: Out<'id, Op>,
) -> Result<Flow, ProviderError>;
// Provided method
fn eof(&mut self, out: Out<'id, Op>) -> Result<Flow, ProviderError> { ... }
}Expand description
Synchronous state machine for one reply. It classifies frames and
decodes known events into the reply’s writer, without transport access
and without being told how the reply arrives. HTTP wires read
WireFrames; other transports name their own frame type.
Required Associated Types§
Required Methods§
Sourcefn classify(&self, frame: Frame) -> WireEvent<Self::Event>
fn classify(&self, frame: Frame) -> WireEvent<Self::Event>
Decode and classify one frame. A JSON wire MUST delegate to a
classifier in crate::providers::internal::wire, so the
decode-then-validate policy is not re-derived per provider.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<'id, Op: Operation, Event> Decoder<'id, Op> for DocumentDecoder<Op, Event>
impl<'id, Op: Operation, Event> Decoder<'id, Op> for DocumentDecoder<Op, Event>
Source§impl<'id> Decoder<'id, AudioGeneration> for SpeechDecoder
impl<'id> Decoder<'id, AudioGeneration> for SpeechDecoder
Source§impl<'id> Decoder<'id, Completion, GenerateContentChunk> for GenerateContentDecoder
A transport that delivers each reply message as its REST chunk, such as
an SDK’s reply transcoded once, hands the decoder the chunk itself.
impl<'id> Decoder<'id, Completion, GenerateContentChunk> for GenerateContentDecoder
A transport that delivers each reply message as its REST chunk, such as an SDK’s reply transcoded once, hands the decoder the chunk itself.
type Event = GenerateContentChunk
Source§impl<'id> Decoder<'id, Completion, MockFrame> for MockDecoder<'id>
Available on crate feature test-utils only.
impl<'id> Decoder<'id, Completion, MockFrame> for MockDecoder<'id>
test-utils only.Source§impl<'id> Decoder<'id, Completion> for rig_core::providers::cohere::streaming::ChatDecoder
impl<'id> Decoder<'id, Completion> for rig_core::providers::cohere::streaming::ChatDecoder
Source§impl<'id> Decoder<'id, Completion> for rig_core::providers::ollama::streaming::ChatDecoder
impl<'id> Decoder<'id, Completion> for rig_core::providers::ollama::streaming::ChatDecoder
type Event = ChatRecord
Source§impl<'id> Decoder<'id, Completion> for GenerateContentDecoder
impl<'id> Decoder<'id, Completion> for GenerateContentDecoder
type Event = GenerateContentChunk
Source§impl<'id> Decoder<'id, Completion> for InteractionsDecoder
EOF without interaction.completed is truncation, not successful
completion, so the decoder has nothing to add at the end of the reply.
impl<'id> Decoder<'id, Completion> for InteractionsDecoder
EOF without interaction.completed is truncation, not successful
completion, so the decoder has nothing to add at the end of the reply.