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§
Sourcefn on_message(&mut self, msg: &WsIn) -> SerIn
fn on_message(&mut self, msg: &WsIn) -> SerIn
Normalize one inbound frame into a SerIn event.
Sourcefn encode_audio(&self, chunk: &AudioChunk) -> WsOut
fn encode_audio(&self, chunk: &AudioChunk) -> WsOut
Encode an outbound audio chunk into a frame to send back to the carrier.
Sourcefn encode_clear(&self) -> Option<WsOut>
fn encode_clear(&self) -> Option<WsOut>
Encode a “clear/flush queued audio” control frame for barge-in, if the carrier supports one.
Sourcefn carrier_rate(&self) -> u32
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".