ByteValued

Trait ByteValued 

Source
pub unsafe trait ByteValued:
    Copy
    + Send
    + Sync {
    // Provided methods
    fn from_slice(data: &[u8]) -> Option<&Self> { ... }
    fn from_mut_slice(data: &mut [u8]) -> Option<&mut Self> { ... }
    fn as_slice(&self) -> &[u8]  { ... }
    fn as_mut_slice(&mut self) -> &mut [u8]  { ... }
    fn as_bytes(&mut self) -> VolatileSlice<'_> { ... }
    fn zeroed() -> Self { ... }
    fn write_all_to<W: Write>(&self, writer: W) -> Result<(), Error> { ... }
    fn read_exact_from<R: Read>(reader: R) -> Result<Self, Error> { ... }
}
Expand description

Types for which it is safe to initialize from raw data.

§Safety

A type T is ByteValued if and only if it can be initialized by reading its contents from a byte array. This is generally true for all plain-old-data structs. It is notably not true for any type that includes a reference. It is generally also not safe for non-packed structs, as compiler-inserted padding is considered uninitialized memory, and thus reads/writing it will cause undefined behavior.

Implementing this trait guarantees that it is safe to instantiate the struct with random data.

Provided Methods§

Source

fn from_slice(data: &[u8]) -> Option<&Self>

Converts a slice of raw data into a reference of Self.

The value of data is not copied. Instead a reference is made from the given slice. The value of Self will depend on the representation of the type in memory, and may change in an unstable fashion.

This will return None if the length of data does not match the size of Self, or if the data is not aligned for the type of Self.

Source

fn from_mut_slice(data: &mut [u8]) -> Option<&mut Self>

Converts a mutable slice of raw data into a mutable reference of Self.

Because Self is made from a reference to the mutable slice, mutations to the returned reference are immediately reflected in data. The value of the returned Self will depend on the representation of the type in memory, and may change in an unstable fashion.

This will return None if the length of data does not match the size of Self, or if the data is not aligned for the type of Self.

Source

fn as_slice(&self) -> &[u8]

Converts a reference to self into a slice of bytes.

The value of self is not copied. Instead, the slice is made from a reference to self. The value of bytes in the returned slice will depend on the representation of the type in memory, and may change in an unstable fashion.

Source

fn as_mut_slice(&mut self) -> &mut [u8]

Converts a mutable reference to self into a mutable slice of bytes.

Because the slice is made from a reference to self, mutations to the returned slice are immediately reflected in self. The value of bytes in the returned slice will depend on the representation of the type in memory, and may change in an unstable fashion.

Source

fn as_bytes(&mut self) -> VolatileSlice<'_>

Converts a mutable reference to self into a VolatileSlice. This is useful because VolatileSlice provides a Bytes<usize> implementation.

Source

fn zeroed() -> Self

Constructs a Self ewhose binary representation is set to all zeroes.

Source

fn write_all_to<W: Write>(&self, writer: W) -> Result<(), Error>

Writes this ByteValued’s byte representation to the given Write impl.

Source

fn read_exact_from<R: Read>(reader: R) -> Result<Self, Error>

Constructs an instance of this ByteValued by reading from the given Read impl.

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 ByteValued for i8

Source§

impl ByteValued for i16

Source§

impl ByteValued for i32

Source§

impl ByteValued for i64

Source§

impl ByteValued for i128

Source§

impl ByteValued for isize

Source§

impl ByteValued for u8

Source§

impl ByteValued for u16

Source§

impl ByteValued for u32

Source§

impl ByteValued for u64

Source§

impl ByteValued for u128

Source§

impl ByteValued for usize

Source§

impl ByteValued for [i8; 0]

Source§

impl ByteValued for [i8; 1]

Source§

impl ByteValued for [i8; 2]

Source§

impl ByteValued for [i8; 3]

Source§

impl ByteValued for [i8; 4]

Source§

impl ByteValued for [i8; 5]

Source§

impl ByteValued for [i8; 6]

Source§

impl ByteValued for [i8; 7]

Source§

impl ByteValued for [i8; 8]

Source§

impl ByteValued for [i8; 9]

Source§

impl ByteValued for [i8; 10]

Source§

impl ByteValued for [i8; 11]

Source§

impl ByteValued for [i8; 12]

Source§

impl ByteValued for [i8; 13]

Source§

impl ByteValued for [i8; 14]

Source§

impl ByteValued for [i8; 15]

Source§

impl ByteValued for [i8; 16]

Source§

impl ByteValued for [i8; 17]

Source§

impl ByteValued for [i8; 18]

Source§

impl ByteValued for [i8; 19]

Source§

impl ByteValued for [i8; 20]

Source§

impl ByteValued for [i8; 21]

Source§

impl ByteValued for [i8; 22]

Source§

impl ByteValued for [i8; 23]

Source§

impl ByteValued for [i8; 24]

Source§

impl ByteValued for [i8; 25]

Source§

impl ByteValued for [i8; 26]

Source§

impl ByteValued for [i8; 27]

Source§

impl ByteValued for [i8; 28]

Source§

impl ByteValued for [i8; 29]

Source§

impl ByteValued for [i8; 30]

Source§

impl ByteValued for [i8; 31]

Source§

impl ByteValued for [i8; 32]

Source§

impl ByteValued for [i16; 0]

Source§

impl ByteValued for [i16; 1]

Source§

impl ByteValued for [i16; 2]

Source§

impl ByteValued for [i16; 3]

Source§

impl ByteValued for [i16; 4]

Source§

impl ByteValued for [i16; 5]

Source§

impl ByteValued for [i16; 6]

Source§

impl ByteValued for [i16; 7]

Source§

impl ByteValued for [i16; 8]

Source§

impl ByteValued for [i16; 9]

Source§

impl ByteValued for [i16; 10]

Source§

impl ByteValued for [i16; 11]

Source§

impl ByteValued for [i16; 12]

Source§

impl ByteValued for [i16; 13]

Source§

impl ByteValued for [i16; 14]

Source§

impl ByteValued for [i16; 15]

Source§

impl ByteValued for [i16; 16]

Source§

impl ByteValued for [i16; 17]

Source§

impl ByteValued for [i16; 18]

Source§

impl ByteValued for [i16; 19]

Source§

impl ByteValued for [i16; 20]

Source§

impl ByteValued for [i16; 21]

Source§

impl ByteValued for [i16; 22]

Source§

impl ByteValued for [i16; 23]

Source§

impl ByteValued for [i16; 24]

Source§

impl ByteValued for [i16; 25]

Source§

impl ByteValued for [i16; 26]

Source§

impl ByteValued for [i16; 27]

Source§

impl ByteValued for [i16; 28]

Source§

impl ByteValued for [i16; 29]

Source§

impl ByteValued for [i16; 30]

Source§

impl ByteValued for [i16; 31]

Source§

impl ByteValued for [i16; 32]

Source§

impl ByteValued for [i32; 0]

Source§

impl ByteValued for [i32; 1]

Source§

impl ByteValued for [i32; 2]

Source§

impl ByteValued for [i32; 3]

Source§

impl ByteValued for [i32; 4]

Source§

impl ByteValued for [i32; 5]

Source§

impl ByteValued for [i32; 6]

Source§

impl ByteValued for [i32; 7]

Source§

impl ByteValued for [i32; 8]

Source§

impl ByteValued for [i32; 9]

Source§

impl ByteValued for [i32; 10]

Source§

impl ByteValued for [i32; 11]

Source§

impl ByteValued for [i32; 12]

Source§

impl ByteValued for [i32; 13]

Source§

impl ByteValued for [i32; 14]

Source§

impl ByteValued for [i32; 15]

Source§

impl ByteValued for [i32; 16]

Source§

impl ByteValued for [i32; 17]

Source§

impl ByteValued for [i32; 18]

Source§

impl ByteValued for [i32; 19]

Source§

impl ByteValued for [i32; 20]

Source§

impl ByteValued for [i32; 21]

Source§

impl ByteValued for [i32; 22]

Source§

impl ByteValued for [i32; 23]

Source§

impl ByteValued for [i32; 24]

Source§

impl ByteValued for [i32; 25]

Source§

impl ByteValued for [i32; 26]

Source§

impl ByteValued for [i32; 27]

Source§

impl ByteValued for [i32; 28]

Source§

impl ByteValued for [i32; 29]

Source§

impl ByteValued for [i32; 30]

Source§

impl ByteValued for [i32; 31]

Source§

impl ByteValued for [i32; 32]

Source§

impl ByteValued for [i64; 0]

Source§

impl ByteValued for [i64; 1]

Source§

impl ByteValued for [i64; 2]

Source§

impl ByteValued for [i64; 3]

Source§

impl ByteValued for [i64; 4]

Source§

impl ByteValued for [i64; 5]

Source§

impl ByteValued for [i64; 6]

Source§

impl ByteValued for [i64; 7]

Source§

impl ByteValued for [i64; 8]

Source§

impl ByteValued for [i64; 9]

Source§

impl ByteValued for [i64; 10]

Source§

impl ByteValued for [i64; 11]

Source§

impl ByteValued for [i64; 12]

Source§

impl ByteValued for [i64; 13]

Source§

impl ByteValued for [i64; 14]

Source§

impl ByteValued for [i64; 15]

Source§

impl ByteValued for [i64; 16]

Source§

impl ByteValued for [i64; 17]

Source§

impl ByteValued for [i64; 18]

Source§

impl ByteValued for [i64; 19]

Source§

impl ByteValued for [i64; 20]

Source§

impl ByteValued for [i64; 21]

Source§

impl ByteValued for [i64; 22]

Source§

impl ByteValued for [i64; 23]

Source§

impl ByteValued for [i64; 24]

Source§

impl ByteValued for [i64; 25]

Source§

impl ByteValued for [i64; 26]

Source§

impl ByteValued for [i64; 27]

Source§

impl ByteValued for [i64; 28]

Source§

impl ByteValued for [i64; 29]

Source§

impl ByteValued for [i64; 30]

Source§

impl ByteValued for [i64; 31]

Source§

impl ByteValued for [i64; 32]

Source§

impl ByteValued for [i128; 0]

Source§

impl ByteValued for [i128; 1]

Source§

impl ByteValued for [i128; 2]

Source§

impl ByteValued for [i128; 3]

Source§

impl ByteValued for [i128; 4]

Source§

impl ByteValued for [i128; 5]

Source§

impl ByteValued for [i128; 6]

Source§

impl ByteValued for [i128; 7]

Source§

impl ByteValued for [i128; 8]

Source§

impl ByteValued for [i128; 9]

Source§

impl ByteValued for [i128; 10]

Source§

impl ByteValued for [i128; 11]

Source§

impl ByteValued for [i128; 12]

Source§

impl ByteValued for [i128; 13]

Source§

impl ByteValued for [i128; 14]

Source§

impl ByteValued for [i128; 15]

Source§

impl ByteValued for [i128; 16]

Source§

impl ByteValued for [i128; 17]

Source§

impl ByteValued for [i128; 18]

Source§

impl ByteValued for [i128; 19]

Source§

impl ByteValued for [i128; 20]

Source§

impl ByteValued for [i128; 21]

Source§

impl ByteValued for [i128; 22]

Source§

impl ByteValued for [i128; 23]

Source§

impl ByteValued for [i128; 24]

Source§

impl ByteValued for [i128; 25]

Source§

impl ByteValued for [i128; 26]

Source§

impl ByteValued for [i128; 27]

Source§

impl ByteValued for [i128; 28]

Source§

impl ByteValued for [i128; 29]

Source§

impl ByteValued for [i128; 30]

Source§

impl ByteValued for [i128; 31]

Source§

impl ByteValued for [i128; 32]

Source§

impl ByteValued for [isize; 0]

Source§

impl ByteValued for [isize; 1]

Source§

impl ByteValued for [isize; 2]

Source§

impl ByteValued for [isize; 3]

Source§

impl ByteValued for [isize; 4]

Source§

impl ByteValued for [isize; 5]

Source§

impl ByteValued for [isize; 6]

Source§

impl ByteValued for [isize; 7]

Source§

impl ByteValued for [isize; 8]

Source§

impl ByteValued for [isize; 9]

Source§

impl ByteValued for [isize; 10]

Source§

impl ByteValued for [isize; 11]

Source§

impl ByteValued for [isize; 12]

Source§

impl ByteValued for [isize; 13]

Source§

impl ByteValued for [isize; 14]

Source§

impl ByteValued for [isize; 15]

Source§

impl ByteValued for [isize; 16]

Source§

impl ByteValued for [isize; 17]

Source§

impl ByteValued for [isize; 18]

Source§

impl ByteValued for [isize; 19]

Source§

impl ByteValued for [isize; 20]

Source§

impl ByteValued for [isize; 21]

Source§

impl ByteValued for [isize; 22]

Source§

impl ByteValued for [isize; 23]

Source§

impl ByteValued for [isize; 24]

Source§

impl ByteValued for [isize; 25]

Source§

impl ByteValued for [isize; 26]

Source§

impl ByteValued for [isize; 27]

Source§

impl ByteValued for [isize; 28]

Source§

impl ByteValued for [isize; 29]

Source§

impl ByteValued for [isize; 30]

Source§

impl ByteValued for [isize; 31]

Source§

impl ByteValued for [isize; 32]

Source§

impl ByteValued for [u8; 0]

Source§

impl ByteValued for [u8; 1]

Source§

impl ByteValued for [u8; 2]

Source§

impl ByteValued for [u8; 3]

Source§

impl ByteValued for [u8; 4]

Source§

impl ByteValued for [u8; 5]

Source§

impl ByteValued for [u8; 6]

Source§

impl ByteValued for [u8; 7]

Source§

impl ByteValued for [u8; 8]

Source§

impl ByteValued for [u8; 9]

Source§

impl ByteValued for [u8; 10]

Source§

impl ByteValued for [u8; 11]

Source§

impl ByteValued for [u8; 12]

Source§

impl ByteValued for [u8; 13]

Source§

impl ByteValued for [u8; 14]

Source§

impl ByteValued for [u8; 15]

Source§

impl ByteValued for [u8; 16]

Source§

impl ByteValued for [u8; 17]

Source§

impl ByteValued for [u8; 18]

Source§

impl ByteValued for [u8; 19]

Source§

impl ByteValued for [u8; 20]

Source§

impl ByteValued for [u8; 21]

Source§

impl ByteValued for [u8; 22]

Source§

impl ByteValued for [u8; 23]

Source§

impl ByteValued for [u8; 24]

Source§

impl ByteValued for [u8; 25]

Source§

impl ByteValued for [u8; 26]

Source§

impl ByteValued for [u8; 27]

Source§

impl ByteValued for [u8; 28]

Source§

impl ByteValued for [u8; 29]

Source§

impl ByteValued for [u8; 30]

Source§

impl ByteValued for [u8; 31]

Source§

impl ByteValued for [u8; 32]

Source§

impl ByteValued for [u16; 0]

Source§

impl ByteValued for [u16; 1]

Source§

impl ByteValued for [u16; 2]

Source§

impl ByteValued for [u16; 3]

Source§

impl ByteValued for [u16; 4]

Source§

impl ByteValued for [u16; 5]

Source§

impl ByteValued for [u16; 6]

Source§

impl ByteValued for [u16; 7]

Source§

impl ByteValued for [u16; 8]

Source§

impl ByteValued for [u16; 9]

Source§

impl ByteValued for [u16; 10]

Source§

impl ByteValued for [u16; 11]

Source§

impl ByteValued for [u16; 12]

Source§

impl ByteValued for [u16; 13]

Source§

impl ByteValued for [u16; 14]

Source§

impl ByteValued for [u16; 15]

Source§

impl ByteValued for [u16; 16]

Source§

impl ByteValued for [u16; 17]

Source§

impl ByteValued for [u16; 18]

Source§

impl ByteValued for [u16; 19]

Source§

impl ByteValued for [u16; 20]

Source§

impl ByteValued for [u16; 21]

Source§

impl ByteValued for [u16; 22]

Source§

impl ByteValued for [u16; 23]

Source§

impl ByteValued for [u16; 24]

Source§

impl ByteValued for [u16; 25]

Source§

impl ByteValued for [u16; 26]

Source§

impl ByteValued for [u16; 27]

Source§

impl ByteValued for [u16; 28]

Source§

impl ByteValued for [u16; 29]

Source§

impl ByteValued for [u16; 30]

Source§

impl ByteValued for [u16; 31]

Source§

impl ByteValued for [u16; 32]

Source§

impl ByteValued for [u32; 0]

Source§

impl ByteValued for [u32; 1]

Source§

impl ByteValued for [u32; 2]

Source§

impl ByteValued for [u32; 3]

Source§

impl ByteValued for [u32; 4]

Source§

impl ByteValued for [u32; 5]

Source§

impl ByteValued for [u32; 6]

Source§

impl ByteValued for [u32; 7]

Source§

impl ByteValued for [u32; 8]

Source§

impl ByteValued for [u32; 9]

Source§

impl ByteValued for [u32; 10]

Source§

impl ByteValued for [u32; 11]

Source§

impl ByteValued for [u32; 12]

Source§

impl ByteValued for [u32; 13]

Source§

impl ByteValued for [u32; 14]

Source§

impl ByteValued for [u32; 15]

Source§

impl ByteValued for [u32; 16]

Source§

impl ByteValued for [u32; 17]

Source§

impl ByteValued for [u32; 18]

Source§

impl ByteValued for [u32; 19]

Source§

impl ByteValued for [u32; 20]

Source§

impl ByteValued for [u32; 21]

Source§

impl ByteValued for [u32; 22]

Source§

impl ByteValued for [u32; 23]

Source§

impl ByteValued for [u32; 24]

Source§

impl ByteValued for [u32; 25]

Source§

impl ByteValued for [u32; 26]

Source§

impl ByteValued for [u32; 27]

Source§

impl ByteValued for [u32; 28]

Source§

impl ByteValued for [u32; 29]

Source§

impl ByteValued for [u32; 30]

Source§

impl ByteValued for [u32; 31]

Source§

impl ByteValued for [u32; 32]

Source§

impl ByteValued for [u64; 0]

Source§

impl ByteValued for [u64; 1]

Source§

impl ByteValued for [u64; 2]

Source§

impl ByteValued for [u64; 3]

Source§

impl ByteValued for [u64; 4]

Source§

impl ByteValued for [u64; 5]

Source§

impl ByteValued for [u64; 6]

Source§

impl ByteValued for [u64; 7]

Source§

impl ByteValued for [u64; 8]

Source§

impl ByteValued for [u64; 9]

Source§

impl ByteValued for [u64; 10]

Source§

impl ByteValued for [u64; 11]

Source§

impl ByteValued for [u64; 12]

Source§

impl ByteValued for [u64; 13]

Source§

impl ByteValued for [u64; 14]

Source§

impl ByteValued for [u64; 15]

Source§

impl ByteValued for [u64; 16]

Source§

impl ByteValued for [u64; 17]

Source§

impl ByteValued for [u64; 18]

Source§

impl ByteValued for [u64; 19]

Source§

impl ByteValued for [u64; 20]

Source§

impl ByteValued for [u64; 21]

Source§

impl ByteValued for [u64; 22]

Source§

impl ByteValued for [u64; 23]

Source§

impl ByteValued for [u64; 24]

Source§

impl ByteValued for [u64; 25]

Source§

impl ByteValued for [u64; 26]

Source§

impl ByteValued for [u64; 27]

Source§

impl ByteValued for [u64; 28]

Source§

impl ByteValued for [u64; 29]

Source§

impl ByteValued for [u64; 30]

Source§

impl ByteValued for [u64; 31]

Source§

impl ByteValued for [u64; 32]

Source§

impl ByteValued for [u128; 0]

Source§

impl ByteValued for [u128; 1]

Source§

impl ByteValued for [u128; 2]

Source§

impl ByteValued for [u128; 3]

Source§

impl ByteValued for [u128; 4]

Source§

impl ByteValued for [u128; 5]

Source§

impl ByteValued for [u128; 6]

Source§

impl ByteValued for [u128; 7]

Source§

impl ByteValued for [u128; 8]

Source§

impl ByteValued for [u128; 9]

Source§

impl ByteValued for [u128; 10]

Source§

impl ByteValued for [u128; 11]

Source§

impl ByteValued for [u128; 12]

Source§

impl ByteValued for [u128; 13]

Source§

impl ByteValued for [u128; 14]

Source§

impl ByteValued for [u128; 15]

Source§

impl ByteValued for [u128; 16]

Source§

impl ByteValued for [u128; 17]

Source§

impl ByteValued for [u128; 18]

Source§

impl ByteValued for [u128; 19]

Source§

impl ByteValued for [u128; 20]

Source§

impl ByteValued for [u128; 21]

Source§

impl ByteValued for [u128; 22]

Source§

impl ByteValued for [u128; 23]

Source§

impl ByteValued for [u128; 24]

Source§

impl ByteValued for [u128; 25]

Source§

impl ByteValued for [u128; 26]

Source§

impl ByteValued for [u128; 27]

Source§

impl ByteValued for [u128; 28]

Source§

impl ByteValued for [u128; 29]

Source§

impl ByteValued for [u128; 30]

Source§

impl ByteValued for [u128; 31]

Source§

impl ByteValued for [u128; 32]

Source§

impl ByteValued for [usize; 0]

Source§

impl ByteValued for [usize; 1]

Source§

impl ByteValued for [usize; 2]

Source§

impl ByteValued for [usize; 3]

Source§

impl ByteValued for [usize; 4]

Source§

impl ByteValued for [usize; 5]

Source§

impl ByteValued for [usize; 6]

Source§

impl ByteValued for [usize; 7]

Source§

impl ByteValued for [usize; 8]

Source§

impl ByteValued for [usize; 9]

Source§

impl ByteValued for [usize; 10]

Source§

impl ByteValued for [usize; 11]

Source§

impl ByteValued for [usize; 12]

Source§

impl ByteValued for [usize; 13]

Source§

impl ByteValued for [usize; 14]

Source§

impl ByteValued for [usize; 15]

Source§

impl ByteValued for [usize; 16]

Source§

impl ByteValued for [usize; 17]

Source§

impl ByteValued for [usize; 18]

Source§

impl ByteValued for [usize; 19]

Source§

impl ByteValued for [usize; 20]

Source§

impl ByteValued for [usize; 21]

Source§

impl ByteValued for [usize; 22]

Source§

impl ByteValued for [usize; 23]

Source§

impl ByteValued for [usize; 24]

Source§

impl ByteValued for [usize; 25]

Source§

impl ByteValued for [usize; 26]

Source§

impl ByteValued for [usize; 27]

Source§

impl ByteValued for [usize; 28]

Source§

impl ByteValued for [usize; 29]

Source§

impl ByteValued for [usize; 30]

Source§

impl ByteValued for [usize; 31]

Source§

impl ByteValued for [usize; 32]

Implementors§