spinel_pack

Trait TryUnpackAs

Source
pub trait TryUnpackAs<'a, Marker: ?Sized>: Sized {
    // Required method
    fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>;

    // Provided method
    fn try_unpack_as_from_slice(slice: &'a [u8]) -> Result<Self> { ... }
}
Expand description

Trait for unpacking a spinel-encoded buffer to a specific type when the field type is known.

The generic parameter Marker is effectiely a part of the name of the trait and is not used directly by the trait. Types may implement more than one instance of this trait, each with a different marker type. For example, structs that use the spinel_packed attribute macro will implement both TryUnpackAs<[u8]> and TryUnpackAs<SpinelDataWlen> for handling the D and d Spinel field formats respectively when deserializing.

Required Methods§

Source

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Attempts to decode the data (with a format determined by Marker) at the given iterator into an instance of Self.

Provided Methods§

Source

fn try_unpack_as_from_slice(slice: &'a [u8]) -> Result<Self>

Convenience method for unpacking directly from a borrowed slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for &'a [u8]

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for bool

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for i8

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for i16

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for i32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for i64

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for u8

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for u16

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for u32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for u64

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for ()

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for Ipv6Addr

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, SpinelUint> for u32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, bool> for bool

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, i8> for i8

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, i16> for i16

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, i32> for i32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, i64> for i64

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, str> for &'a str

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, str> for &'a [u8]

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, str> for String

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, str> for Vec<u8>

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, u8> for u8

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, u16> for u16

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, u32> for u32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, u64> for u64

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, ()> for ()

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, Ipv6Addr> for Ipv6Addr

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for &'a [u8]

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for bool

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for i8

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for i16

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for i32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for i64

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for u8

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for u16

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for u32

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for u64

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for ()

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a> TryUnpackAs<'a, [u8]> for Ipv6Addr

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a, T> TryUnpackAs<'a, SpinelDataWlen> for Vec<T>
where Self: TryUnpackAs<'a, [u8]>,

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a, T> TryUnpackAs<'a, [u8]> for Vec<T>
where Self: TryUnpack<'a, Unpacked = Self>,

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a, T, const N: usize> TryUnpackAs<'a, SpinelDataWlen> for [T; N]
where Self: TryUnpackAs<'a, [u8]>,

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Source§

impl<'a, T, const N: usize> TryUnpackAs<'a, [u8]> for [T; N]
where Self: TryUnpack<'a, Unpacked = Self>,

Source§

fn try_unpack_as(iter: &mut Iter<'a, u8>) -> Result<Self>

Implementors§

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for EUI48

Source§

impl<'a> TryUnpackAs<'a, SpinelDataWlen> for EUI64

Source§

impl<'a> TryUnpackAs<'a, EUI48> for EUI48

Source§

impl<'a> TryUnpackAs<'a, EUI64> for EUI64

Source§

impl<'a> TryUnpackAs<'a, [u8]> for EUI48

Source§

impl<'a> TryUnpackAs<'a, [u8]> for EUI64