Struct holochain::prelude::dependencies::kitsune_p2p_types::dependencies::ghost_actor::dependencies::mockall::Fragile
pub struct Fragile<T> { /* private fields */ }
Expand description
A Fragile<T>
wraps a non sendable T
to be safely send to other threads.
Once the value has been wrapped it can be sent to other threads but access to the value on those threads will fail.
If the value needs destruction and the fragile wrapper is on another thread
the destructor will panic. Alternatively you can use
Sticky
which is not going to panic but might temporarily
leak the value.
Implementations§
§impl<T> Fragile<T>
impl<T> Fragile<T>
pub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Returns true
if the access is valid.
This will be false
if the value was sent to another thread.
pub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Consumes the Fragile
, returning the wrapped value.
Panics
Panics if called from a different thread than the one where the original value was created.
pub fn try_into_inner(self) -> Result<T, Fragile<T>>
pub fn try_into_inner(self) -> Result<T, Fragile<T>>
Consumes the Fragile
, returning the wrapped value if successful.
The wrapped value is returned if this is called from the same thread
as the one where the original value was created, otherwise the
Fragile
is returned as Err(self)
.
pub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Mutably borrows the wrapped value.
Panics
Panics if the calling thread is not the one that wrapped the value.
For a non-panicking variant, use try_get_mut
.
pub fn try_get(&self) -> Result<&T, InvalidThreadAccess>
pub fn try_get(&self) -> Result<&T, InvalidThreadAccess>
Tries to immutably borrow the wrapped value.
Returns None
if the calling thread is not the one that wrapped the value.
pub fn try_get_mut(&mut self) -> Result<&mut T, InvalidThreadAccess>
pub fn try_get_mut(&mut self) -> Result<&mut T, InvalidThreadAccess>
Tries to mutably borrow the wrapped value.
Returns None
if the calling thread is not the one that wrapped the value.
Trait Implementations§
§impl<T> Ord for Fragile<T>where
T: Ord,
impl<T> Ord for Fragile<T>where
T: Ord,
§impl<T> PartialEq<Fragile<T>> for Fragile<T>where
T: PartialEq<T>,
impl<T> PartialEq<Fragile<T>> for Fragile<T>where
T: PartialEq<T>,
§impl<T> PartialOrd<Fragile<T>> for Fragile<T>where
T: PartialOrd<T>,
impl<T> PartialOrd<Fragile<T>> for Fragile<T>where
T: PartialOrd<T>,
impl<T> Eq for Fragile<T>where
T: Eq,
impl<T> Send for Fragile<T>
impl<T> Sync for Fragile<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Fragile<T>where
T: RefUnwindSafe,
impl<T> Unpin for Fragile<T>where
T: Unpin,
impl<T> UnwindSafe for Fragile<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> 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> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.