pub struct Shared<T> { /* private fields */ }Expand description
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.
Implementations§
Sourcepub fn try_clone(data: &Shared<T>) -> Result<Shared<T>, Error>
pub fn try_clone(data: &Shared<T>) -> Result<Shared<T>, Error>
Attempts to clone data.
This will remap data at another location in memory, in addition to keeping data alive.
Sourcepub fn as_mut_ptr(data: &Shared<T>) -> *mut T
pub fn as_mut_ptr(data: &Shared<T>) -> *mut T
Returns a mutable pointer to the data contained by data.
Note that using this pointer needs the caller to handle synchronization themselves.
Sourcepub unsafe fn from_raw_fd(fd: RawFd) -> Result<Shared<T>, Error>
pub unsafe fn from_raw_fd(fd: RawFd) -> Result<Shared<T>, Error>
Creates a Shared<T> from pre-existing fd.
§Safety
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§
Source§fn into_raw_fd(self) -> RawFd
fn into_raw_fd(self) -> RawFd
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more