[−][src]Struct objc_id::Id
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]
T: Message,
O: Ownership,
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]
T: Message,
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]
T: PartialEq,
impl<T, O> Sync for Id<T, O> where
T: Sync,
[src]
T: Sync,
impl<T> Clone for Id<T, Shared> where
T: Message,
[src]
T: Message,
fn clone(&self) -> ShareId<T>
[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]
T: Send,
impl<T> Send for Id<T, Shared> where
T: Sync,
[src]
T: Sync,
impl<T, O> Eq for Id<T, O> where
T: Eq,
[src]
T: Eq,
impl<T, O> Debug for Id<T, O> where
T: Debug,
[src]
T: Debug,
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]
impl<T, O> Hash for Id<T, O> where
T: Hash,
[src]
T: Hash,
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,