Skip to main content

EncoderBuffer

Struct EncoderBuffer 

Source
pub struct EncoderBuffer { /* private fields */ }
Available on crate feature encoder only.
Expand description

Output buffer for writing Draco bitstream data.

EncoderBuffer accumulates encoded bytes and supports both byte-aligned writes and packed bit-level encoding for entropy-coded sections. Encoders write into it; after encoding, data returns the finished bitstream as a byte slice ready to hand to a DecoderBuffer or write to a file.

Implementations§

Source§

impl EncoderBuffer

Source

pub fn new() -> Self

Creates an empty encoder buffer.

Source

pub fn set_version(&mut self, major: u8, minor: u8)

Sets the target Draco bitstream version.

Source

pub fn version_major(&self) -> u8

Returns the target major bitstream version.

Source

pub fn version_minor(&self) -> u8

Returns the target minor bitstream version.

Source

pub fn bitstream_version(&self) -> u16

Returns the packed 0xMMmm target bitstream version for ordered comparisons.

Source

pub fn clear(&mut self)

Clears all encoded bytes and resets active bit encoding state.

Source

pub fn resize(&mut self, nbytes: usize)

Resizes the underlying byte buffer.

Source

pub fn start_bit_encoding( &mut self, required_bits: usize, encode_size: bool, ) -> bool

Starts writing a packed bit sequence.

Source

pub fn end_bit_encoding(&mut self)

Finishes the active packed bit sequence.

Source

pub fn encode_least_significant_bits32( &mut self, nbits: u32, value: u32, ) -> bool

Writes the least significant nbits bits of a 32-bit value.

Source

pub fn encode<T: NoUninit>(&mut self, data: T) -> bool

Appends a plain-old-data value in native memory representation.

Source

pub fn encode_data(&mut self, data: &[u8]) -> bool

Appends raw bytes.

Source

pub fn encode_u8(&mut self, val: u8)

Appends one byte.

Source

pub fn encode_u16(&mut self, val: u16)

Appends a little-endian u16.

Source

pub fn encode_u32(&mut self, val: u32)

Appends a little-endian u32.

Source

pub fn encode_u64(&mut self, val: u64)

Appends a little-endian u64.

Source

pub fn encode_varint<T: Into<u64>>(&mut self, val: T)

Appends an unsigned LEB128-style Draco varint.

Source

pub fn encode_varint_signed_i32(&mut self, val: i32)

Draco-compatible signed varint (ConvertSignedIntToSymbol + unsigned varint).

Source

pub fn data(&self) -> &[u8]

Returns the encoded byte slice.

Source

pub fn size(&self) -> usize

Returns the encoded byte length.

Trait Implementations§

Source§

impl Default for EncoderBuffer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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.