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>
impl<W: Write> Encoder<W>
Sourcepub fn write_frame(&mut self, planes: [&[u8]; 3]) -> Result<(), Error>
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.
Sourcepub fn write_frame_with_params(
&mut self,
planes: [&[u8]; 3],
params: &[u8],
) -> Result<(), Error>
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.
Sourcepub fn write_frame_u16(&mut self, planes: [&[u16]; 3]) -> Result<(), Error>
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.
Sourcepub fn into_inner(self) -> Result<W, Error>
pub fn into_inner(self) -> Result<W, Error>
Flushes and returns the underlying writer.