Struct objc_id::Id [−][src]
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]
impl<T, O> Id<T, O> where
T: Message,
O: Ownership,
pub unsafe fn from_ptr(ptr: *mut T) -> Id<T, O>
[src]
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.
pub unsafe fn from_retained_ptr(ptr: *mut T) -> Id<T, O>
[src]
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.
impl<T> Id<T, Owned> where
T: Message,
[src]
impl<T> Id<T, Owned> where
T: Message,
"Downgrade" an owned Id
to a ShareId
, allowing it to be cloned.
Trait Implementations
impl<T> Clone for Id<T, Shared> where
T: Message,
[src]
impl<T> Clone for Id<T, Shared> where
T: Message,
fn clone(&self) -> ShareId<T>
[src]
fn clone(&self) -> ShareId<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T, O> Sync for Id<T, O> where
T: Sync,
[src]
impl<T, O> Sync for Id<T, O> where
T: Sync,
impl<T> Send for Id<T, Owned> where
T: Send,
[src]
impl<T> Send for Id<T, Owned> where
T: Send,
impl<T> Send for Id<T, Shared> where
T: Sync,
[src]
impl<T> Send for Id<T, Shared> where
T: Sync,
impl<T, O> Deref for Id<T, O>
[src]
impl<T, O> Deref for Id<T, O>
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
fn deref(&self) -> &T
Dereferences the value.
impl<T> DerefMut for Id<T, Owned>
[src]
impl<T> DerefMut for Id<T, Owned>
impl<T, O> PartialEq for Id<T, O> where
T: PartialEq,
[src]
impl<T, O> PartialEq for Id<T, O> where
T: PartialEq,
fn eq(&self, other: &Id<T, O>) -> bool
[src]
fn eq(&self, other: &Id<T, O>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Id<T, O>) -> bool
[src]
fn ne(&self, other: &Id<T, O>) -> bool
This method tests for !=
.
impl<T, O> Eq for Id<T, O> where
T: Eq,
[src]
impl<T, O> Eq for Id<T, O> where
T: Eq,
impl<T, O> Hash for Id<T, O> where
T: Hash,
[src]
impl<T, O> Hash for Id<T, O> where
T: Hash,
fn hash<H>(&self, state: &mut H) where
H: Hasher,
[src]
fn hash<H>(&self, state: &mut H) where
H: Hasher,
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<T, O> Debug for Id<T, O> where
T: Debug,
[src]
impl<T, O> Debug for Id<T, O> where
T: Debug,
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<T, O> Pointer for Id<T, O>
[src]
impl<T, O> Pointer for Id<T, O>