Struct kitsune_p2p_types::tx2::tx2_utils::Share
source · pub struct Share<T: 'static + Send>(_);
Expand description
Synchronized droppable share-lock around internal state date.
Implementations§
sourcepub fn new_closed() -> Self
pub fn new_closed() -> Self
Create a new closed share lock.
Execute code with immutable access to the internal state.
sourcepub fn try_unwrap(self) -> Result<Option<T>, Self>
pub fn try_unwrap(self) -> Result<Option<T>, Self>
Attempt to unwrap the inner value, assuming this is the only instance.
Execute code with mut access to the internal state.
The second param, if set to true, will drop the shared state,
any further access will Err(KitsuneError::Closed)
.
E.g. share.share_mut(|_state, close| *close = true).unwrap();
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§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§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§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>
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
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
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.