[][src]Trait shared_data::SharedMemCast

pub unsafe trait SharedMemCast { }

Read WARNING before use

Trait used to indicate that a type can be cast over the shared memory.

For now, shared_memory implements the trait on almost all primitive types.

WARNING

Only implement this trait if you understand the implications of mapping Rust types to shared memory. When doing so, you should be mindful of :

  • Does my type have any pointers in its internal representation ?
    • This is important because pointers in your type need to also point to the shared memory for it to be usable by other processes
  • Can my type resize its contents ?
    • If so, the type probably cannot be safely used over shared memory because your type might call alloc/realloc/free on shared memory addresses
  • Does my type allow for initialisation after instantiation ?
    • A [R|W]lock to the shared memory returns a reference to your type. That means that any use of that reference assumes that the type was properly initialized.

An example of a type that shouldnt be cast to the shared memory would be Vec. Vec internaly contains a pointer to a slice containing its data and some other metadata. This means that to cast a Vec to the shared memory, the memory has to already be initialized with valid pointers and metadata. Granted we could initialize those fields manually, the use of the vector might then trigger a free/realloc on our shared memory.

Implementations on Foreign Types

impl SharedMemCast for bool[src]

impl SharedMemCast for str[src]

impl<T> SharedMemCast for AtomicPtr<T>[src]

impl SharedMemCast for usize[src]

impl SharedMemCast for u64[src]

impl SharedMemCast for u32[src]

impl SharedMemCast for u16[src]

impl SharedMemCast for u8[src]

impl SharedMemCast for AtomicUsize[src]

impl SharedMemCast for i16[src]

impl SharedMemCast for i32[src]

impl SharedMemCast for i64[src]

impl SharedMemCast for f32[src]

impl SharedMemCast for i8[src]

impl SharedMemCast for isize[src]

impl SharedMemCast for char[src]

impl SharedMemCast for AtomicBool[src]

impl SharedMemCast for f64[src]

impl SharedMemCast for AtomicIsize[src]

Loading content...

Implementors

impl SharedMemCast for SharedAddressRange[src]

impl<T: SharedMemCast> SharedMemCast for SharedBox<T>[src]

impl<T: SharedMemCast> SharedMemCast for SharedOption<T>[src]

impl<T: SharedMemCast> SharedMemCast for SharedRc<T>[src]

impl<T: SharedMemCast> SharedMemCast for SharedReceiver<T>[src]

impl<T: SharedMemCast> SharedMemCast for SharedSender<T>[src]

impl<T: SharedMemCast> SharedMemCast for SharedVec<T>[src]

impl<T: SharedMemCast> SharedMemCast for Volatile<T>[src]

Loading content...