Struct Kernel

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

This decoding kernel reads from an underlying std::io::Read type primitive CBOR values such as unsigned and signed integers as well as raw bytes. It forms the basis on which Decoder and GenericDecoder add logic for handling Tags, heterogenous data and generic value decoding.

Implementations§

Source§

impl<R: ReadBytesExt> Kernel<R>

Source

pub fn new(r: R) -> Kernel<R>

Source

pub fn into_reader(self) -> R

Source

pub fn typeinfo(&mut self) -> DecodeResult<TypeInfo>

Source

pub fn simple(&mut self, ti: &TypeInfo) -> DecodeResult<Simple>

Source

pub fn bool(&mut self, ti: &TypeInfo) -> DecodeResult<bool>

Source

pub fn u8(&mut self, ti: &TypeInfo) -> DecodeResult<u8>

Source

pub fn u16(&mut self, ti: &TypeInfo) -> DecodeResult<u16>

Source

pub fn u32(&mut self, ti: &TypeInfo) -> DecodeResult<u32>

Source

pub fn u64(&mut self, ti: &TypeInfo) -> DecodeResult<u64>

Source

pub fn i8(&mut self, ti: &TypeInfo) -> DecodeResult<i8>

Source

pub fn i16(&mut self, ti: &TypeInfo) -> DecodeResult<i16>

Source

pub fn i32(&mut self, ti: &TypeInfo) -> DecodeResult<i32>

Source

pub fn i64(&mut self, ti: &TypeInfo) -> DecodeResult<i64>

Source

pub fn int(&mut self, ti: &TypeInfo) -> DecodeResult<Int>

Source

pub fn f16(&mut self, ti: &TypeInfo) -> DecodeResult<f32>

Source

pub fn f32(&mut self, ti: &TypeInfo) -> DecodeResult<f32>

Source

pub fn f64(&mut self, ti: &TypeInfo) -> DecodeResult<f64>

Source

pub fn unsigned(&mut self, first: u8) -> DecodeResult<u64>

Decode first and potentially the following bytes as an unsigned value following the rules of major type 0.

Source

pub fn raw_data(&mut self, begin: u8, max_len: usize) -> DecodeResult<Vec<u8>>

Read begin as the length and return that many raw bytes.

If length is greater than the given max_len, DecodeError::TooLong is returned instead.

Source

pub fn read_raw_data( &mut self, begin: u8, buf: &mut [u8], ) -> DecodeResult<usize>

Read begin as the length and read that many raw bytes into buf.

If length is greater than the given buffer, DecodeError::TooLong is returned instead.

Source§

impl<R: ReadBytesExt + ReadSlice> Kernel<R>

Source

pub fn raw_slice(&mut self, begin: u8, max_len: usize) -> DecodeResult<&[u8]>

Read begin as the length and return that many raw bytes as a slice.

If length is greater than the given max_len, DecodeError::TooLong is returned instead.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<R> UnwindSafe for Kernel<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.