#[repr(C)]pub struct RbBytesOwned {
pub len: u32,
pub data: *mut u8,
pub capacity: u32,
}Expand description
FFI-safe owned byte buffer
Unlike RbBytes, this type owns its memory and must be freed by calling
rb_bytes_free. This is used for binary data returned from Rust to the host.
§Memory Ownership
- Memory is allocated by Rust
- Must be freed by calling
rb_bytes_free - Do NOT free with host language’s free()
Fields§
§len: u32Length in bytes
data: *mut u8Pointer to binary data (Rust-owned)
capacity: u32Allocation capacity (for proper deallocation)
Implementations§
Source§impl RbBytesOwned
impl RbBytesOwned
Sourcepub fn from_slice(bytes: &[u8]) -> Self
pub fn from_slice(bytes: &[u8]) -> Self
Create from a byte slice (copies data)
Sourcepub fn as_borrowed(&self) -> RbBytes
pub fn as_borrowed(&self) -> RbBytes
Convert to borrowed RbBytes
Trait Implementations§
Source§impl Debug for RbBytesOwned
impl Debug for RbBytesOwned
Source§impl Default for RbBytesOwned
impl Default for RbBytesOwned
impl Send for RbBytesOwned
Auto Trait Implementations§
impl Freeze for RbBytesOwned
impl RefUnwindSafe for RbBytesOwned
impl !Sync for RbBytesOwned
impl Unpin for RbBytesOwned
impl UnsafeUnpin for RbBytesOwned
impl UnwindSafe for RbBytesOwned
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