Skip to main content

Decoder

Struct Decoder 

Source
pub struct Decoder<'a> { /* private fields */ }
Expand description

Range decoder over a byte slice (reads past the end as zeros).

Implementations§

Source§

impl<'a> Decoder<'a>

Source

pub fn new(buf: &'a [u8]) -> Self

Start decoding buf (as produced by Encoder::finish).

Source

pub fn decode_p(&mut self, p1: u32) -> bool

Decode a bit coded with P(1) = p1 / 2^16.

Source

pub fn decode(&mut self, m: &mut BitModel) -> bool

Decode with an adaptive model, then adapt it.

Source

pub fn decode_raw(&mut self, n: u32) -> u64

n raw bits, MSB first.

Source

pub fn overrun(&self) -> bool

Whether the decoder consumed more than the buffer (corrupt stream).

Trait Implementations§

Source§

impl Bits for Decoder<'_>

Source§

fn bit(&mut self, _: bool, m: &mut BitModel) -> bool

Code bit (ignored when decoding) with an adaptive model.
Source§

fn bitp(&mut self, _: bool, p1: u32) -> bool

Code bit with a fixed probability P(1) = p1/2^16.
Source§

fn uint(&mut self, _: u64, m: &mut UintModel) -> u64

Code an unbounded non-negative integer.
Source§

fn tag(&mut self, _t: usize)

Accounting tag for the decisions that follow (no-op for real coders).
Source§

impl<'a> Debug for Decoder<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Decoder<'a>

§

impl<'a> RefUnwindSafe for Decoder<'a>

§

impl<'a> Send for Decoder<'a>

§

impl<'a> Sync for Decoder<'a>

§

impl<'a> Unpin for Decoder<'a>

§

impl<'a> UnsafeUnpin for Decoder<'a>

§

impl<'a> UnwindSafe for Decoder<'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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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.