[−][src]Struct caring::Shared
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]
impl<T> Drop for Shared<T>
[src]
impl<T> IntoRawFd for Shared<T>
[src]
fn into_raw_fd(self) -> RawFd
[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,
T: RefUnwindSafe,
impl<T> Unpin for Shared<T>
impl<T> UnwindSafe for Shared<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,