[−][src]Struct restor::MutexStorage
The storage with interior mutability based on Mutex
es.
This allows the data that is put in to only need to be T: Send
,
because this only allows one thread to read or write to the data.
Because of the above, this also only has the mutable versions
of functions implemented, as though a MutexGuard
can only
contain a mutable reference due to the nature of the mutex.
Please note!
The documentation for the functions implemented for this type are found in
BlackBox
's documentation under the same name.
This can be used in any context a DynamicStorage
can be used
with the exception of the uses of non-mut functions
Please refer to the make_storage
macro to create these with a shorthand.
Implementation note
A wrapper for a Mutex
-safe BlackBox
.
This only allows for allocation of T: Send + Any
units,
making it safe to impl Sync for MutexStorage
.
This is done by Deref
ing into the appropriate BlackBox
, but not
DerefMut
ing into it. This prevents the user from using the
allocate_for
function from BlackBox
and instead forces them to
use MutexStorage
's allocate_for
function, which satisfies the
above requirements.
This fits into the same context as any storage type provided by
restor
.
Methods
impl MutexStorage
[src]
pub fn allocate_for<T: Send + Any>(&mut self)
[src]
Adds a storage unit for the given type. This will not add another unit in the case that it already exists.
pub fn has_unit<T: Send + Any>(&self) -> bool
[src]
Please refer to the documentation for this function at BlackBox::has_unit
.
pub fn insert<T: Send + Any>(&self, data: T) -> Result<(), (T, ErrorDesc)>
[src]
Please refer to the documentation for this function at BlackBox::insert
.
pub fn insert_many<T: Send + Any>(
&self,
data: Vec<T>
) -> Result<(), (Vec<T>, ErrorDesc)>
[src]
&self,
data: Vec<T>
) -> Result<(), (Vec<T>, ErrorDesc)>
Please refer to the documentation for this function at BlackBox::insert_many
.
pub fn run_for_mut<T: Send + Any, D: 'static + Any, F: FnMut(&mut Vec<T>) -> D>(
&self,
f: F
) -> Result<D, ErrorDesc>
[src]
&self,
f: F
) -> Result<D, ErrorDesc>
Please refer to the documentation for this function at BlackBox::run_for_mut
.
pub fn get<'a, T: FetchMultiple<'a, dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync>>(
&'a self
) -> Result<T::Output, ErrorDesc> where
<T as FetchMultiple<'a, dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync>>::Actual: Send + Any,
[src]
&'a self
) -> Result<T::Output, ErrorDesc> where
<T as FetchMultiple<'a, dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync>>::Actual: Send + Any,
Please refer to the documentation for this function at BlackBox::get
.
impl MutexStorage
[src]
pub fn waiting_get<'a, T: FetchMultiple<'a, dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync>>(
&'a self
) -> Result<T::Output, ErrorDesc> where
<dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync as Unit<'a>>::Borrowed: Waitable,
<dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync as Unit<'a>>::MutBorrowed: Waitable,
<T as FetchMultiple<'a, dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync>>::Actual: Send + Any,
[src]
&'a self
) -> Result<T::Output, ErrorDesc> where
<dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync as Unit<'a>>::Borrowed: Waitable,
<dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync as Unit<'a>>::MutBorrowed: Waitable,
<T as FetchMultiple<'a, dyn Unit<'u, Borrowed = MappedMutexGuard<'u, dyn Any>, MutBorrowed = MappedMutexGuard<'u, dyn Any>> + Send + Sync>>::Actual: Send + Any,
Please refer to the documentation for this function at BlackBox::waiting_get
.
impl MutexStorage
[src]
Trait Implementations
impl Default for MutexStorage
[src]
Auto Trait Implementations
impl Send for MutexStorage
impl Sync for MutexStorage
Blanket Implementations
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,