Trait spinel_pack::TryPack

source ·
pub trait TryPack {
    // Required methods
    fn try_pack<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize>;
    fn pack_len(&self) -> Result<usize>;

    // Provided methods
    fn try_array_pack<T: Write + ?Sized>(&self, buffer: &mut T) -> Result<usize> { ... }
    fn array_pack_len(&self) -> Result<usize> { ... }
    fn try_packed(&self) -> Result<Vec<u8>> { ... }
}
Expand description

Trait implemented by data types that support being serialized to a spinel-based byte encoding.

Required Methods§

source

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

Uses Spinel encoding to serialize to a given std::io::Write reference.

source

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

Calculates how many bytes this type will use when serialized.

Provided Methods§

source

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

Uses Spinel array encoding to serialize to a given std::io::Write reference.

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

Default behavior is the same as try_pack().

source

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

Calculates how many bytes this type will use when serialized into an array.

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

Default behavior is the same as pack_len().

source

fn try_packed(&self) -> Result<Vec<u8>>

Convenience method which serializes to a new Vec<u8>.

Implementations on Foreign Types§

source§

impl<T: TryPack> TryPack for HashSet<T>

source§

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

source§

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

source§

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

source§

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

source§

impl<T: TryPack> TryPack for &[T]

source§

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

source§

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

source§

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

source§

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

source§

impl TryPack for &str

source§

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

source§

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

source§

impl TryPack for u32

source§

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

source§

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

source§

impl TryPack for str

source§

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

source§

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

source§

impl TryPack for i16

source§

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

source§

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

source§

impl TryPack for Ipv6Addr

source§

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

source§

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

source§

impl TryPack for i8

source§

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

source§

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

source§

impl TryPack for i32

source§

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

source§

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

source§

impl TryPack for bool

source§

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

source§

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

source§

impl TryPack for ()

source§

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

source§

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

source§

impl TryPack for u16

source§

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

source§

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

source§

impl TryPack for String

source§

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

source§

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

source§

impl TryPack for i64

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl TryPack for u64

source§

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

source§

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

source§

impl TryPack for u8

source§

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

source§

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

Implementors§