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<'_> { ... }
}
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.

§Safety

Unlike most VolatileMemory implementation, this method requires an exclusive reference to self; this trivially fulfills VolatileSlice::new’s requirement that all accesses to self use volatile accesses (because there can be no other accesses).

Object Safety§

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§