#[unsafe(no_mangle)]pub unsafe extern "C" fn hurray_buffer_from_ptr(
data: *mut c_void,
byte_size: u64,
alignment: u32,
device_tag: u8,
sync_mode: u8,
memory_class: u8,
release: HurrayReleaseCallback,
release_context: *mut c_void,
out_handle: *mut *mut HurrayBuffer,
) -> HurrayStatusExpand description
Creates a new HurrayBuffer handle from a raw data pointer and metadata.
The caller retains ownership of data until the handle is destroyed via
hurray_buffer_destroy, at which point the release callback (if
non-null) is invoked with (data, release_context). If release is null,
the caller is responsible for freeing data after destroying the handle.
§Arguments
data— Non-null pointer to the first byte of the buffer. MUST be aligned to at leastalignmentbytes.byte_size— Length of the buffer in bytes.alignment— Declared alignment ofdatain bytes; MUST be a power of two and at leasthurray_core::MIN_BUFFER_ALIGNMENTfor non-empty buffers.device_tag— Wire byte identifying the memory space (seedocs/spec/buffer-protocol.md § Device Tags).sync_mode— Wire byte for producer/consumer ordering (seedocs/spec/buffer-protocol.md § Synchronization Mode).memory_class— Wire byte for memory accessibility class.release— Optional callback invoked onhurray_buffer_destroy.release_context— Opaque context pointer forwarded torelease; MAY be null.out_handle— Non-null pointer to a*mut HurrayBuffer; set to the newly allocated handle on success.
§Safety
dataMUST be a valid, non-null pointer to at leastbyte_sizebytes.dataMUST remain valid until the release callback is called.out_handleMUST be a valid, non-null, writable pointer.release_contextlifetime is caller-managed; it MUST remain valid until the release callback returns.