Struct RecordingCodec
pub struct RecordingCodec<C> { /* private fields */ }Expand description
A Codec decorator that records every byte crossing the wire.
Outbound bytes are recorded after a successful encode (empty encodes —
e.g. SessionCommand::Disconnect — are skipped because they never hit
the wire). Inbound bytes are recorded before decoding, so frames that
fail to decode are still captured.
use std::sync::Arc;
use gemini_genai_rs::transport::{JsonCodec, MemoryWireRecorder, RecordingCodec};
let recorder = Arc::new(MemoryWireRecorder::new());
let codec = RecordingCodec::new(JsonCodec, recorder.clone());Implementations§
§impl<C> RecordingCodec<C>where
C: Codec,
impl<C> RecordingCodec<C>where
C: Codec,
pub fn new(inner: C, recorder: Arc<dyn WireRecorder>) -> RecordingCodec<C>
pub fn new(inner: C, recorder: Arc<dyn WireRecorder>) -> RecordingCodec<C>
Wrap inner, delivering taps to recorder.
Trait Implementations§
§impl<C> Codec for RecordingCodec<C>where
C: Codec,
impl<C> Codec for RecordingCodec<C>where
C: Codec,
§fn encode_setup(&self, config: &SessionConfig) -> Result<Vec<u8>, CodecError>
fn encode_setup(&self, config: &SessionConfig) -> Result<Vec<u8>, CodecError>
Encode the initial setup message for the given session configuration.
§fn encode_command(
&self,
cmd: &SessionCommand,
config: &SessionConfig,
) -> Result<Vec<u8>, CodecError>
fn encode_command( &self, cmd: &SessionCommand, config: &SessionConfig, ) -> Result<Vec<u8>, CodecError>
Encode a session command into wire bytes.
§fn decode_message(&self, data: &[u8]) -> Result<ServerMessage, CodecError>
fn decode_message(&self, data: &[u8]) -> Result<ServerMessage, CodecError>
Decode raw bytes from the server into a
ServerMessage.Auto Trait Implementations§
impl<C> !Freeze for RecordingCodec<C>
impl<C> !RefUnwindSafe for RecordingCodec<C>
impl<C> Send for RecordingCodec<C>where
C: Send,
impl<C> Sync for RecordingCodec<C>where
C: Sync,
impl<C> Unpin for RecordingCodec<C>where
C: Unpin,
impl<C> !UnwindSafe for RecordingCodec<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more