Skip to main content

Marshal

Trait Marshal 

Source
pub trait Marshal: MarshalSize {
    // Required method
    fn marshal_to(&self, buf: &mut [u8]) -> Result<usize>;

    // Provided method
    fn marshal(&self) -> Result<BytesMut> { ... }
}
Expand description

Encodes a value into its wire format.

Every protocol codec in the stack — STUN, RTP, RTCP, SDP, DTLS, SCTP — implements this so that higher layers can serialize uniformly.

Required Methods§

Source

fn marshal_to(&self, buf: &mut [u8]) -> Result<usize>

Encodes into buf, returning the number of bytes written.

§Errors

Fails if buf is shorter than MarshalSize::marshal_size, or if the value itself is not encodable (an out-of-range field, for instance).

Provided Methods§

Source

fn marshal(&self) -> Result<BytesMut>

Encodes into a freshly allocated buffer sized by MarshalSize::marshal_size.

§Errors

Propagates any failure from Self::marshal_to.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§