[][src]Struct caring::Shared

pub struct Shared<T> { /* fields omitted */ }

A wrapper for data that can be shared across processes.

The data is owned, but the element of type T will not be dropped when the Shared<T> is dropped. Note that an element that has a meaningful Drop is likely not ProcSync anyway.

Methods

impl<T> Shared<T>[src]

pub fn new(val: T) -> Result<Shared<T>, Error>[src]

Creates and initializes a Shared<T> to value val.

impl Shared<c_void>[src]

pub fn new_sized(size: usize) -> Result<Shared<c_void>, Error>[src]

Creates a Shared<c_void> that points to a memory region of size size, aligned to page boundary.

Proper handling of the returned value is left up to the user.

impl<T> Shared<T>[src]

pub fn try_clone(data: &Shared<T>) -> Result<Shared<T>, Error>[src]

Attempts to clone data.

This will remap data at another location in memory, in addition to keeping data alive.

pub fn as_mut_ptr(data: &Shared<T>) -> *mut T[src]

Returns a mutable pointer to the data contained by data.

Note that using this pointer needs the caller to handle synchronization themselves.

impl<T: ProcSync> Shared<T>[src]

pub unsafe fn from_raw_fd(fd: RawFd) -> Result<Shared<T>, Error>[src]

Creates a Shared<T> from pre-existing fd.

Unsafety

This assumes that fd is a file descriptor that has been created by another instance of Shared<T>, and that it will never be used by anything else than Shared<T>. Note that not respecting this will at best do as bad as std::mem::transmute, and at worst end in tears.

This also assumes that fd is not shared with another Shared<T>, as the output of as_raw_fd() is only a borrow. Do not forget to call dup before passing the file descriptor to from_raw_fd if you are not using into_raw_fd and have not passed the RawFd over a socket.

Trait Implementations

impl<T> AsRawFd for Shared<T>[src]

impl<T> Deref for Shared<T>[src]

type Target = T

The resulting type after dereferencing.

impl<T> Drop for Shared<T>[src]

impl<T> IntoRawFd for Shared<T>[src]

impl<T: Sync> Send for Shared<T>[src]

impl<T: Sync> Sync for Shared<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Shared<T> where
    T: RefUnwindSafe

impl<T> Unpin for Shared<T>

impl<T> UnwindSafe for Shared<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.