binder

Struct SpIBinder

Source
pub struct SpIBinder(/* private fields */);
Expand description

A strong reference to a Binder remote object.

This struct encapsulates the generic C++ sp<IBinder> class. This wrapper is untyped; typed interface access is implemented by the AIDL compiler.

Implementations§

Source§

impl SpIBinder

Source

pub unsafe fn as_raw(&self) -> *mut AIBinder

Extract a raw AIBinder pointer from this wrapper.

This method should only be used for testing. Do not try to use the NDK interface directly for anything else.

§Safety

The resulting pointer is valid only as long as the SpIBinder is alive. The SpIBinder object retains ownership of the AIBinder and the caller should not attempt to free the returned pointer.

Source

pub fn is_remote(&self) -> bool

Return true if this binder object is hosted in a different process than the current one.

Source

pub fn into_interface<I: FromIBinder + Interface + ?Sized>( self, ) -> Result<Strong<I>, StatusCode>

Try to convert this Binder object into a trait object for the given Binder interface.

If this object does not implement the expected interface, the error StatusCode::BAD_TYPE is returned.

Source

pub fn get_class(&mut self) -> Option<InterfaceClass>

Return the interface class of this binder object, if associated with one.

Source

pub fn downgrade(&mut self) -> WpIBinder

Creates a new weak reference to this binder object.

Trait Implementations§

Source§

impl AssociateClass for SpIBinder

Source§

fn associate_class(&mut self, class: InterfaceClass) -> bool

Check if this object is a valid object for the given interface class I. Read more
Source§

impl Clone for SpIBinder

Source§

fn clone(&self) -> Self

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 SpIBinder

Source§

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

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

impl Deserialize for SpIBinder

Source§

type UninitType = Option<SpIBinder>

Type for the uninitialized value of this type. Will be either Self if the type implements Default, Option<Self> otherwise.
Source§

fn uninit() -> Self::UninitType

Return an uninitialized or default-initialized value for this type.
Source§

fn from_init(value: Self) -> Self::UninitType

Convert an initialized value of type Self into Self::UninitType.
Source§

fn deserialize(parcel: &BorrowedParcel<'_>) -> Result<SpIBinder, StatusCode>

Deserialize an instance from the given crate::parcel::Parcel.
Source§

const ASSERT_UNINIT_SIZE_AND_ALIGNMENT: bool = _

Assert at compile-time that Self and Self::UninitType have the same size and alignment. This will either fail to compile or evaluate to true. The only two macros that work here are panic! and assert!, so we cannot use assert_eq!.
Source§

fn deserialize_from( &mut self, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Deserialize an instance from the given crate::parcel::Parcel onto the current object. This operation will overwrite the old value partially or completely, depending on how much data is available.
Source§

impl DeserializeArray for SpIBinder

Source§

fn deserialize_array( parcel: &BorrowedParcel<'_>, ) -> Result<Option<Vec<Self>>, StatusCode>

Deserialize an array of type from the given parcel.
Source§

impl DeserializeOption for SpIBinder

Source§

fn deserialize_option( parcel: &BorrowedParcel<'_>, ) -> Result<Option<SpIBinder>, StatusCode>

Deserialize an Option of this type from the given parcel.
Source§

fn deserialize_option_from( this: &mut Option<Self>, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Deserialize an Option of this type from the given parcel onto the current object. This operation will overwrite the current value partially or completely, depending on how much data is available.
Source§

impl Drop for SpIBinder

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Ord for SpIBinder

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for SpIBinder

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SpIBinder

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for SpIBinder

Source§

fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode>

Serialize this instance into the given crate::parcel::Parcel.
Source§

impl SerializeArray for SpIBinder

Source§

fn serialize_array( slice: &[Self], parcel: &mut BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Serialize an array of this type into the given parcel.
Source§

impl SerializeOption for SpIBinder

Source§

fn serialize_option( this: Option<&Self>, parcel: &mut BorrowedParcel<'_>, ) -> Result<(), StatusCode>

Serialize an Option of this type into the given parcel.
Source§

impl<B: Remotable> TryFrom<SpIBinder> for Binder<B>

Source§

type Error = android_c_interface_StatusCode

The type returned in the event of a conversion error.
Source§

fn try_from(ibinder: SpIBinder) -> Result<Self, StatusCode>

Performs the conversion.
Source§

impl Eq for SpIBinder

Source§

impl Send for SpIBinder

Safety: An SpIBinder is an immutable handle to a C++ IBinder, which is thread-safe.

Source§

impl Sync for SpIBinder

Safety: An SpIBinder is an immutable handle to a C++ IBinder, which is thread-safe.

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§

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> IBinder for T
where T: AsNative<AIBinder>,

Register the recipient for a notification if this binder goes away. If this binder object unexpectedly goes away (typically because its hosting process has been killed), then the DeathRecipient’s callback will be called. Read more
Remove a previously registered death notification. The recipient will no longer be called if this object dies.
Source§

fn ping_binder(&mut self) -> Result<(), android_c_interface_StatusCode>

Send a ping transaction to this object
Source§

impl<T> IBinderInternal for T
where T: AsNative<AIBinder>,

Source§

fn prepare_transact(&self) -> Result<Parcel, android_c_interface_StatusCode>

Create a Parcel that can be used with submit_transact.
Source§

fn submit_transact( &self, code: u32, data: Parcel, flags: u32, ) -> Result<Parcel, android_c_interface_StatusCode>

Perform a generic operation with the object. Read more
Source§

fn is_binder_alive(&self) -> bool

Is this object still alive?
Source§

fn set_requesting_sid(&mut self, enable: bool)

Indicate that the service intends to receive caller security contexts.
Source§

fn dump<F>( &mut self, fp: &F, args: &[&str], ) -> Result<(), android_c_interface_StatusCode>
where F: AsRawFd,

Dump this object to the given file handle
Source§

fn get_extension( &mut self, ) -> Result<Option<SpIBinder>, android_c_interface_StatusCode>

Get a new interface that exposes additional extension functionality, if available.
Source§

fn transact<F: FnOnce(BorrowedParcel<'_>) -> Result<(), StatusCode>>( &self, code: TransactionCode, flags: TransactionFlags, input_callback: F, ) -> Result<Parcel, StatusCode>

Perform a generic operation with the object. This is a convenience method that internally calls prepare_transact followed by `submit_transact. Read more
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,

Source§

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

Source§

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

Source§

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.