Skip to main content

lift_byte_slice

Function lift_byte_slice 

Source
pub unsafe fn lift_byte_slice<'a>(
    ptr: *const u8,
    len: usize,
) -> Option<&'a [u8]>
Expand description

Borrow a (ptr, len) parameter as a byte slice for a caller-chosen lifetime, without copying.

Returns None when ptr is null but len isn’t 0, which the thunk reports as a marshalling failure.

§Safety

When ptr is non-null it must point to len initialized bytes that stay valid and unmodified for the whole lifetime 'a. Generated thunks bound 'a by the call, matching the contract that parameters are borrowed for the call’s duration.