pub trait TryOwnedUnpack: Send {
    type Unpacked: Send + Sized + Debug;

    // Required method
    fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>;

    // Provided methods
    fn try_array_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked> { ... }
    fn try_owned_unpack_from_slice(slice: &[u8]) -> Result<Self::Unpacked> { ... }
}
Expand description

Trait for unpacking only into owned types, like Vec<u8> or String.

Similar to TryUnpack, except that this trait cannot unpack into borrowed types like &[u8] or &str.

If you have a TryOwnedUnpack implementation, you can automatically implement TryUnpack using the impl_try_unpack_for_owned! macro.

Required Associated Types§

source

type Unpacked: Send + Sized + Debug

The type of the unpacked result. This can be the same as Self, but in some cases it can be different. This is because Self is a marker type, and may not even be Sized. For example, if Self is SpinelUint, then Unpacked would be u32 (because SpinelUint is just a marker trait indicating a variably-sized unsigned integer).

Required Methods§

source

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

Attempts to decode the data at the given iterator into an instance of Self, where Self must be an “owned” type.

Provided Methods§

source

fn try_array_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

Attempts to decode an item from an array at the given iterator into an instance of Self, where Self must be an “owned” type.

Array encoding is occasionally different than single-value encoding, hence the need for a separate method.

Default behavior is the same as try_owned_unpack().

source

fn try_owned_unpack_from_slice(slice: &[u8]) -> Result<Self::Unpacked>

Convenience method for unpacking directly from a borrowed slice.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TryOwnedUnpack for bool

§

type Unpacked = bool

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for i8

§

type Unpacked = i8

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for i16

§

type Unpacked = i16

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for i32

§

type Unpacked = i32

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for i64

§

type Unpacked = i64

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for u8

§

type Unpacked = u8

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for u16

§

type Unpacked = u16

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for u32

§

type Unpacked = u32

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for u64

§

type Unpacked = u64

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for ()

§

type Unpacked = ()

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for String

§

type Unpacked = String

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl TryOwnedUnpack for Ipv6Addr

§

type Unpacked = Ipv6Addr

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl<T> TryOwnedUnpack for [T]
where T: TryOwnedUnpack,

§

type Unpacked = Vec<<T as TryOwnedUnpack>::Unpacked>

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

fn try_array_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl<T> TryOwnedUnpack for Vec<T>
where T: TryOwnedUnpack,

§

type Unpacked = Vec<<T as TryOwnedUnpack>::Unpacked>

source§

fn try_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

fn try_array_owned_unpack(iter: &mut Iter<'_, u8>) -> Result<Self::Unpacked>

source§

impl<T> TryOwnedUnpack for HashSet<T>
where T: TryOwnedUnpack, T::Unpacked: Eq + Hash,

Implementors§