Codec

Trait Codec 

pub trait Codec:
    Send
    + Sync
    + 'static {
    // Required methods
    fn encode_setup(
        &self,
        config: &SessionConfig,
    ) -> Result<Vec<u8>, CodecError>;
    fn encode_command(
        &self,
        cmd: &SessionCommand,
        config: &SessionConfig,
    ) -> Result<Vec<u8>, CodecError>;
    fn decode_message(&self, data: &[u8]) -> Result<ServerMessage, CodecError>;
}
Expand description

Encodes client commands into wire bytes and decodes server bytes into messages.

The default implementation is JsonCodec, which serializes commands as JSON and parses server responses via ServerMessage::parse.

§Implementors

  • JsonCodec – Standard JSON codec. Encodes setup messages, audio (base64), text, tool responses, and activity signals. Decodes server JSON into ServerMessage variants. Handles platform-specific wire stripping (e.g., removing scheduling fields for Vertex AI).

Required Methods§

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>

Encode a session command into wire bytes.

fn decode_message(&self, data: &[u8]) -> Result<ServerMessage, CodecError>

Decode raw bytes from the server into a ServerMessage.

Trait Implementations§

§

impl Codec for Box<dyn Codec>

Forwarding impl so connect_with can install a recorder dynamically without changing its generic signature.

§

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>

Encode a session command into wire bytes.
§

fn decode_message(&self, data: &[u8]) -> Result<ServerMessage, CodecError>

Decode raw bytes from the server into a ServerMessage.

Implementations on Foreign Types§

§

impl Codec for Box<dyn Codec>

Forwarding impl so connect_with can install a recorder dynamically without changing its generic signature.

Implementors§

§

impl Codec for JsonCodec

§

impl<C> Codec for RecordingCodec<C>
where C: Codec,