Struct probor::Decoder
[−]
pub struct Decoder<R> { /* fields omitted */ }
The actual decoder type definition
Methods
impl<R> Decoder<R> where R: ReadBytesExt
fn new(c: Config, r: R) -> Decoder<R>
fn into_reader(self) -> R
fn kernel(&mut self) -> &mut Kernel<R>
fn simple(&mut self) -> Result<Simple, DecodeError>
fn bool(&mut self) -> Result<bool, DecodeError>
fn u8(&mut self) -> Result<u8, DecodeError>
fn u16(&mut self) -> Result<u16, DecodeError>
fn u32(&mut self) -> Result<u32, DecodeError>
fn u64(&mut self) -> Result<u64, DecodeError>
fn i8(&mut self) -> Result<i8, DecodeError>
fn i16(&mut self) -> Result<i16, DecodeError>
fn i32(&mut self) -> Result<i32, DecodeError>
fn i64(&mut self) -> Result<i64, DecodeError>
fn int(&mut self) -> Result<Int, DecodeError>
fn f16(&mut self) -> Result<f32, DecodeError>
fn f32(&mut self) -> Result<f32, DecodeError>
fn f64(&mut self) -> Result<f64, DecodeError>
fn bytes(&mut self) -> Result<Vec<u8>, DecodeError>
Decode a single byte string.
Please note that indefinite byte strings are not supported by this
method (Consider using Decoder::bytes_iter()
for this use-case).
fn bytes_iter(&mut self) -> Result<BytesIter<R>, DecodeError>
Decode an indefinite byte string.
fn text(&mut self) -> Result<String, DecodeError>
Decode a single UTF-8 encoded String.
Please note that indefinite strings are not supported by this method
(Consider using Decoder::text_iter()
for this use-case).
fn text_iter(&mut self) -> Result<TextIter<R>, DecodeError>
Decode an indefinite string.
fn tag(&mut self) -> Result<Tag, DecodeError>
Decode a Tag
.
If no tag is found an UnexpectedType
error is returned.
fn array(&mut self) -> Result<usize, DecodeError>
Decode the begin of an array. The length is returned unless it exceeds the configured maximum.
Please note that indefinite arrays are not supported by this method
(Consider using Decoder::array_begin()
for this use-case).
fn array_begin(&mut self) -> Result<(), DecodeError>
Decode the begin of an indefinite array.
After this one can continue decoding items, but a Break
value
will be encountered at some unknown point.
(Consider using or_break
around every decoding step within an
indefinite array to handle this case).
fn object(&mut self) -> Result<usize, DecodeError>
Decode the begin of an object. The size (number of key-value pairs) is returned unless it exceeds the configured maximum.
Please note that indefinite objects are not supported by this method
(Consider using Decoder::object_begin
for this use-case).
fn object_begin(&mut self) -> Result<(), DecodeError>
Decode the begin of an indefinite object.
After this one can continue decoding items, but a Break
value
will be encountered at some unknown point.
(Consider using or_break
around every decoding step within an
indefinite object to handle this case).
impl<R> Decoder<R> where R: Skip + ReadBytesExt
fn skip(&mut self) -> Result<(), DecodeError>
Skip over a single CBOR value.
Please note that this function does not validate the value hence
it might not even be well-formed CBOR. Instead skip
is an
optimisation over GenericDecoder::value()
and generally only
determines as much information as necessary to safely skip a value
without keeping all of it in memory.
impl<R> Decoder<R> where R: ReadSlice + ReadBytesExt
fn text_borrow(&mut self) -> Result<&str, DecodeError>
Decode a single UTF-8 encoded String and borrow it from underlying buffer instead of allocating.
Please note that indefinite strings are not supported by this method.
fn bytes_borrow(&mut self) -> Result<&[u8], DecodeError>
Decode a single byte string and borrow it from underlying buffer instead of allocating.
Please note that indefinite byte strings are not supported by this method.