pub struct Buffer { /* private fields */ }Expand description
Reference-counted byte buffer with copy-on-write semantics.
Based on FFmpeg’s AVBuffer model:
- Shared via
Arc(reference counting) make_writable()copies only if shared (CoW)- All allocations include SIMD padding initialized to zero
- Data is 64-byte aligned for SIMD operations
Implementations§
Source§impl Buffer
impl Buffer
Sourcepub fn new(size: usize) -> Self
pub fn new(size: usize) -> Self
Create a new buffer of the given size, zero-initialized with SIMD padding.
Sourcepub fn from_slice(data: &[u8]) -> Self
pub fn from_slice(data: &[u8]) -> Self
Create a buffer from existing data. Padding is appended.
Sourcepub fn is_writable(&self) -> bool
pub fn is_writable(&self) -> bool
Returns true if this is the only reference to the underlying data.
Sourcepub fn make_writable(&mut self)
pub fn make_writable(&mut self)
Ensure the buffer is writable (CoW). If shared, creates a copy.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Send for Buffer
impl Sync for Buffer
impl Unpin for Buffer
impl UnsafeUnpin for Buffer
impl UnwindSafe for Buffer
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