Skip to main content

MediaSerializer

Trait MediaSerializer 

Source
pub trait MediaSerializer: Send {
    // Required methods
    fn on_message(&mut self, msg: &WsIn) -> SerIn;
    fn encode_audio(&self, chunk: &AudioChunk) -> WsOut;
    fn encode_clear(&self) -> Option<WsOut>;
    fn carrier_rate(&self) -> u32;
}
Expand description

Carrier-specific WS framing. Implementations are pure functions over frames (no sockets, no async) so they are trivially unit-testable.

Required Methods§

Source

fn on_message(&mut self, msg: &WsIn) -> SerIn

Normalize one inbound frame into a SerIn event.

Source

fn encode_audio(&self, chunk: &AudioChunk) -> WsOut

Encode an outbound audio chunk into a frame to send back to the carrier.

Source

fn encode_clear(&self) -> Option<WsOut>

Encode a “clear/flush queued audio” control frame for barge-in, if the carrier supports one.

Source

fn carrier_rate(&self) -> u32

The carrier-side audio sample rate (e.g. 8000 for telephony μ-law).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§