pub struct Primary<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§
Source§impl<T> Primary<T>
impl<T> Primary<T>
Sourcepub 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.
Sourcepub fn clone_strong(_: &Self) -> Strong<T>
pub fn clone_strong(_: &Self) -> Strong<T>
Clones a strongly-held reference.
Sourcepub fn downgrade(_: &Self) -> Weak<T>
pub fn downgrade(_: &Self) -> Weak<T>
Returns a weak reference pointing to the same underlying data.
Sourcepub fn ptr_eq(_: &Self, _: &Strong<T>) -> bool
pub fn ptr_eq(_: &Self, _: &Strong<T>) -> bool
Returns true if the two pointers point to the same allocation.
Sourcepub fn unwrap_with_notifier<N: Notifier<T> + 'static>(this: Self, notifier: N)
pub fn unwrap_with_notifier<N: Notifier<T> + 'static>(this: Self, notifier: N)
Sourcepub fn unwrap_or_notify_with<N: Notifier<T> + 'static, O, F: FnOnce() -> (N, O)>(
this: Self,
new_notifier: F,
) -> Result<T, O>
pub fn unwrap_or_notify_with<N: Notifier<T> + 'static, O, F: FnOnce() -> (N, O)>( this: Self, 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.
Sourcepub fn debug_references(this: &Self) -> DebugReferences<T>
pub fn debug_references(this: &Self) -> DebugReferences<T>
Creates a DebugReferences instance.