Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder<W: Write> { /* private fields */ }
Expand description

Writes frames for one stream. Produced by EncoderBuilder::write_header.

The hot path is write_all calls only. The optional u16-to-LE scratch buffer is allocated once at header time, and the counting-allocator test tests/zero_alloc.rs pins frame writes at zero heap allocations.

Implementations§

Source§

impl<W: Write> Encoder<W>

Source

pub fn write_frame(&mut self, planes: [&[u8]; 3]) -> Result<(), Error>

Writes one frame with a bare FRAME header from wire-format byte planes. Plane byte lengths must match the header-derived sizes, else Error::BadInput.

Source

pub fn write_frame_with_params( &mut self, planes: [&[u8]; 3], params: &[u8], ) -> Result<(), Error>

Writes one frame carrying verbatim frame header parameters (the bytes after "FRAME ", LF excluded, or empty for a bare header).

Parameters must follow the frame header grammar: SP-separated, each a single ASCII letter tag plus a value of one byte or more, no empty piece, and no LF, CR, or NUL byte, else Error::BadInput before anything is written. An over-budget frame header line is Error::Limits.

Source

pub fn write_frame_u16(&mut self, planes: [&[u16]; 3]) -> Result<(), Error>

Writes one frame from host-order u16 sample planes, encoding each sample little-endian on the wire regardless of host endianness.

Requires a >8-bit colorspace. Plane sample counts must match the header-derived sizes and every sample must fit the stream bit depth, else Error::BadInput.

Source

pub fn into_inner(self) -> Result<W, Error>

Flushes and returns the underlying writer.

Trait Implementations§

Source§

impl<W: Write> Debug for Encoder<W>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<W> Freeze for Encoder<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for Encoder<W>
where W: RefUnwindSafe,

§

impl<W> Send for Encoder<W>
where W: Send,

§

impl<W> Sync for Encoder<W>
where W: Sync,

§

impl<W> Unpin for Encoder<W>
where W: Unpin,

§

impl<W> UnsafeUnpin for Encoder<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for Encoder<W>
where W: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.