pub unsafe trait ValueType: Copy {
    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§

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§

Implementors§