Skip to main content

Unpacker

Struct Unpacker 

Source
pub struct Unpacker<'b> { /* private fields */ }
Expand description

Reads a frame. Every read answers None for bytes that aren’t what Packer writes there.

Implementations§

Source§

impl<'b> Unpacker<'b>

Source

pub fn open(bytes: &'b [u8]) -> Option<Self>

The frame’s body and table found; the root value next.

Source

pub fn at_end(&self) -> bool

Whether the body is read through.

Source

pub fn get_u(&mut self) -> Option<u64>

Source

pub fn get_i(&mut self) -> Option<i64>

Source

pub fn get_bool(&mut self) -> Option<bool>

Source

pub fn get_f64(&mut self) -> Option<f64>

Source

pub fn get_f32(&mut self) -> Option<f32>

Source

pub fn count(&mut self) -> Option<usize>

A list’s count (every value takes a byte at least).

Source

pub fn get_f64s(&mut self) -> Option<Vec<f64>>

Source

pub fn get_uints<T>(&mut self, of: impl Fn(u64) -> Option<T>) -> Option<Vec<T>>

Bit-packed numbers (Packer::put_uints), each made a T by of.

Source

pub fn get_f32s(&mut self) -> Option<Vec<f32>>

Source

pub fn packed_ints(&mut self) -> Option<(usize, u32, &'b [u8])>

A packed list of ints, unread: how many, bits each, their bytes.

Source

pub fn packed_floats(&mut self, wide: bool) -> Option<(usize, bool, &'b [u8])>

A list of floats, unread: how many, whether they’re f32s, their bytes. A list of f64 says whether it’s narrowed (wide); one of f32 always is.

Source

pub fn get_str(&mut self) -> Option<&'b str>

A string, borrowed from the frame: the table read as far as it’s needed.

Source

pub fn get_shared_str(&mut self) -> Option<Arc<str>>

A string as an Arc<str>: one allocation for every time the frame has it.

Source

pub fn get_bytes(&mut self) -> Option<&'b [u8]>

Source

pub fn get_tagged<T: Schema>(&mut self) -> Option<T>

A value held in its binary form (Packer::put_tagged).

Source

pub fn begin(&mut self) -> Option<usize>

A record starts: where it ends.

Source

pub fn list(&mut self) -> Option<(usize, usize)>

A list (Packer::begin_list): how many items, and where it ends.

Source

pub fn skip_to(&mut self, end: usize) -> Option<()>

Steps to end (a list’s), past what’s left of it.

Source

pub fn position(&self) -> usize

Where it’s read up to.

Source

pub fn fork(&self, at: usize) -> Unpacker<'b>

A reader of the same frame from at, with a string cache of its own.

Source

pub fn more(&self, end: usize) -> bool

Whether the record ending at end has more fields.

Source

pub fn leave(&mut self, end: usize) -> Option<()>

The record ending at end is done: fields this reader doesn’t know skipped.

Auto Trait Implementations§

§

impl<'b> Freeze for Unpacker<'b>

§

impl<'b> RefUnwindSafe for Unpacker<'b>

§

impl<'b> Send for Unpacker<'b>

§

impl<'b> Sync for Unpacker<'b>

§

impl<'b> Unpin for Unpacker<'b>

§

impl<'b> UnsafeUnpin for Unpacker<'b>

§

impl<'b> UnwindSafe for Unpacker<'b>

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.