pub struct Decoder<R> { /* private fields */ }
Expand description
The actual decoder type definition
Implementations§
Source§impl<R: ReadBytesExt> Decoder<R>
impl<R: ReadBytesExt> Decoder<R>
pub fn new(c: Config, r: R) -> Decoder<R>
pub fn into_reader(self) -> R
pub fn kernel(&mut self) -> &mut Kernel<R>
pub fn simple(&mut self) -> DecodeResult<Simple>
pub fn bool(&mut self) -> DecodeResult<bool>
pub fn u8(&mut self) -> DecodeResult<u8>
pub fn u16(&mut self) -> DecodeResult<u16>
pub fn u32(&mut self) -> DecodeResult<u32>
pub fn u64(&mut self) -> DecodeResult<u64>
pub fn i8(&mut self) -> DecodeResult<i8>
pub fn i16(&mut self) -> DecodeResult<i16>
pub fn i32(&mut self) -> DecodeResult<i32>
pub fn i64(&mut self) -> DecodeResult<i64>
pub fn int(&mut self) -> DecodeResult<Int>
pub fn f16(&mut self) -> DecodeResult<f32>
pub fn f32(&mut self) -> DecodeResult<f32>
pub fn f64(&mut self) -> DecodeResult<f64>
Sourcepub fn read_bytes(&mut self, b: &mut [u8]) -> DecodeResult<usize>
pub fn read_bytes(&mut self, b: &mut [u8]) -> DecodeResult<usize>
Decode a single byte string into the given buffer.
The provided buffer must be large enough to hold the entire byte string, otherwise an error is returned.
Please note that indefinite byte strings are not supported by this
method (Consider using Decoder::bytes_iter()
for this use-case).
Sourcepub fn bytes(&mut self) -> DecodeResult<Vec<u8>>
pub fn bytes(&mut self) -> DecodeResult<Vec<u8>>
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).
Sourcepub fn bytes_iter(&mut self) -> DecodeResult<BytesIter<'_, R>>
pub fn bytes_iter(&mut self) -> DecodeResult<BytesIter<'_, R>>
Decode an indefinite byte string.
Sourcepub fn text(&mut self) -> DecodeResult<String>
pub fn text(&mut self) -> DecodeResult<String>
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).
Sourcepub fn text_iter(&mut self) -> DecodeResult<TextIter<'_, R>>
pub fn text_iter(&mut self) -> DecodeResult<TextIter<'_, R>>
Decode an indefinite string.
Sourcepub fn tag(&mut self) -> DecodeResult<Tag>
pub fn tag(&mut self) -> DecodeResult<Tag>
Decode a Tag
.
If no tag is found an UnexpectedType
error is returned.
Sourcepub fn array(&mut self) -> DecodeResult<usize>
pub fn array(&mut self) -> DecodeResult<usize>
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).
Sourcepub fn array_begin(&mut self) -> DecodeResult<()>
pub fn array_begin(&mut self) -> DecodeResult<()>
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).
Sourcepub fn object(&mut self) -> DecodeResult<usize>
pub fn object(&mut self) -> DecodeResult<usize>
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).
Sourcepub fn object_begin(&mut self) -> DecodeResult<()>
pub fn object_begin(&mut self) -> DecodeResult<()>
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).
Source§impl<R: ReadBytesExt + Skip> Decoder<R>
impl<R: ReadBytesExt + Skip> Decoder<R>
Sourcepub fn skip(&mut self) -> DecodeResult<()>
pub fn skip(&mut self) -> DecodeResult<()>
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.
Source§impl<R: ReadBytesExt + ReadSlice> Decoder<R>
impl<R: ReadBytesExt + ReadSlice> Decoder<R>
Sourcepub fn text_borrow(&mut self) -> DecodeResult<&str>
pub fn text_borrow(&mut self) -> DecodeResult<&str>
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.
Sourcepub fn bytes_borrow(&mut self) -> DecodeResult<&[u8]>
pub fn bytes_borrow(&mut self) -> DecodeResult<&[u8]>
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.