[][src]Trait vm_memory::bytes::ByteValued

pub unsafe trait ByteValued: Copy + Default + Send + Sync {
    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 { ... } }

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

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.

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

Provided methods

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.

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.

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.

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.

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).

Loading content...

Implementations on Foreign Types

impl ByteValued for u8[src]

impl ByteValued for [u8; 0][src]

impl ByteValued for [u8; 1][src]

impl ByteValued for [u8; 2][src]

impl ByteValued for [u8; 3][src]

impl ByteValued for [u8; 4][src]

impl ByteValued for [u8; 5][src]

impl ByteValued for [u8; 6][src]

impl ByteValued for [u8; 7][src]

impl ByteValued for [u8; 8][src]

impl ByteValued for [u8; 9][src]

impl ByteValued for [u8; 10][src]

impl ByteValued for [u8; 11][src]

impl ByteValued for [u8; 12][src]

impl ByteValued for [u8; 13][src]

impl ByteValued for [u8; 14][src]

impl ByteValued for [u8; 15][src]

impl ByteValued for [u8; 16][src]

impl ByteValued for [u8; 17][src]

impl ByteValued for [u8; 18][src]

impl ByteValued for [u8; 19][src]

impl ByteValued for [u8; 20][src]

impl ByteValued for [u8; 21][src]

impl ByteValued for [u8; 22][src]

impl ByteValued for [u8; 23][src]

impl ByteValued for [u8; 24][src]

impl ByteValued for [u8; 25][src]

impl ByteValued for [u8; 26][src]

impl ByteValued for [u8; 27][src]

impl ByteValued for [u8; 28][src]

impl ByteValued for [u8; 29][src]

impl ByteValued for [u8; 30][src]

impl ByteValued for [u8; 31][src]

impl ByteValued for [u8; 32][src]

impl ByteValued for u16[src]

impl ByteValued for [u16; 0][src]

impl ByteValued for [u16; 1][src]

impl ByteValued for [u16; 2][src]

impl ByteValued for [u16; 3][src]

impl ByteValued for [u16; 4][src]

impl ByteValued for [u16; 5][src]

impl ByteValued for [u16; 6][src]

impl ByteValued for [u16; 7][src]

impl ByteValued for [u16; 8][src]

impl ByteValued for [u16; 9][src]

impl ByteValued for [u16; 10][src]

impl ByteValued for [u16; 11][src]

impl ByteValued for [u16; 12][src]

impl ByteValued for [u16; 13][src]

impl ByteValued for [u16; 14][src]

impl ByteValued for [u16; 15][src]

impl ByteValued for [u16; 16][src]

impl ByteValued for [u16; 17][src]

impl ByteValued for [u16; 18][src]

impl ByteValued for [u16; 19][src]

impl ByteValued for [u16; 20][src]

impl ByteValued for [u16; 21][src]

impl ByteValued for [u16; 22][src]

impl ByteValued for [u16; 23][src]

impl ByteValued for [u16; 24][src]

impl ByteValued for [u16; 25][src]

impl ByteValued for [u16; 26][src]

impl ByteValued for [u16; 27][src]

impl ByteValued for [u16; 28][src]

impl ByteValued for [u16; 29][src]

impl ByteValued for [u16; 30][src]

impl ByteValued for [u16; 31][src]

impl ByteValued for [u16; 32][src]

impl ByteValued for u32[src]

impl ByteValued for [u32; 0][src]

impl ByteValued for [u32; 1][src]

impl ByteValued for [u32; 2][src]

impl ByteValued for [u32; 3][src]

impl ByteValued for [u32; 4][src]

impl ByteValued for [u32; 5][src]

impl ByteValued for [u32; 6][src]

impl ByteValued for [u32; 7][src]

impl ByteValued for [u32; 8][src]

impl ByteValued for [u32; 9][src]

impl ByteValued for [u32; 10][src]

impl ByteValued for [u32; 11][src]

impl ByteValued for [u32; 12][src]

impl ByteValued for [u32; 13][src]

impl ByteValued for [u32; 14][src]

impl ByteValued for [u32; 15][src]

impl ByteValued for [u32; 16][src]

impl ByteValued for [u32; 17][src]

impl ByteValued for [u32; 18][src]

impl ByteValued for [u32; 19][src]

impl ByteValued for [u32; 20][src]

impl ByteValued for [u32; 21][src]

impl ByteValued for [u32; 22][src]

impl ByteValued for [u32; 23][src]

impl ByteValued for [u32; 24][src]

impl ByteValued for [u32; 25][src]

impl ByteValued for [u32; 26][src]

impl ByteValued for [u32; 27][src]

impl ByteValued for [u32; 28][src]

impl ByteValued for [u32; 29][src]

impl ByteValued for [u32; 30][src]

impl ByteValued for [u32; 31][src]

impl ByteValued for [u32; 32][src]

impl ByteValued for u64[src]

impl ByteValued for [u64; 0][src]

impl ByteValued for [u64; 1][src]

impl ByteValued for [u64; 2][src]

impl ByteValued for [u64; 3][src]

impl ByteValued for [u64; 4][src]

impl ByteValued for [u64; 5][src]

impl ByteValued for [u64; 6][src]

impl ByteValued for [u64; 7][src]

impl ByteValued for [u64; 8][src]

impl ByteValued for [u64; 9][src]

impl ByteValued for [u64; 10][src]

impl ByteValued for [u64; 11][src]

impl ByteValued for [u64; 12][src]

impl ByteValued for [u64; 13][src]

impl ByteValued for [u64; 14][src]

impl ByteValued for [u64; 15][src]

impl ByteValued for [u64; 16][src]

impl ByteValued for [u64; 17][src]

impl ByteValued for [u64; 18][src]

impl ByteValued for [u64; 19][src]

impl ByteValued for [u64; 20][src]

impl ByteValued for [u64; 21][src]

impl ByteValued for [u64; 22][src]

impl ByteValued for [u64; 23][src]

impl ByteValued for [u64; 24][src]

impl ByteValued for [u64; 25][src]

impl ByteValued for [u64; 26][src]

impl ByteValued for [u64; 27][src]

impl ByteValued for [u64; 28][src]

impl ByteValued for [u64; 29][src]

impl ByteValued for [u64; 30][src]

impl ByteValued for [u64; 31][src]

impl ByteValued for [u64; 32][src]

impl ByteValued for usize[src]

impl ByteValued for [usize; 0][src]

impl ByteValued for [usize; 1][src]

impl ByteValued for [usize; 2][src]

impl ByteValued for [usize; 3][src]

impl ByteValued for [usize; 4][src]

impl ByteValued for [usize; 5][src]

impl ByteValued for [usize; 6][src]

impl ByteValued for [usize; 7][src]

impl ByteValued for [usize; 8][src]

impl ByteValued for [usize; 9][src]

impl ByteValued for [usize; 10][src]

impl ByteValued for [usize; 11][src]

impl ByteValued for [usize; 12][src]

impl ByteValued for [usize; 13][src]

impl ByteValued for [usize; 14][src]

impl ByteValued for [usize; 15][src]

impl ByteValued for [usize; 16][src]

impl ByteValued for [usize; 17][src]

impl ByteValued for [usize; 18][src]

impl ByteValued for [usize; 19][src]

impl ByteValued for [usize; 20][src]

impl ByteValued for [usize; 21][src]

impl ByteValued for [usize; 22][src]

impl ByteValued for [usize; 23][src]

impl ByteValued for [usize; 24][src]

impl ByteValued for [usize; 25][src]

impl ByteValued for [usize; 26][src]

impl ByteValued for [usize; 27][src]

impl ByteValued for [usize; 28][src]

impl ByteValued for [usize; 29][src]

impl ByteValued for [usize; 30][src]

impl ByteValued for [usize; 31][src]

impl ByteValued for [usize; 32][src]

impl ByteValued for i8[src]

impl ByteValued for [i8; 0][src]

impl ByteValued for [i8; 1][src]

impl ByteValued for [i8; 2][src]

impl ByteValued for [i8; 3][src]

impl ByteValued for [i8; 4][src]

impl ByteValued for [i8; 5][src]

impl ByteValued for [i8; 6][src]

impl ByteValued for [i8; 7][src]

impl ByteValued for [i8; 8][src]

impl ByteValued for [i8; 9][src]

impl ByteValued for [i8; 10][src]

impl ByteValued for [i8; 11][src]

impl ByteValued for [i8; 12][src]

impl ByteValued for [i8; 13][src]

impl ByteValued for [i8; 14][src]

impl ByteValued for [i8; 15][src]

impl ByteValued for [i8; 16][src]

impl ByteValued for [i8; 17][src]

impl ByteValued for [i8; 18][src]

impl ByteValued for [i8; 19][src]

impl ByteValued for [i8; 20][src]

impl ByteValued for [i8; 21][src]

impl ByteValued for [i8; 22][src]

impl ByteValued for [i8; 23][src]

impl ByteValued for [i8; 24][src]

impl ByteValued for [i8; 25][src]

impl ByteValued for [i8; 26][src]

impl ByteValued for [i8; 27][src]

impl ByteValued for [i8; 28][src]

impl ByteValued for [i8; 29][src]

impl ByteValued for [i8; 30][src]

impl ByteValued for [i8; 31][src]

impl ByteValued for [i8; 32][src]

impl ByteValued for i16[src]

impl ByteValued for [i16; 0][src]

impl ByteValued for [i16; 1][src]

impl ByteValued for [i16; 2][src]

impl ByteValued for [i16; 3][src]

impl ByteValued for [i16; 4][src]

impl ByteValued for [i16; 5][src]

impl ByteValued for [i16; 6][src]

impl ByteValued for [i16; 7][src]

impl ByteValued for [i16; 8][src]

impl ByteValued for [i16; 9][src]

impl ByteValued for [i16; 10][src]

impl ByteValued for [i16; 11][src]

impl ByteValued for [i16; 12][src]

impl ByteValued for [i16; 13][src]

impl ByteValued for [i16; 14][src]

impl ByteValued for [i16; 15][src]

impl ByteValued for [i16; 16][src]

impl ByteValued for [i16; 17][src]

impl ByteValued for [i16; 18][src]

impl ByteValued for [i16; 19][src]

impl ByteValued for [i16; 20][src]

impl ByteValued for [i16; 21][src]

impl ByteValued for [i16; 22][src]

impl ByteValued for [i16; 23][src]

impl ByteValued for [i16; 24][src]

impl ByteValued for [i16; 25][src]

impl ByteValued for [i16; 26][src]

impl ByteValued for [i16; 27][src]

impl ByteValued for [i16; 28][src]

impl ByteValued for [i16; 29][src]

impl ByteValued for [i16; 30][src]

impl ByteValued for [i16; 31][src]

impl ByteValued for [i16; 32][src]

impl ByteValued for i32[src]

impl ByteValued for [i32; 0][src]

impl ByteValued for [i32; 1][src]

impl ByteValued for [i32; 2][src]

impl ByteValued for [i32; 3][src]

impl ByteValued for [i32; 4][src]

impl ByteValued for [i32; 5][src]

impl ByteValued for [i32; 6][src]

impl ByteValued for [i32; 7][src]

impl ByteValued for [i32; 8][src]

impl ByteValued for [i32; 9][src]

impl ByteValued for [i32; 10][src]

impl ByteValued for [i32; 11][src]

impl ByteValued for [i32; 12][src]

impl ByteValued for [i32; 13][src]

impl ByteValued for [i32; 14][src]

impl ByteValued for [i32; 15][src]

impl ByteValued for [i32; 16][src]

impl ByteValued for [i32; 17][src]

impl ByteValued for [i32; 18][src]

impl ByteValued for [i32; 19][src]

impl ByteValued for [i32; 20][src]

impl ByteValued for [i32; 21][src]

impl ByteValued for [i32; 22][src]

impl ByteValued for [i32; 23][src]

impl ByteValued for [i32; 24][src]

impl ByteValued for [i32; 25][src]

impl ByteValued for [i32; 26][src]

impl ByteValued for [i32; 27][src]

impl ByteValued for [i32; 28][src]

impl ByteValued for [i32; 29][src]

impl ByteValued for [i32; 30][src]

impl ByteValued for [i32; 31][src]

impl ByteValued for [i32; 32][src]

impl ByteValued for i64[src]

impl ByteValued for [i64; 0][src]

impl ByteValued for [i64; 1][src]

impl ByteValued for [i64; 2][src]

impl ByteValued for [i64; 3][src]

impl ByteValued for [i64; 4][src]

impl ByteValued for [i64; 5][src]

impl ByteValued for [i64; 6][src]

impl ByteValued for [i64; 7][src]

impl ByteValued for [i64; 8][src]

impl ByteValued for [i64; 9][src]

impl ByteValued for [i64; 10][src]

impl ByteValued for [i64; 11][src]

impl ByteValued for [i64; 12][src]

impl ByteValued for [i64; 13][src]

impl ByteValued for [i64; 14][src]

impl ByteValued for [i64; 15][src]

impl ByteValued for [i64; 16][src]

impl ByteValued for [i64; 17][src]

impl ByteValued for [i64; 18][src]

impl ByteValued for [i64; 19][src]

impl ByteValued for [i64; 20][src]

impl ByteValued for [i64; 21][src]

impl ByteValued for [i64; 22][src]

impl ByteValued for [i64; 23][src]

impl ByteValued for [i64; 24][src]

impl ByteValued for [i64; 25][src]

impl ByteValued for [i64; 26][src]

impl ByteValued for [i64; 27][src]

impl ByteValued for [i64; 28][src]

impl ByteValued for [i64; 29][src]

impl ByteValued for [i64; 30][src]

impl ByteValued for [i64; 31][src]

impl ByteValued for [i64; 32][src]

impl ByteValued for isize[src]

impl ByteValued for [isize; 0][src]

impl ByteValued for [isize; 1][src]

impl ByteValued for [isize; 2][src]

impl ByteValued for [isize; 3][src]

impl ByteValued for [isize; 4][src]

impl ByteValued for [isize; 5][src]

impl ByteValued for [isize; 6][src]

impl ByteValued for [isize; 7][src]

impl ByteValued for [isize; 8][src]

impl ByteValued for [isize; 9][src]

impl ByteValued for [isize; 10][src]

impl ByteValued for [isize; 11][src]

impl ByteValued for [isize; 12][src]

impl ByteValued for [isize; 13][src]

impl ByteValued for [isize; 14][src]

impl ByteValued for [isize; 15][src]

impl ByteValued for [isize; 16][src]

impl ByteValued for [isize; 17][src]

impl ByteValued for [isize; 18][src]

impl ByteValued for [isize; 19][src]

impl ByteValued for [isize; 20][src]

impl ByteValued for [isize; 21][src]

impl ByteValued for [isize; 22][src]

impl ByteValued for [isize; 23][src]

impl ByteValued for [isize; 24][src]

impl ByteValued for [isize; 25][src]

impl ByteValued for [isize; 26][src]

impl ByteValued for [isize; 27][src]

impl ByteValued for [isize; 28][src]

impl ByteValued for [isize; 29][src]

impl ByteValued for [isize; 30][src]

impl ByteValued for [isize; 31][src]

impl ByteValued for [isize; 32][src]

Loading content...

Implementors

impl ByteValued for Be16[src]

impl ByteValued for Be32[src]

impl ByteValued for Be64[src]

impl ByteValued for BeSize[src]

impl ByteValued for Le16[src]

impl ByteValued for Le32[src]

impl ByteValued for Le64[src]

impl ByteValued for LeSize[src]

Loading content...