binder

Struct ParcelableHolder

Source
pub struct ParcelableHolder { /* private fields */ }
Expand description

A container that can hold any arbitrary Parcelable.

This type is currently used for AIDL parcelable fields.

ParcelableHolder is currently not thread-safe (neither Send nor Sync), mainly because it internally contains a Parcel which in turn is not thread-safe.

Implementations§

Source§

impl ParcelableHolder

Source

pub fn new(stability: Stability) -> Self

Construct a new ParcelableHolder with the given stability.

Source

pub fn reset(&mut self)

Reset the contents of this ParcelableHolder.

Note that this method does not reset the stability, only the contents.

Source

pub fn set_parcelable<T>(&mut self, p: Arc<T>) -> Result<(), StatusCode>

Set the parcelable contained in this ParcelableHolder.

Source

pub fn get_parcelable<T>(&self) -> Result<Option<Arc<T>>, StatusCode>

Retrieve the parcelable stored in this ParcelableHolder.

This method attempts to retrieve the parcelable inside the current object as a parcelable of type T. The object is validated against T by checking that its parcelable descriptor matches the one returned by T::get_descriptor().

Returns one of the following:

  • Err(_) in case of error
  • Ok(None) if the holder is empty or the descriptor does not match
  • Ok(Some(_)) if the object holds a parcelable of type T with the correct descriptor
Source

pub fn get_stability(&self) -> Stability

Return the stability value of this object.

Trait Implementations§

Source§

impl Clone for ParcelableHolder

Source§

fn clone(&self) -> ParcelableHolder

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 ParcelableHolder

Source§

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

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

impl Deserialize for ParcelableHolder

Source§

type UninitType = ParcelableHolder

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<Self, 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 Parcelable for ParcelableHolder

Source§

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

Internal serialization function for parcelables. Read more
Source§

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

Internal deserialization function for parcelables. Read more
Source§

impl Serialize for ParcelableHolder

Source§

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

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

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