#[repr(C)]pub struct StbBytes {
pub ptr: *mut u8,
pub len: usize,
}Expand description
An owned byte buffer that can cross an ABI boundary as pointer plus length.
The allocation is always released by the producer’s FreeBytesFn, just as
StbString is released by FreeStringFn. This type does not carry an
allocator or lifetime; those are part of the call contract.
Fields§
§ptr: *mut u8§len: usizeImplementations§
Source§impl StbBytes
impl StbBytes
pub const fn is_empty(&self) -> bool
Sourcepub unsafe fn to_vec(&self) -> Vec<u8> ⓘ
pub unsafe fn to_vec(&self) -> Vec<u8> ⓘ
Copy the borrowed ABI buffer into a Rust-owned vector.
§Safety
ptr must be valid for len initialized bytes in one allocation and
remain readable for the duration of this call.
Sourcepub unsafe fn free_with(self, free_fn: Option<FreeBytesFn>)
pub unsafe fn free_with(self, free_fn: Option<FreeBytesFn>)
Release the buffer through its producer-side deallocator.
§Safety
The buffer must be a live allocation produced by free_fn’s allocator,
and ownership must be transferred exactly once.
Trait Implementations§
impl Copy for StbBytes
impl Send for StbBytes
impl Sync for StbBytes
Auto Trait Implementations§
impl Freeze for StbBytes
impl RefUnwindSafe for StbBytes
impl Unpin for StbBytes
impl UnsafeUnpin for StbBytes
impl UnwindSafe for StbBytes
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more