Struct binder_ndk_sys::AIBinder

source ·
#[repr(C)]
pub struct AIBinder { /* private fields */ }
Expand description

Represents a local or remote object which can be used for IPC or which can itself be sent.

This object has a refcount associated with it and will be deleted when its refcount reaches zero. How methods interactive with this refcount is described below. When using this API, it is intended for a client of a service to hold a strong reference to that service. This also means that user data typically should hold a strong reference to a local AIBinder object. A remote AIBinder object automatically holds a strong reference to the AIBinder object in the server’s process. A typically memory layout looks like this:

Key: —> Ownership/a strong reference …> A weak reference

                    (process boundary)
                            |

MyInterface —> AIBinder_Weak | ProxyForMyInterface ^ . | | | . | | | v | v UserData <— AIBinder <-|- AIBinder |

In this way, you’ll notice that a proxy for the interface holds a strong reference to the implementation and that in the server process, the AIBinder object which was sent can be resent so that the same AIBinder object always represents the same object. This allows, for instance, an implementation (usually a callback) to transfer all ownership to a remote process and automatically be deleted when the remote process is done with it or dies. Other memory models are possible, but this is the standard one.

If the process containing an AIBinder dies, it is possible to be holding a strong reference to an object which does not exist. In this case, transactions to this binder will return STATUS_DEAD_OBJECT. See also AIBinder_linkToDeath, AIBinder_unlinkToDeath, and AIBinder_isAlive.

Once an AIBinder is created, anywhere it is passed (remotely or locally), there is a 1-1 correspondence between the address of an AIBinder and the object it represents. This means that when two AIBinder pointers point to the same address, they represent the same object (whether that object is local or remote). This correspondance can be broken accidentally if AIBinder_new is erronesouly called to create the same object multiple times.

Trait Implementations§

source§

impl Clone for AIBinder

source§

fn clone(&self) -> AIBinder

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 Debug for AIBinder

source§

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

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

impl Copy for AIBinder

Auto Trait Implementations§

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<T> ToOwned for T
where T: Clone,

§

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

§

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

§

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.