Struct Id

Source
pub struct Id<T, O = Owned> { /* private fields */ }
Expand description

A pointer type for Objective-C’s reference counted objects.

The object of an Id is retained and sent a release message when the Id is dropped.

An Id may be either Owned or Shared, represented by the types Id and ShareId, respectively. If owned, there are no other references to the object and the Id can be mutably dereferenced. ShareId, however, can only be immutably dereferenced because there may be other references to the object, but a ShareId can be cloned to provide more references to the object. An owned Id can be “downgraded” freely to a ShareId, but there is no way to safely upgrade back.

Implementations§

Source§

impl<T, O> Id<T, O>
where T: Message, O: Ownership,

Source

pub unsafe fn from_ptr(ptr: *mut T) -> Id<T, O>

Constructs an Id from a pointer to an unretained object and retains it. Panics if the pointer is null. Unsafe because the pointer must be to a valid object and the caller must ensure the ownership is correct.

Source

pub unsafe fn from_retained_ptr(ptr: *mut T) -> Id<T, O>

Constructs an Id from a pointer to a retained object; this won’t retain the pointer, so the caller must ensure the object has a +1 retain count. Panics if the pointer is null. Unsafe because the pointer must be to a valid object and the caller must ensure the ownership is correct.

Source§

impl<T> Id<T>
where T: Message,

Source

pub fn share(self) -> Id<T, Shared>

“Downgrade” an owned Id to a ShareId, allowing it to be cloned.

Trait Implementations§

Source§

impl<T> Clone for Id<T, Shared>
where T: Message,

Source§

fn clone(&self) -> Id<T, Shared>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T, O> Debug for Id<T, O>
where T: Debug,

Source§

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

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

impl<T, O> Deref for Id<T, O>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<T> DerefMut for Id<T>

Source§

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

Mutably dereferences the value.
Source§

impl<T, O> Hash for Id<T, O>
where T: Hash,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T, O> PartialEq for Id<T, O>
where T: PartialEq,

Source§

fn eq(&self, other: &Id<T, O>) -> bool

Tests for self and other values to be equal, and is used by ==.
Source§

fn ne(&self, other: &Id<T, O>) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, O> Pointer for Id<T, O>

Source§

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

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

impl<T, O> Eq for Id<T, O>
where T: Eq,

Source§

impl<T> Send for Id<T>
where T: Send,

Source§

impl<T> Send for Id<T, Shared>
where T: Sync,

Source§

impl<T, O> Sync for Id<T, O>
where T: Sync,

Auto Trait Implementations§

§

impl<T, O> Freeze for Id<T, O>

§

impl<T, O> RefUnwindSafe for Id<T, O>

§

impl<T, O = Owned> !Send for Id<T, O>

§

impl<T, O> Unpin for Id<T, O>
where T: Unpin, O: Unpin,

§

impl<T, O> UnwindSafe for Id<T, O>
where T: UnwindSafe, O: UnwindSafe,

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