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. Versions 1 and 2 are read; a version 1 document may use only the tags it was written with.
§Errors
DecodeError when the header isn’t SDAT and a version this reads.
Source§impl<'b> Decoder<'b>
impl<'b> Decoder<'b>
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.
§Errors
DecodeError when the bytes aren’t a value.
Source§impl<'b> Decoder<'b>
impl<'b> Decoder<'b>
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.