pub struct ParcelableHolder<STABILITY: StabilityType> { /* 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<STABILITY: StabilityType> ParcelableHolder<STABILITY>
impl<STABILITY: StabilityType> ParcelableHolder<STABILITY>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset the contents of this ParcelableHolder
.
Note that this method does not reset the stability, only the contents.
Sourcepub fn set_parcelable<T>(&mut self, p: Arc<T>) -> Result<(), StatusCode>
pub fn set_parcelable<T>(&mut self, p: Arc<T>) -> Result<(), StatusCode>
Set the parcelable contained in this ParcelableHolder
.
Sourcepub fn get_parcelable<T>(&self) -> Result<Option<Arc<T>>, StatusCode>
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 errorOk(None)
if the holder is empty or the descriptor does not matchOk(Some(_))
if the object holds a parcelable of typeT
with the correct descriptor
Sourcepub fn get_stability(&self) -> Stability
pub fn get_stability(&self) -> Stability
Return the stability value of this object.
Trait Implementations§
Source§impl<STABILITY: StabilityType> Clone for ParcelableHolder<STABILITY>
impl<STABILITY: StabilityType> Clone for ParcelableHolder<STABILITY>
Source§impl<STABILITY: Debug + StabilityType> Debug for ParcelableHolder<STABILITY>
impl<STABILITY: Debug + StabilityType> Debug for ParcelableHolder<STABILITY>
Source§impl<STABILITY: StabilityType> Default for ParcelableHolder<STABILITY>
impl<STABILITY: StabilityType> Default for ParcelableHolder<STABILITY>
Source§impl<STABILITY: StabilityType> Deserialize for ParcelableHolder<STABILITY>
impl<STABILITY: StabilityType> Deserialize for ParcelableHolder<STABILITY>
Source§type UninitType = ParcelableHolder<STABILITY>
type UninitType = ParcelableHolder<STABILITY>
Self
if the type implements Default
, Option<Self>
otherwise.Source§fn uninit() -> Self::UninitType
fn uninit() -> Self::UninitType
Source§fn from_init(value: Self) -> Self::UninitType
fn from_init(value: Self) -> Self::UninitType
Self
into Self::UninitType
.Source§fn deserialize(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>
fn deserialize(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>
crate::parcel::Parcel
.Source§const ASSERT_UNINIT_SIZE_AND_ALIGNMENT: bool = _
const ASSERT_UNINIT_SIZE_AND_ALIGNMENT: bool = _
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>
fn deserialize_from( &mut self, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>
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<STABILITY: StabilityType> Parcelable for ParcelableHolder<STABILITY>
impl<STABILITY: StabilityType> Parcelable for ParcelableHolder<STABILITY>
Source§fn write_to_parcel(
&self,
parcel: &mut BorrowedParcel<'_>,
) -> Result<(), StatusCode>
fn write_to_parcel( &self, parcel: &mut BorrowedParcel<'_>, ) -> Result<(), StatusCode>
Source§fn read_from_parcel(
&mut self,
parcel: &BorrowedParcel<'_>,
) -> Result<(), StatusCode>
fn read_from_parcel( &mut self, parcel: &BorrowedParcel<'_>, ) -> Result<(), StatusCode>
Source§impl<STABILITY: StabilityType> Serialize for ParcelableHolder<STABILITY>
impl<STABILITY: StabilityType> Serialize for ParcelableHolder<STABILITY>
Source§fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode>
fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode>
crate::parcel::Parcel
.Auto Trait Implementations§
impl<STABILITY> !Freeze for ParcelableHolder<STABILITY>
impl<STABILITY> RefUnwindSafe for ParcelableHolder<STABILITY>where
STABILITY: RefUnwindSafe,
impl<STABILITY> Send for ParcelableHolder<STABILITY>where
STABILITY: Send,
impl<STABILITY> Sync for ParcelableHolder<STABILITY>where
STABILITY: Sync,
impl<STABILITY> Unpin for ParcelableHolder<STABILITY>where
STABILITY: Unpin,
impl<STABILITY> UnwindSafe for ParcelableHolder<STABILITY>where
STABILITY: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.