pub unsafe trait StablePayloadInit: StablePayload {
type Init<'a>;
// Provided methods
fn init_from_uninit_bytes<'a>(
payload: &'a mut [MaybeUninit<u8>],
) -> Result<Self::Init<'a>, UWireError> { ... }
fn init_from_uninit_payload<'a>(
payload: LoanedPayloadUninitMut<'a>,
) -> Result<Self::Init<'a>, UWireError> { ... }
}Expand description
Safe generated initialization proof for stable-container payloads.
Derived implementations initialize one stable payload directly in
uninitialized storage. Generated builders expose named typed setters and make
finish() available only after all required fields are set. Implementations
must also initialize any implicit and trailing padding bytes they own without
blanket-zeroing the full payload.
§Safety
Implementors must guarantee that every successful finish() for Self::Init
returns only after the full transported size_of::<Self>() byte range,
including implicit padding, contains one valid initialized Self in the
stable-container representation. Ordinary payload types should use the derive
macro; manual implementations are an expert unsafe extension point.
Required Associated Types§
Provided Methods§
Sourcefn init_from_uninit_bytes<'a>(
payload: &'a mut [MaybeUninit<u8>],
) -> Result<Self::Init<'a>, UWireError>
fn init_from_uninit_bytes<'a>( payload: &'a mut [MaybeUninit<u8>], ) -> Result<Self::Init<'a>, UWireError>
Creates a generated initializer from an exact uninitialized payload range.
§Errors
Returns an error if the byte range does not match this stable payload’s size and alignment.
Sourcefn init_from_uninit_payload<'a>(
payload: LoanedPayloadUninitMut<'a>,
) -> Result<Self::Init<'a>, UWireError>
fn init_from_uninit_payload<'a>( payload: LoanedPayloadUninitMut<'a>, ) -> Result<Self::Init<'a>, UWireError>
Creates a generated initializer from a transport loan’s visible payload range.
§Errors
Returns an error if the payload range does not match this stable payload’s size and alignment.
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.