Trait FromToBytes

Source
pub trait FromToBytes:
    Sized
    + ViewReflex
    + Copy {
    // Required methods
    fn ex_from_le_bytes(s: &[u8]) -> Self;
    fn ex_to_le_bytes(&self, s: &mut Vec<u8>, pos: usize);
    fn eq(&self, other: &Self) -> bool;
}
Expand description

A trait for converting an integer type to and from a sequence of bytes.

Required Methods§

Source

fn ex_from_le_bytes(s: &[u8]) -> Self

Converts a sequence of bytes to an integer in little-endian byte order.

Source

fn ex_to_le_bytes(&self, s: &mut Vec<u8>, pos: usize)

Converts an integer to a sequence of bytes in little-endian byte order.

Source

fn eq(&self, other: &Self) -> bool

Compares two integers for equality.

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 FromToBytes for u8

Source§

fn ex_from_le_bytes(s: &[u8]) -> u8

Source§

fn ex_to_le_bytes(&self, s: &mut Vec<u8>, pos: usize)

Source§

fn eq(&self, other: &u8) -> bool

Source§

impl FromToBytes for u16

Source§

fn ex_from_le_bytes(s: &[u8]) -> u16

Source§

fn ex_to_le_bytes(&self, s: &mut Vec<u8>, pos: usize)

Source§

fn eq(&self, other: &u16) -> bool

Source§

impl FromToBytes for u32

Source§

fn ex_from_le_bytes(s: &[u8]) -> u32

Source§

fn ex_to_le_bytes(&self, s: &mut Vec<u8>, pos: usize)

Source§

fn eq(&self, other: &u32) -> bool

Source§

impl FromToBytes for u64

Source§

fn ex_from_le_bytes(s: &[u8]) -> u64

Source§

fn ex_to_le_bytes(&self, s: &mut Vec<u8>, pos: usize)

Source§

fn eq(&self, other: &u64) -> bool

Implementors§