Lacer

Enum Lacer 

Source
pub enum Lacer {
    Xiph,
    FixedSize,
    Ebml,
}
Expand description

Handler for lacing and delacing operations on frame data.

Variants§

§

Xiph

Xiph lacing (variable-size frames with size prefixes)

The Xiph lacing uses the same coding of size as found in the Ogg container [@?RFC3533]. The bits 5-6 of the Block Header flags are set to 01. The Block data with laced frames is stored as follows: Lacing Head on 1 Octet: Number of frames in the lace minus 1. Lacing size of each frame except the last one. Binary data of each frame consecutively. The lacing size is split into 255 values, stored as unsigned octets – for example, 500 is coded 255;245 or [0xFF 0xF5]. A frame with a size multiple of 255 is coded with a 0 at the end of the size – for example, 765 is coded 255;255;255;0 or [0xFF 0xFF 0xFF 0x00]. The size of the last frame is deduced from the size remaining in the Block after the other frames.

§

FixedSize

Fixed-size lacing (all frames have the same size)

§

Ebml

EBML lacing (variable-size frames with EBML-encoded sizes)

The EBML lacing encodes the frame size with an EBML-like encoding [@!RFC8794]. The bits 5-6 of the Block Header flags are set to 11.

The Block data with laced frames is stored as follows: Lacing Head on 1 Octet: Number of frames in the lace minus 1. Lacing size of each frame except the last one. Binary data of each frame consecutively.

The first frame size is encoded as an EBML Variable-Size Integer value, also known as VINT in [@!RFC8794]. The remaining frame sizes are encoded as signed values using the difference between the frame size and the previous frame size. These signed values are encoded as VINT, with a mapping from signed to unsigned numbers. Decoding the unsigned number stored in the VINT to a signed number is done by subtracting 2^((7*n)-1)-1, where n is the octet size of the VINT.

Implementations§

Source§

impl Lacer

Source

pub fn lace(&self, frames: &[&[u8]]) -> Vec<u8>

Encode multiple frames into a single laced block

Source

pub fn delace<'a>(&self, data: &'a [u8]) -> Result<Vec<&'a [u8]>>

Decode a laced block into individual frames

Auto Trait Implementations§

§

impl Freeze for Lacer

§

impl RefUnwindSafe for Lacer

§

impl Send for Lacer

§

impl Sync for Lacer

§

impl Unpin for Lacer

§

impl UnwindSafe for Lacer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.