[][src]Struct objc_id::Id

pub struct Id<T, O = Owned> { /* fields omitted */ }

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.

Methods

impl<T, O> Id<T, O> where
    T: Message,
    O: Ownership
[src]

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

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.

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

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.

impl<T> Id<T, Owned> where
    T: Message
[src]

pub fn share(self) -> ShareId<T>[src]

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

Trait Implementations

impl<T, O> PartialEq<Id<T, O>> for Id<T, O> where
    T: PartialEq
[src]

impl<T, O> Sync for Id<T, O> where
    T: Sync
[src]

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

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<T> Send for Id<T, Owned> where
    T: Send
[src]

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

impl<T, O> Eq for Id<T, O> where
    T: Eq
[src]

impl<T, O> Debug for Id<T, O> where
    T: Debug
[src]

impl<T, O> Pointer for Id<T, O>[src]

impl<T> DerefMut for Id<T, Owned>[src]

impl<T, O> Deref for Id<T, O>[src]

type Target = T

The resulting type after dereferencing.

impl<T, O> Hash for Id<T, O> where
    T: Hash
[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

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

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]