Struct PrimaryRc
pub struct PrimaryRc<T> { /* private fields */ }
Expand description
A primary reference.
Note that only one Primary
may be associated with data. This is
enforced by not implementing Clone
.
For now, this reference is no different than a Strong
but later changes
will enable blocking the destruction of a primary reference until all
strongly held references are dropped.
Implementations§
§impl<T> Primary<T>
impl<T> Primary<T>
pub fn new_cyclic(data_fn: impl FnOnce(Weak<T>) -> T) -> Primary<T>
pub fn new_cyclic(data_fn: impl FnOnce(Weak<T>) -> T) -> Primary<T>
Constructs a new Primary<T>
while giving you a WeakT
which holds a weak pointer
to itself.
Like for [Arc::new_cyclic
], the Weak
reference provided to data_fn
cannot be upgraded until the Primary
is constructed.
pub fn clone_strong(_: &Primary<T>) -> Strong<T>
pub fn clone_strong(_: &Primary<T>) -> Strong<T>
Clones a strongly-held reference.
pub fn downgrade(_: &Primary<T>) -> Weak<T>
pub fn downgrade(_: &Primary<T>) -> Weak<T>
Returns a weak reference pointing to the same underlying data.
pub fn ptr_eq(_: &Primary<T>, _: &Strong<T>) -> bool
pub fn ptr_eq(_: &Primary<T>, _: &Strong<T>) -> bool
Returns true if the two pointers point to the same allocation.
pub fn debug_id(&self) -> impl Debug
pub fn debug_id(&self) -> impl Debug
Returns core::fmt::Debug
implementation that is stable and unique
for the data held behind this Primary
.
pub fn unwrap_with_notifier<N>(this: Primary<T>, notifier: N)where
N: Notifier<T> + 'static,
pub fn unwrap_with_notifier<N>(this: Primary<T>, notifier: N)where
N: Notifier<T> + 'static,
pub fn unwrap_or_notify_with<N, O, F>(
this: Primary<T>,
new_notifier: F,
) -> Result<T, O>
pub fn unwrap_or_notify_with<N, O, F>( this: Primary<T>, new_notifier: F, ) -> Result<T, O>
Marks this Primary
for destruction and returns Ok
if this was the
last strong reference standing for it. Otherwise new_notifier
is
called to create a new notifier to observe deferred destruction.
Like Primary::unwrap_with_notifier
, Weak
references can no
longer be upgraded after calling unwrap_or_notify_with
.
pub fn debug_references(this: &Primary<T>) -> DebugReferences<T>
pub fn debug_references(this: &Primary<T>) -> DebugReferences<T>
Creates a DebugReferences
instance.