Trait sharify::ShmemBacked[][src]

pub unsafe trait ShmemBacked {
    type NewArg: ?Sized;
    type MetaData: Serialize + DeserializeOwned + Clone;
    fn required_memory_arg(arg: &Self::NewArg) -> usize;
fn required_memory_src(src: &Self) -> usize;
fn new(data: &mut [u8], arg: &Self::NewArg) -> Self::MetaData;
fn new_from_src(data: &mut [u8], src: &Self) -> Self::MetaData; }

Implemented for types which can be wrapped in a Shared or SharedMut for cheap sharing across processes.

This trait is closely connected to the ShmemView and ShmemViewMut traits. See the crate-level documentation for how to implement this trait on custom types.

Safety

This trait is unsafe because care must be taken to return the correct memory size and metadata. The ShmemView/ShmemViewMut traits rely on valid metadata to create view types from raw memory, usually using unsafe operations. Incorrect metadata can produce invalid view types.

Associated Types

type NewArg: ?Sized[src]

The type of user-defined arguments passed to Self::required_memory_arg and Self::new. The new function on the Shared/SharedMut wrappers accepts an argument of this type to construct a shared memory-backed version of Self.

type MetaData: Serialize + DeserializeOwned + Clone[src]

The information required to construct ShmemView::View/ShmemViewMut::View types from raw memory.

Loading content...

Required methods

fn required_memory_arg(arg: &Self::NewArg) -> usize[src]

Returns the memory size in bytes required by a shared memory-backed version of Self created with the user-defined constructor argument arg.

fn required_memory_src(src: &Self) -> usize[src]

Returns the required shared memory size in bytes to hold a copy of src.

fn new(data: &mut [u8], arg: &Self::NewArg) -> Self::MetaData[src]

Fills the shared memory at data with bytes according to the user-defined constructor argument arg and returns the metadata required to create a ShmemView::View/ShmemViewMut::View from data.

fn new_from_src(data: &mut [u8], src: &Self) -> Self::MetaData[src]

Fills the shared memory at data with a copy of src and returns the metadata required to create a ShmemView::View/ShmemViewMut::View from data.

Loading content...

Implementations on Foreign Types

impl ShmemBacked for str[src]

type NewArg = str

type MetaData = usize

fn new(data: &mut [u8], src: &Self::NewArg) -> Self::MetaData[src]

Creates a string slice at data with the contents of src.

fn new_from_src(data: &mut [u8], src: &Self) -> Self::MetaData[src]

Creates a string slice at data with the contents of src.

impl<T> ShmemBacked for [T] where
    T: Copy
[src]

type NewArg = (T, usize)

type MetaData = usize

fn new(data: &mut [u8], (init, len): &Self::NewArg) -> Self::MetaData[src]

Creates a slice at data of length len filled with init.

fn new_from_src(data: &mut [u8], src: &Self) -> Self::MetaData[src]

Creates a slice at data with the contents of src.

impl<'a, T, D> ShmemBacked for Array<T, D> where
    T: Copy,
    D: Dimension + Serialize + DeserializeOwned
[src]

type NewArg = (T, D)

type MetaData = (Vec<usize>, Vec<isize>)

Loading content...

Implementors

Loading content...