PinWeak

Struct PinWeak 

Source
pub struct PinWeak<T: ?Sized>(/* private fields */);
Expand description

PinWeak<T> represents a non-owning reference to a pinned value managed by a Pin<HybridRc<T, _>>.

The typical way to obtain a PinWeak<T> is to call HybridRc::downgrade_pin().

See Weak<T> for more information about weak references.

Implementations§

Source§

impl<T: ?Sized> PinWeak<T>

Source

pub fn upgrade_local(&self) -> Result<Pin<Rc<T>>, UpgradeError>

Attempts to upgrade the pinned weak pointer to a pinned Rc.

See Weak::upgrade_local() for more information.

§Errors
  • ValueDropped: the referenced value has already been dropped.
  • WrongThread: another thread currently holds Rcs for the value.
Source

pub fn upgrade(&self) -> Result<Pin<Arc<T>>, UpgradeError>

Attempts to upgrade the pinned weak pointer to a pinned Arc.

See Weak::upgrade() for more information.

§Errors
  • ValueDropped: the referenced value has already been dropped.
Source

pub fn strong_count(&self) -> usize

Gets a lower bound to the number of strong pointers to the inner value.

See Weak::strong_count() for more information.

Source

pub fn weak_count(&self) -> usize

Gets the number of Weak pointers to this allocation.

See Weak::strong_count() for more information.

Source

pub unsafe fn into_inner_unchecked(self) -> Weak<T>

Transforms this PinWeak<T> into a Weak<T>

§Safety

This function is unsafe. You must guarantee that you will continue to treat the Weak as pinned after you call this function. Not maintaining the pinning invariants that is a violation of the API contract and may lead to undefined behavior in later (safe) operations.

If the underlying data is Unpin, PinWeak::into_inner() should be used instead.

Source§

impl<T> PinWeak<T>

Source

pub fn new() -> PinWeak<T>

Constructs a dummy PinWeak<T>, without allocating any memory.

Trying to upgrade the result will always result in a ValueDropped error.

Source§

impl<T: ?Sized + Unpin> PinWeak<T>

Source

pub fn into_inner(self) -> Weak<T>

Transforms this PinWeak<T> into a Weak<T>

This requires that the data inside the shared allocation is Unpin, so that we can ignore the pinning invariants when unwrapping it.

Trait Implementations§

Source§

impl<T: ?Sized> Clone for PinWeak<T>

Source§

fn clone(&self) -> Self

Creates another pinned weak reference for the same value.

See Weak::clone() for more information.

1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ?Sized> Debug for PinWeak<T>

Source§

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

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

impl<T> Default for PinWeak<T>

Source§

fn default() -> Self

Constructs a dummy PinWeak<T>, without allocating any memory.

See PinWeak<T>::new().

Source§

impl<T: ?Sized> Pointer for PinWeak<T>

Source§

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

Formats the value using the given formatter.

If the # flag is used, the state (weak) is written after the address.

Source§

impl<T: ?Sized + Sync + Send> Send for PinWeak<T>

Source§

impl<T: ?Sized + Sync + Send> Sync for PinWeak<T>

Auto Trait Implementations§

§

impl<T> Freeze for PinWeak<T>
where T: ?Sized,

§

impl<T> !RefUnwindSafe for PinWeak<T>

§

impl<T> Unpin for PinWeak<T>
where T: ?Sized,

§

impl<T> !UnwindSafe for PinWeak<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.