Trait vasi::VirtualAddressSpaceIndependent

source ·
pub unsafe trait VirtualAddressSpaceIndependent {
    const IGNORE: () = ();
}
Expand description

A type implementing this trait guarantees that accessing instances of that type outside of their original virtual address space does not violate Rust’s safety requirements.

This is mostly equivalent to them being self-contained: not referring to memory outside of the range [&self, &self + std::mem::sizeof<T>()]. However, they may reference memory outside of that range if they somehow ensure that they only do so from inside the virtual address space where it is valid to do so.

Types implementing this trait can definitely not contain references. If they contain pointers, the type is responsible for ensuring those pointers aren’t dereferenced outside a virtual address space where they are valid.

Relative pointers, e.g. as implemented in rkyv, are acceptable as long as they point within the boundaries of the enclosing type.

The type must also be FFI-safe; e.g. have a stable layout (e.g. [repr(C)]), to help ensure that different processes accessing data of a given type actually agree on its layout. Note though that is necessary, but not sufficient, to ensure they agree on the layout; e.g. things can still go wrong if processes use different versions of the type. (TODO: maybe split this property into a separate trait).

§Safety

The type must actually be self-contained, as above.

Provided Associated Constants§

source

const IGNORE: () = ()

Used by the derive macro to validate that fields are Vasi.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl VirtualAddressSpaceIndependent for bool

source§

impl VirtualAddressSpaceIndependent for i8

source§

impl VirtualAddressSpaceIndependent for i16

source§

impl VirtualAddressSpaceIndependent for i32

source§

impl VirtualAddressSpaceIndependent for i64

source§

impl VirtualAddressSpaceIndependent for isize

source§

impl VirtualAddressSpaceIndependent for u8

source§

impl VirtualAddressSpaceIndependent for u16

source§

impl VirtualAddressSpaceIndependent for u32

source§

impl VirtualAddressSpaceIndependent for u64

source§

impl VirtualAddressSpaceIndependent for ()

source§

impl VirtualAddressSpaceIndependent for usize

source§

impl VirtualAddressSpaceIndependent for AtomicBool

source§

impl VirtualAddressSpaceIndependent for AtomicI8

source§

impl VirtualAddressSpaceIndependent for AtomicI16

source§

impl VirtualAddressSpaceIndependent for AtomicI32

source§

impl VirtualAddressSpaceIndependent for AtomicI64

source§

impl VirtualAddressSpaceIndependent for AtomicU8

source§

impl VirtualAddressSpaceIndependent for AtomicU16

source§

impl VirtualAddressSpaceIndependent for AtomicU32

source§

impl VirtualAddressSpaceIndependent for AtomicU64

source§

impl<T> VirtualAddressSpaceIndependent for Cell<T>

source§

impl<T> VirtualAddressSpaceIndependent for UnsafeCell<T>

source§

impl<T> VirtualAddressSpaceIndependent for PhantomData<T>

source§

impl<T> VirtualAddressSpaceIndependent for ManuallyDrop<T>

source§

impl<T> VirtualAddressSpaceIndependent for MaybeUninit<T>

source§

impl<T, const N: usize> VirtualAddressSpaceIndependent for [T; N]

Implementors§