pub trait Deserialize: Sized {
type UninitType;
const ASSERT_UNINIT_SIZE_AND_ALIGNMENT: bool = _;
// Required methods
fn uninit() -> Self::UninitType;
fn from_init(value: Self) -> Self::UninitType;
fn deserialize(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>;
// Provided method
fn deserialize_from(
&mut self,
parcel: &BorrowedParcel<'_>,
) -> Result<(), StatusCode> { ... }
}
Expand description
A struct whose instances can be restored from a crate::parcel::Parcel
.
Provided Associated Constants§
Sourceconst ASSERT_UNINIT_SIZE_AND_ALIGNMENT: bool = _
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!
.
Required Associated Types§
Sourcetype UninitType
type UninitType
Type for the uninitialized value of this type. Will be either Self
if the type implements Default
, Option<Self>
otherwise.
Required Methods§
Sourcefn uninit() -> Self::UninitType
fn uninit() -> Self::UninitType
Return an uninitialized or default-initialized value for this type.
Sourcefn from_init(value: Self) -> Self::UninitType
fn from_init(value: Self) -> Self::UninitType
Convert an initialized value of type Self
into Self::UninitType
.
Sourcefn deserialize(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>
fn deserialize(parcel: &BorrowedParcel<'_>) -> Result<Self, StatusCode>
Deserialize an instance from the given crate::parcel::Parcel
.
Provided Methods§
Sourcefn deserialize_from(
&mut self,
parcel: &BorrowedParcel<'_>,
) -> Result<(), StatusCode>
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.