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§
Source§impl<C: Codec> RecordingCodec<C>
impl<C: Codec> RecordingCodec<C>
Sourcepub fn new(inner: C, recorder: Arc<dyn WireRecorder>) -> Self
pub fn new(inner: C, recorder: Arc<dyn WireRecorder>) -> Self
Wrap inner, delivering taps to recorder.
Trait Implementations§
Source§impl<C: Codec> Codec for RecordingCodec<C>
impl<C: Codec> Codec for RecordingCodec<C>
Source§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.
Source§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.
Source§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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].