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>

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

Returns a new strongly-held reference.

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.

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

Clones a strongly-held reference.

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

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

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(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.

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.

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.

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

Creates a DebugReferences instance.

Trait Implementations§

§

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

§

fn as_ref(&self) -> &T

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

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

§

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

Formats the value using the given formatter. Read more
§

impl<T> Deref for Primary<T>

§

type Target = T

The resulting type after dereferencing.
§

fn deref(&self) -> &T

Dereferences the value.
§

impl<T> Drop for Primary<T>

§

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
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<CC, BC, Meta> RecvFrameContext<BC, Meta> for CC
where Meta: ReceivableFrameMeta<CC, BC>,

source§

fn receive_frame<B>(&mut self, bindings_ctx: &mut BC, metadata: Meta, frame: B)
where B: BufferMut + Debug,

Receive a frame. Read more
source§

impl<CC, BC, Meta> SendFrameContext<BC, Meta> for CC
where Meta: SendableFrameMeta<CC, BC>,

source§

fn send_frame<S>( &mut self, bindings_ctx: &mut BC, metadata: Meta, frame: S ) -> Result<(), S>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Send a frame. Read more
source§

impl<Meta, BC> SendableFrameMeta<FakeFrameCtx<Meta>, BC> for Meta

source§

fn send_meta<S>( self, core_ctx: &mut FakeFrameCtx<Meta>, _bindings_ctx: &mut BC, frame: S ) -> Result<(), S>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Sends this frame metadata to the provided contexts.
source§

impl<Id, CC, BC> TimerHandler<BC, Id> for CC
where Id: HandleableTimer<CC, BC>,

source§

fn handle_timer(&mut self, bindings_ctx: &mut BC, id: Id)

Handle a timer firing.
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.
§

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

§

fn vzip(self) -> V