NativePack

Trait NativePack 

Source
pub trait NativePack: Sized {
    // Required methods
    fn pack_size(&self) -> usize;
    fn pack_unchecked(&self, buffer: &mut [u8]);

    // Provided method
    fn pack<'a>(&self, buffer: &'a mut [u8]) -> Result<&'a mut [u8]> { ... }
}
Expand description

Pack value into byte slice, using native endian

Required Methods§

Source

fn pack_size(&self) -> usize

Source

fn pack_unchecked(&self, buffer: &mut [u8])

Pack value into slice without failing

Provided Methods§

Source

fn pack<'a>(&self, buffer: &'a mut [u8]) -> Result<&'a mut [u8]>

Pack value into byte slice, returning the unused part of the 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 NativePack for f32

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for f64

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for i8

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for i16

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for i32

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for i64

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for u8

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for u16

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for u32

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for u64

Source§

fn pack_size(&self) -> usize

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Source§

impl NativePack for Vec<u8>

Source§

fn pack_size(&self) -> usize

Source§

fn pack<'a>(&self, buffer: &'a mut [u8]) -> Result<&'a mut [u8]>

Source§

fn pack_unchecked(&self, buffer: &mut [u8])

Implementors§