Struct Decoder

Source
pub struct Decoder<R> { /* private fields */ }
Expand description

The actual decoder type definition

Implementations§

Source§

impl<R: ReadBytesExt> Decoder<R>

Source

pub fn new(c: Config, r: R) -> Decoder<R>

Source

pub fn into_reader(self) -> R

Source

pub fn kernel(&mut self) -> &mut Kernel<R>

Source

pub fn simple(&mut self) -> DecodeResult<Simple>

Source

pub fn bool(&mut self) -> DecodeResult<bool>

Source

pub fn u8(&mut self) -> DecodeResult<u8>

Source

pub fn u16(&mut self) -> DecodeResult<u16>

Source

pub fn u32(&mut self) -> DecodeResult<u32>

Source

pub fn u64(&mut self) -> DecodeResult<u64>

Source

pub fn i8(&mut self) -> DecodeResult<i8>

Source

pub fn i16(&mut self) -> DecodeResult<i16>

Source

pub fn i32(&mut self) -> DecodeResult<i32>

Source

pub fn i64(&mut self) -> DecodeResult<i64>

Source

pub fn int(&mut self) -> DecodeResult<Int>

Source

pub fn f16(&mut self) -> DecodeResult<f32>

Source

pub fn f32(&mut self) -> DecodeResult<f32>

Source

pub fn f64(&mut self) -> DecodeResult<f64>

Source

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).

Source

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).

Source

pub fn bytes_iter(&mut self) -> DecodeResult<BytesIter<'_, R>>

Decode an indefinite byte string.

Source

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).

Source

pub fn text_iter(&mut self) -> DecodeResult<TextIter<'_, R>>

Decode an indefinite string.

Source

pub fn tag(&mut self) -> DecodeResult<Tag>

Decode a Tag. If no tag is found an UnexpectedType error is returned.

Source

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).

Source

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).

Source

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).

Source

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>

Source

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>

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<R> Freeze for Decoder<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for Decoder<R>
where R: RefUnwindSafe,

§

impl<R> Send for Decoder<R>
where R: Send,

§

impl<R> Sync for Decoder<R>
where R: Sync,

§

impl<R> Unpin for Decoder<R>
where R: Unpin,

§

impl<R> UnwindSafe for Decoder<R>
where R: UnwindSafe,

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.