pub struct Decoder<'b> { /* private fields */ }Expand description
Reads the binary form. The step-by-step reads (Decoder::int,
Decoder::map …) answer None for anything but what
crate::Schema::encode writes there — the schema then reads the
slow way, which says what’s wrong.
Implementations§
Source§impl<'b> Decoder<'b>
impl<'b> Decoder<'b>
Sourcepub fn open(bytes: &'b [u8]) -> Result<Self, DecodeError>
pub fn open(bytes: &'b [u8]) -> Result<Self, DecodeError>
After the header: the root value next.
Sourcepub fn value(&mut self) -> Result<Value, DecodeError>
pub fn value(&mut self) -> Result<Value, DecodeError>
The next value, owned.
Sourcepub fn value_ref<'a>(
&mut self,
arena: &'a Bump,
) -> Result<ValueRef<'a>, DecodeError>where
'b: 'a,
pub fn value_ref<'a>(
&mut self,
arena: &'a Bump,
) -> Result<ValueRef<'a>, DecodeError>where
'b: 'a,
The next value, borrowed: strings point into the bytes, lists and maps go in arena.
pub fn bool(&mut self) -> Option<bool>
pub fn int(&mut self) -> Option<i64>
pub fn str(&mut self) -> Option<&'b str>
pub fn bytes(&mut self) -> Option<&'b [u8]>
Sourcepub fn list(&mut self) -> Option<usize>
pub fn list(&mut self) -> Option<usize>
A list next: how many values; Decoder::leave after them.
Sourcepub fn ints(&mut self) -> Option<usize>
pub fn ints(&mut self) -> Option<usize>
A packed list of ints next (Decoder::packed_int each): how many.
Sourcepub fn stream(&mut self) -> Option<&'b [u8]>
pub fn stream(&mut self) -> Option<&'b [u8]>
A stream next: its body (count and values, strings its own).
Sourcepub fn floats(&mut self) -> Option<Vec<f64>>
pub fn floats(&mut self) -> Option<Vec<f64>>
A packed list of floats next: each one. (Written narrow when they fit: widened back.)
Sourcepub fn packed_int(&mut self) -> Option<i64>
pub fn packed_int(&mut self) -> Option<i64>
One int of a packed list.
Sourcepub fn map(&mut self) -> Option<usize>
pub fn map(&mut self) -> Option<usize>
A map next: how many entries, each a Decoder::key and a value;
Decoder::leave after them.
pub fn key(&mut self) -> Option<&'b str>
Auto Trait Implementations§
impl<'b> Freeze for Decoder<'b>
impl<'b> RefUnwindSafe for Decoder<'b>
impl<'b> Send for Decoder<'b>
impl<'b> Sync for Decoder<'b>
impl<'b> Unpin for Decoder<'b>
impl<'b> UnsafeUnpin for Decoder<'b>
impl<'b> UnwindSafe for Decoder<'b>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more