#[repr(C)]pub struct OwnedBytes {
pub ptr: *mut u8,
pub len: usize,
pub cap: usize,
pub drop_fn: Option<unsafe extern "C" fn(ptr: *mut u8, len: usize, cap: usize)>,
}Expand description
An owned byte buffer crossing the plug-in boundary.
Allocated by the producing side and freed by the producer’s drop_fn so
allocator mismatches between host and plug-in stay impossible. v1 uses
this only for runtime-constructed error messages; data payloads cross via
other paths (Arrow IPC for batches, JSON via OwnedBytes for single items).
Fields§
§ptr: *mut u8§len: usize§cap: usize§drop_fn: Option<unsafe extern "C" fn(ptr: *mut u8, len: usize, cap: usize)>Implementations§
Source§impl OwnedBytes
impl OwnedBytes
Sourcepub fn from_vec(v: Vec<u8>) -> Self
pub fn from_vec(v: Vec<u8>) -> Self
Constructs an OwnedBytes from a Rust Vec<u8> using the producer’s
allocator and stamps the matching producer-side free as drop_fn.
Consumers release the buffer by dropping the OwnedBytes (which
invokes the embedded drop_fn) or by calling that drop_fn
explicitly. Do not call drop_owned_bytes on a value received
across the plug-in boundary: that would free with the consumer’s
allocator, which may not match the producer’s. drop_owned_bytes
is only the default function installed here for the producer; each
side sees its own copy linked against its own allocator.
Trait Implementations§
Source§impl Drop for OwnedBytes
impl Drop for OwnedBytes
impl Send for OwnedBytes
SAFETY: a heap pointer freed only by its producer’s drop_fn; safe to
transfer ownership across threads.