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

Trait BorrowPayload

Source
pub unsafe trait BorrowPayload<T>: PayloadCodec {
    // Required method
    fn borrow_payload(src: &[u8]) -> Result<&T, UWireError>;
}
Expand description

Borrows a typed payload directly from contiguous receive storage.

This is the receive-side true zero-copy codec hook. Implementors must not allocate, copy, or deserialize into owned storage before returning &T.

§Safety

Implementors must validate that src has the exact length and alignment for one initialized T, that the bytes are a valid representation for T under this codec, and that returning &T cannot observe uninitialized padding or process-local state.

Required Methods§

Source

fn borrow_payload(src: &[u8]) -> Result<&T, UWireError>

Borrows T from contiguous payload bytes.

§Errors

Returns an error if the payload bytes cannot be borrowed as one valid T.

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§