Skip to main content

take_owned_bytes

Function take_owned_bytes 

Source
pub unsafe fn take_owned_bytes(buffer: AlefOwnedBuffer) -> Vec<u8> ⓘ
Expand description

Copy an owned buffer’s bytes into a Vec<u8> and release the original allocation through its own free callback.

Generated contract proxies use this to convert a component’s AlefOwnedBuffer results into owned Rust values. It is alef_component_abi::take_owned_bytes, re-exported so existing generated code keeps its alef_component_runtime::take_owned_bytes path. Copy an owned buffer’s bytes into a Vec<u8> and release the original allocation through its own free callback.

This is the receiving side of owned_buffer: hosts call it on a component’s results, and components on buffers the host returns from a service call.

§Safety

buffer must be a valid AlefOwnedBuffer: ptr must be non-null and valid for len bytes whenever len > 0, and free (if present) must be safe to call with this buffer’s own context, ptr, len, and capacity. The buffer must not be used again afterwards.