Struct objc2::rc::WeakId

source ·
#[repr(transparent)]
pub struct WeakId<T: ?Sized> { /* private fields */ }
Expand description

A pointer type for a weak reference to an Objective-C reference counted object.

Allows breaking reference cycles and safely checking whether the object has been deallocated.

Implementations§

source§

impl<T: Message> WeakId<T>

source

pub fn new(obj: &Id<T, Shared>) -> Self

Construct a new WeakId referencing the given shared Id.

source

pub fn load(&self) -> Option<Id<T, Shared>>

Load a shared (and retained) Id if the object still exists.

Returns None if the object has been deallocated or was created with Default::default.

Trait Implementations§

source§

impl<T> Clone for WeakId<T>

source§

fn clone(&self) -> Self

Makes a clone of the WeakId that points to the same object.

1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<T: Debug + ?Sized> Debug for WeakId<T>

source§

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

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

impl<T: Message> Default for WeakId<T>

source§

fn default() -> Self

Constructs a new WeakId<T> that doesn’t reference any object.

Calling Self::load on the return value always gives None.

source§

impl<T: ?Sized> Drop for WeakId<T>

source§

fn drop(&mut self)

Drops the WeakId pointer.

source§

impl<T: Message> From<Id<T, Shared>> for WeakId<T>

source§

fn from(obj: Id<T, Shared>) -> Self

Converts to this type from the input type.
source§

impl<T: Message> TryFrom<WeakId<T>> for Id<T, Shared>

§

type Error = ()

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

fn try_from(weak: WeakId<T>) -> Result<Self, ()>

Performs the conversion.
source§

impl<T: RefUnwindSafe + ?Sized> RefUnwindSafe for WeakId<T>

source§

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

This implementation follows the same reasoning as Id<T, Shared>.

source§

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

This implementation follows the same reasoning as Id<T, Shared>.

source§

impl<T: ?Sized> Unpin for WeakId<T>

source§

impl<T: RefUnwindSafe + ?Sized> UnwindSafe for WeakId<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere 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 Twhere 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<T> AutoreleaseSafe for Twhere T: ?Sized,