Preview of the proposed up-rust native-frame-model branch (up-rust b6b99c6d, up-spec f0e9b17) — not released documentation. branch · write-up

Trait LoanPayload

Source
pub unsafe trait LoanPayload<T>: PayloadCodec {
    // Required methods
    fn loan_layout() -> Result<PayloadLayout, UWireError>;
    fn loan_payload(dst: &mut [u8]) -> Result<&mut T, UWireError>;
}
Expand description

Initializes and borrows a typed value directly in initialized transmit storage.

§Safety

Implementors must guarantee that LoanPayload::loan_payload returns &mut T only when the destination byte range is uniquely borrowed, has the exact layout returned by LoanPayload::loan_layout, and contains one valid initialized T for the returned lifetime.

Required Methods§

Source

fn loan_layout() -> Result<PayloadLayout, UWireError>

Returns the exact layout required for a typed initialized transmit loan.

§Errors

Returns an error if this codec cannot loan T into initialized TX storage.

Source

fn loan_payload(dst: &mut [u8]) -> Result<&mut T, UWireError>

Initializes dst and returns a typed mutable view over the loaned payload.

§Errors

Returns an error if dst does not have the required length or 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.

Implementors§