Struct objc_id::Id
[−]
[src]
pub struct Id<T, O = Owned> { // some 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]
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.
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]
Trait Implementations
impl<T> Clone for Id<T, Shared> where T: Message
[src]
fn clone(&self) -> ShareId<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T, O> Sync for Id<T, O> where T: Sync
[src]
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> Deref for Id<T, O>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<T> DerefMut for Id<T, Owned>
[src]
fn deref_mut(&mut self) -> &mut T
The method called to mutably dereference a value
impl<T, O> PartialEq for Id<T, O> where T: PartialEq
[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
This method tests for !=
.
impl<T, O> Eq for Id<T, O> where T: Eq
[src]
impl<T, O> Hash for Id<T, O> where T: Hash
[src]
fn hash<H>(&self, state: &mut H) where H: Hasher
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.