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§
sourcefn zero_padding_bytes(&self, bytes: &mut [MaybeUninit<u8>])
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).
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.