pub struct TLV<Type, Length, EncodedType, Payload> {
pub tlv_type: EncodedType,
pub payload: Payload,
pub _phantom: PhantomData<(Type, Length)>,
}
Expand description
A TLV.
This has to be constructed with ..Default::default()
as internally there exists a PhantomData.
The first type parameter is the raw type of the tlv type.
The second is the strongly typed tlv type, which has to implement conversions from and into the raw tlv type.
The third parameter is the type of the length of the TLV.
The last parameter is a constant boolean, which describes if the fields should be encoded using big endian.
Fields§
§tlv_type: EncodedType
§payload: Payload
§_phantom: PhantomData<(Type, Length)>
Implementations§
source§impl<'a, Type: TryFromCtx<'a, Endian, Error = Error> + TryIntoCtx<Endian, Error = Error> + From<EncodedType>, Length: 'a + TryFromCtx<'a, Endian, Error = Error> + TryIntoCtx<Endian, Error = Error> + TryInto<usize> + TryFrom<usize>, EncodedType: 'a + From<Type>, Payload: TryFromCtx<'a, Error = Error> + TryIntoCtx<Error = Error> + MeasureWith<()>> TLV<Type, Length, EncodedType, Payload>
impl<'a, Type: TryFromCtx<'a, Endian, Error = Error> + TryIntoCtx<Endian, Error = Error> + From<EncodedType>, Length: 'a + TryFromCtx<'a, Endian, Error = Error> + TryIntoCtx<Endian, Error = Error> + TryInto<usize> + TryFrom<usize>, EncodedType: 'a + From<Type>, Payload: TryFromCtx<'a, Error = Error> + TryIntoCtx<Error = Error> + MeasureWith<()>> TLV<Type, Length, EncodedType, Payload>
sourcepub fn from_bytes(bytes: &'a [u8], big_endian: bool) -> Result<Self, Error>
pub fn from_bytes(bytes: &'a [u8], big_endian: bool) -> Result<Self, Error>
Wrapper around scroll Pread.
sourcepub fn into_bytes(
self,
buf: &mut [u8],
big_endian: bool
) -> Result<usize, Error>
pub fn into_bytes( self, buf: &mut [u8], big_endian: bool ) -> Result<usize, Error>
Serialize into the buffer.
sourcepub fn into_bytes_capped<const N: usize>(
self,
big_endian: bool
) -> Result<Vec<u8, N>, Error>
pub fn into_bytes_capped<const N: usize>( self, big_endian: bool ) -> Result<Vec<u8, N>, Error>
Serialize into a heapless::Vec.
Trait Implementations§
source§impl<Type: Clone, Length: Clone, EncodedType: Clone, Payload: Clone> Clone for TLV<Type, Length, EncodedType, Payload>
impl<Type: Clone, Length: Clone, EncodedType: Clone, Payload: Clone> Clone for TLV<Type, Length, EncodedType, Payload>
source§impl<Type: Debug, Length: Debug, EncodedType: Debug, Payload: Debug> Debug for TLV<Type, Length, EncodedType, Payload>
impl<Type: Debug, Length: Debug, EncodedType: Debug, Payload: Debug> Debug for TLV<Type, Length, EncodedType, Payload>
source§impl<Type: Default, Length: Default, EncodedType: Default, Payload: Default> Default for TLV<Type, Length, EncodedType, Payload>
impl<Type: Default, Length: Default, EncodedType: Default, Payload: Default> Default for TLV<Type, Length, EncodedType, Payload>
source§impl<Type: SizeWith, Length: SizeWith, EncodedType: From<Type>, Payload: MeasureWith<()>> MeasureWith<()> for TLV<Type, Length, EncodedType, Payload>
impl<Type: SizeWith, Length: SizeWith, EncodedType: From<Type>, Payload: MeasureWith<()>> MeasureWith<()> for TLV<Type, Length, EncodedType, Payload>
source§fn measure_with(&self, ctx: &()) -> usize
fn measure_with(&self, ctx: &()) -> usize
How large is
Self
, given the ctx
?source§impl<Type: PartialEq, Length: PartialEq, EncodedType: PartialEq, Payload: PartialEq> PartialEq for TLV<Type, Length, EncodedType, Payload>
impl<Type: PartialEq, Length: PartialEq, EncodedType: PartialEq, Payload: PartialEq> PartialEq for TLV<Type, Length, EncodedType, Payload>
source§impl<'a, Type: TryFromCtx<'a, Endian, Error = Error>, Length: TryFromCtx<'a, Endian, Error = Error> + TryInto<usize>, EncodedType: 'a + From<Type>, Payload: TryFromCtx<'a, Error = Error>> TryFromCtx<'a, Endian> for TLV<Type, Length, EncodedType, Payload>
impl<'a, Type: TryFromCtx<'a, Endian, Error = Error>, Length: TryFromCtx<'a, Endian, Error = Error> + TryInto<usize>, EncodedType: 'a + From<Type>, Payload: TryFromCtx<'a, Error = Error>> TryFromCtx<'a, Endian> for TLV<Type, Length, EncodedType, Payload>
source§impl<Type: TryIntoCtx<Endian, Error = Error>, Length: TryIntoCtx<Endian, Error = Error> + TryFrom<usize>, EncodedType: Into<Type>, Payload: TryIntoCtx<Error = Error> + MeasureWith<()>> TryIntoCtx<Endian> for TLV<Type, Length, EncodedType, Payload>
impl<Type: TryIntoCtx<Endian, Error = Error>, Length: TryIntoCtx<Endian, Error = Error> + TryFrom<usize>, EncodedType: Into<Type>, Payload: TryIntoCtx<Error = Error> + MeasureWith<()>> TryIntoCtx<Endian> for TLV<Type, Length, EncodedType, Payload>
impl<Type: Eq, Length: Eq, EncodedType: Eq, Payload: Eq> Eq for TLV<Type, Length, EncodedType, Payload>
impl<Type, Length, EncodedType, Payload> StructuralEq for TLV<Type, Length, EncodedType, Payload>
impl<Type, Length, EncodedType, Payload> StructuralPartialEq for TLV<Type, Length, EncodedType, Payload>
Auto Trait Implementations§
impl<Type, Length, EncodedType, Payload> RefUnwindSafe for TLV<Type, Length, EncodedType, Payload>where
EncodedType: RefUnwindSafe,
Length: RefUnwindSafe,
Payload: RefUnwindSafe,
Type: RefUnwindSafe,
impl<Type, Length, EncodedType, Payload> Send for TLV<Type, Length, EncodedType, Payload>
impl<Type, Length, EncodedType, Payload> Sync for TLV<Type, Length, EncodedType, Payload>
impl<Type, Length, EncodedType, Payload> Unpin for TLV<Type, Length, EncodedType, Payload>
impl<Type, Length, EncodedType, Payload> UnwindSafe for TLV<Type, Length, EncodedType, Payload>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more