pub fn native_abi_owned_bytes(bytes: Vec<u8>) -> NativeAbiOwnedBytesExpand description
Transfers ownership of a Vec<u8> into an ABI owned-bytes descriptor.
ยงExamples
use sim_kernel::native_abi_owned_bytes;
let owned = native_abi_owned_bytes(vec![7u8, 8, 9]);
assert_eq!(owned.len, 3);
assert!(owned.cap >= owned.len);
// The descriptor owns the allocation; reclaim it to avoid a leak.
let reclaimed = unsafe { Vec::from_raw_parts(owned.ptr, owned.len, owned.cap) };
assert_eq!(reclaimed, vec![7u8, 8, 9]);