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§

source§

impl<T> Primary<T>

source

pub fn new(data: T) -> Primary<T>

Returns a new strongly-held reference.

source

pub fn new_cyclic(data_fn: impl FnOnce(Weak<T>) -> T) -> Primary<T>

Constructs a new Primary<T> while giving you a Weak to the allocation, to allow you to construct a T 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.

source

pub fn clone_strong(_: &Primary<T>) -> Strong<T>

Clones a strongly-held reference.

source

pub fn downgrade(_: &Primary<T>) -> Weak<T>

Returns a weak reference pointing to the same underlying data.

source

pub fn ptr_eq(_: &Primary<T>, _: &Strong<T>) -> bool

Returns true if the two pointers point to the same allocation.

source

pub fn debug_id(&self) -> impl Debug

Returns core::fmt::Debug implementation that is stable and unique for the data held behind this Primary.

source

pub fn unwrap(this: Primary<T>) -> T

Returns the inner value if no Strong references are held.

§Panics

Panics if Strong references are held when this function is called.

source

pub fn unwrap_with_notifier<N>(this: Primary<T>, notifier: N)
where N: Notifier<T> + 'static,

Marks this Primary for destruction and uses notifier as a signaler for when destruction of all strong references is terminated. After calling unwrap_with_notifier Weak references can no longer be upgraded.

source

pub fn unwrap_or_notify_with<N, O, F>( this: Primary<T>, new_notifier: F ) -> Result<T, O>
where N: Notifier<T> + 'static, F: FnOnce() -> (N, 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.

source

pub fn debug_references(this: &Primary<T>) -> DebugReferences<T>

Creates a DebugReferences instance.

Trait Implementations§

source§

impl<T> AsRef<T> for Primary<T>

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Debug for Primary<T>
where T: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> Deref for Primary<T>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T> Drop for Primary<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Primary<T>

§

impl<T> RefUnwindSafe for Primary<T>
where T: RefUnwindSafe,

§

impl<T> Send for Primary<T>
where T: Sync + Send,

§

impl<T> Sync for Primary<T>
where T: Sync + Send,

§

impl<T> Unpin for Primary<T>

§

impl<T> UnwindSafe for Primary<T>
where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> InstantBindingsTypes for T

§

type Instant = FakeInstant

The type of an instant in time. Read more
source§

impl<T> InstantContext for T

source§

fn now(&self) -> FakeInstant

Returns the current instant. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<N> UnreachableExt for N
where N: AsRef<Infallible>,

source§

fn uninstantiable_unreachable<T>(&self) -> T

A method that can’t be called. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<B, A> LockBefore<B> for A
where B: LockAfter<A>,