SpeexBits

Struct SpeexBits 

Source
pub struct SpeexBits<'a> {
    pub buffer_ref: Option<&'a mut [u8]>,
    /* private fields */
}
Expand description

A struct that holds bits to be read or written to

Internally packs bits.

Fields§

§buffer_ref: Option<&'a mut [u8]>

Implementations§

Source§

impl<'a> SpeexBits<'a>

Source

pub fn new() -> Self

Creates a new SpeexBits

Source

pub fn buffer<'b>(&mut self) -> &'a mut [u8]

Source

pub fn new_with_buffer(buffer: &'a mut [u8]) -> Self

Creates a new SpeexBits with an existing buffer

Source

pub fn advance(&mut self, n: i32)

Advances the read pointer by n bits

Source

pub fn insert_terminator(&mut self)

Inserts a terminator so the data can be sent as a packet while autodetecting how many frames were in the packet

Source

pub fn num_bytes(&mut self) -> i32

Returns the number of bytes in the bitstream, including the last partial byte

Source

pub fn pack(&mut self, data: i32, num_bits: i32)

Appends bits to the bitstream

Source

pub fn peek(&mut self) -> i32

Gets the value of the next bit in the stream without advancing the read pointer

Source

pub fn peek_unsigned(&mut self, num_bits: i32) -> u32

Gets the value of the next num_bits in the stream without advancing the read pointer

Source

pub fn read_from(&mut self, buffer: &mut [u8])

Source

pub fn read_whole_bytes(&mut self, bytes: &[u8])

Appends bytes to the bitstream

Source

pub fn remaining(&mut self) -> u32

Returns the number of bits remaining to be read from a stream

Source

pub fn reset(&mut self)

Resets SpeexBits to the initial state, erasing all content

Source

pub fn rewind(&mut self)

Resets the read pointer to the beginning, without erasing the content

Source

pub fn set_bit_buffer(&mut self, buffer: &mut [u8])

Sets an existing SpeexBits to use data from an existing buffer

Source

pub fn unpack_signed(&mut self, num_bits: i32) -> i32

Interpret the next number of bits as a signed integer, advancing the read pointer

Source

pub fn unpacked_unsigned(&mut self, num_bits: i32) -> u32

Interpret the next number of bits as an unsigned integer, advancing the read pointer

Source

pub fn write(&mut self, buffer: &mut [u8]) -> u32

Writes the content of the bitstream to a buffer

Source

pub fn write_whole_bytes(&mut self, buffer: &mut [u8]) -> u32

Writes the content of the bitstream to a buffer, writing whole bytes only. Removes any bytes that are successfully written from the bitstream.

Trait Implementations§

Source§

impl<'a> Default for SpeexBits<'a>

Source§

fn default() -> Self

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

impl<'a> Drop for SpeexBits<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for SpeexBits<'a>

§

impl<'a> RefUnwindSafe for SpeexBits<'a>

§

impl<'a> !Send for SpeexBits<'a>

§

impl<'a> !Sync for SpeexBits<'a>

§

impl<'a> Unpin for SpeexBits<'a>

§

impl<'a> !UnwindSafe for SpeexBits<'a>

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.