pub unsafe trait ValueType: Copy {
    // Required method
    fn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>]);
}
Expand description

Trait for a Value type. A Value type is a type that is always valid and may be safely copied.

Safety

To maintain safety, types which implement this trait must be valid for all bit patterns. This means that it cannot contain enums, bool, references, etc.

Concretely a u32 is a Value type because every combination of 32 bits is a valid u32. However a bool is not a Value type because any bit patterns other than 0 and 1 are invalid in Rust and may cause undefined behavior if a bool is constructed from those bytes.

Additionally this trait has a method which zeros out any uninitializes bytes prior to writing them to Wasm memory, which prevents information leaks into the sandbox.

Required Methods§

source

fn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>])

This method is passed a byte slice which contains the byte representation of self. It must zero out any bytes which are uninitialized (e.g. padding bytes).

Implementations on Foreign Types§

source§

impl<const N: usize> ValueType for [f64; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for u32

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for i32

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for u64

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [i16; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [i32; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for u128

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [isize; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for u16

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [u16; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for f64

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for usize

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [i8; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [u8; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [usize; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for i64

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for i8

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for i128

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [i64; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [i128; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for isize

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [u128; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [u32; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [f32; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for bool

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for u8

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [u64; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for i16

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl ValueType for f32

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

source§

impl<const N: usize> ValueType for [bool; N]

source§

fn zero_padding_bytes(&self, _bytes: &mut [MaybeUninit<u8>])

Implementors§