netstack3_core::sync

Struct PrimaryRc

Source
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>

Source§

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, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<CC, BC, Meta> RecvFrameContext<Meta, BC> 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<T> Same for T

Source§

type Output = T

Should always be Self
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<(), ErrorAndSerializer<SendFrameErrorReason, S>>
where S: Serializer, <S as Serializer>::Buffer: BufferMut,

Send a frame. Read more
Source§

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

Source§

fn handle_timer( &mut self, bindings_ctx: &mut BC, dispatch: Id, timer: <BC as TimerBindingsTypes>::UniqueTimerId, )

Handle a timer firing. Read more
Source§

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

Source§

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>,

Source§

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<L, T> UnlockedAccess<L> for T

Source§

type Data = <L as UnlockedAccessMarkerFor<T>>::Data

The type of state being accessed.
Source§

type Guard<'l> = &'l <L as UnlockedAccessMarkerFor<T>>::Data where T: 'l

A guard providing read access to the data.
Source§

fn access(&self) -> <T as UnlockedAccess<L>>::Guard<'_>

How to access the state.
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

Source§

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