WriteToHeapless

Struct WriteToHeapless 

Source
pub struct WriteToHeapless<'a, LenT: LenType, S: VecStorage<u8> + ?Sized>(pub &'a mut VecInner<u8, LenT, S>);
Expand description

Wrapper around a heapless::Vec that can be written to by minicbor.

The wrapper can generally be short-lived; it updates the vector’s length as it goes. The vector consequently contains incomplete data if encoding errs out prematurely.

§Usage example

use minicbor_adapters::WriteToHeapless;
let mut buf = heapless::Vec::<u8, 32>::new();
minicbor::encode([1, 2, 3], WriteToHeapless(&mut buf)).unwrap();
assert_eq!(&[0x83, 1, 2, 3], &buf);

Tuple Fields§

§0: &'a mut VecInner<u8, LenT, S>

Trait Implementations§

Source§

impl<'a, LenT: Debug + LenType, S: Debug + VecStorage<u8> + ?Sized> Debug for WriteToHeapless<'a, LenT, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<LenT: LenType, S: VecStorage<u8> + ?Sized> Write for WriteToHeapless<'_, LenT, S>

Source§

type Error = CapacityError

Source§

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Error>

Write the whole byte slice.

Auto Trait Implementations§

§

impl<'a, LenT, S> Freeze for WriteToHeapless<'a, LenT, S>
where S: ?Sized,

§

impl<'a, LenT, S> RefUnwindSafe for WriteToHeapless<'a, LenT, S>
where LenT: RefUnwindSafe, S: RefUnwindSafe + ?Sized,

§

impl<'a, LenT, S> Send for WriteToHeapless<'a, LenT, S>
where S: Send + ?Sized,

§

impl<'a, LenT, S> Sync for WriteToHeapless<'a, LenT, S>
where S: Sync + ?Sized,

§

impl<'a, LenT, S> Unpin for WriteToHeapless<'a, LenT, S>
where S: ?Sized,

§

impl<'a, LenT, S> !UnwindSafe for WriteToHeapless<'a, LenT, S>

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.