spinel_pack

Trait TryPackAs

Source
pub trait TryPackAs<Marker: ?Sized> {
    // Required methods
    fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>;
    fn pack_as_len(&self) -> Result<usize>;
}
Expand description

Trait implemented by data types that support being serialized to a specific spinel-based byte encoding, based on the marker type.

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 TryPackAs<[u8]> and TryPackAs<SpinelDataWlen> for handling the D and d Spinel field formats respectively when serializing.

Required Methods§

Source

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Uses Spinel encoding to serialize to a given std::io::Write reference as the Spinel type identified by Marker.

Source

fn pack_as_len(&self) -> Result<usize>

Calculates how many bytes this type will use when serialized.

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 TryPackAs<SpinelDataWlen> for bool

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for i8

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for i16

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for i32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for i64

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for u8

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for u16

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for u32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for u64

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for ()

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelDataWlen> for Ipv6Addr

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<SpinelUint> for u32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<bool> for bool

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<i8> for i8

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<i16> for i16

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<i32> for i32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<i64> for i64

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<str> for &str

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<str> for &[u8]

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<str> for str

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<str> for String

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<str> for Vec<u8>

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<u8> for u8

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<u16> for u16

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<u32> for u32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<u64> for u64

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<()> for ()

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<Ipv6Addr> for Ipv6Addr

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for bool

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for i8

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for i16

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for i32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for i64

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for u8

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for u16

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for u32

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for u64

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for ()

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl TryPackAs<[u8]> for Ipv6Addr

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>

Source§

impl<T> TryPackAs<SpinelDataWlen> for &[T]
where Self: TryPackAs<[u8]>,

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<B: Write + ?Sized>(&self, buffer: &mut B) -> Result<usize>

Source§

impl<T> TryPackAs<SpinelDataWlen> for Vec<T>
where for<'a> &'a [T]: TryPackAs<SpinelDataWlen>,

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<B: Write + ?Sized>(&self, buffer: &mut B) -> Result<usize>

Source§

impl<T> TryPackAs<[u8]> for &[T]
where Self: TryPack,

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<B: Write + ?Sized>(&self, buffer: &mut B) -> Result<usize>

Source§

impl<T> TryPackAs<[u8]> for Vec<T>
where for<'a> &'a [T]: TryPackAs<[u8]>,

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<B: Write + ?Sized>(&self, buffer: &mut B) -> Result<usize>

Source§

impl<T, const N: usize> TryPackAs<SpinelDataWlen> for [T; N]
where for<'a> &'a [T]: TryPackAs<SpinelDataWlen>,

Source§

fn pack_as_len(&self) -> Result<usize>

Source§

fn try_pack_as<B: Write + ?Sized>(&self, buffer: &mut B) -> Result<usize>

Implementors§