pub enum SharedResource<T: Serialize + DeserializeOwned> {
Unix(UnixSharedResource<T>),
}
Variants§
Unix(UnixSharedResource<T>)
Implementations§
pub fn new(name: &str, initial_value: T) -> Result<SharedResource<T>, Error>
Sourcepub fn access<F: Fn(&T) -> R, R>(&self, accessor: F) -> Result<R, Error>
pub fn access<F: Fn(&T) -> R, R>(&self, accessor: F) -> Result<R, Error>
Access an immutable reference to the shared resource using a clojure. The clojure can return a value based on the reference to the resource.
§Arguments
accessor
: A clojure that accepts a value of type&T
and returns a value of generic typeR
§Returns
On success, returns the value of generic type R
. On failure, returns an Error
.
Sourcepub fn access_mut<F: Fn(&mut T) -> D, D>(&self, accessor: F) -> Result<D, Error>
pub fn access_mut<F: Fn(&mut T) -> D, D>(&self, accessor: F) -> Result<D, Error>
Access a mutable reference to the shared resource using a clojure. The clojure can return a value based on the reference to the resource.
§Arguments
accessor
: A clojure that accepts a value of type&mut T
and returns a value of generic typeR
§Returns
On success, returns the value of generic type R
. On failure, returns an Error
.
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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