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
impl ParcelableHolder
Sourcepub fn new(stability: Stability) -> Self
pub fn new(stability: Stability) -> Self
Construct a new ParcelableHolder
with the given 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 Clone for ParcelableHolder
impl Clone for ParcelableHolder
Source§fn clone(&self) -> ParcelableHolder
fn clone(&self) -> ParcelableHolder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ParcelableHolder
impl Debug for ParcelableHolder
Source§impl Deserialize for ParcelableHolder
impl Deserialize for ParcelableHolder
Source§type UninitType = ParcelableHolder
type UninitType = ParcelableHolder
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 Parcelable for ParcelableHolder
impl Parcelable for ParcelableHolder
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 Serialize for ParcelableHolder
impl Serialize for ParcelableHolder
Source§fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode>
fn serialize(&self, parcel: &mut BorrowedParcel<'_>) -> Result<(), StatusCode>
crate::parcel::Parcel
.Auto Trait Implementations§
impl !Freeze for ParcelableHolder
impl RefUnwindSafe for ParcelableHolder
impl Send for ParcelableHolder
impl Sync for ParcelableHolder
impl Unpin for ParcelableHolder
impl UnwindSafe for ParcelableHolder
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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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.