pub struct DynamicByteBuffer { /* private fields */ }Expand description
A mutable byte buffer with Arc-based reference counting. Send but not Sync - can be moved between threads but not shared. Pool-attached buffers are returned to the pool on drop.
Implementations§
Source§impl DynamicByteBuffer
impl DynamicByteBuffer
Sourcepub fn copy(&self) -> Self
pub fn copy(&self) -> Self
Convert to an immutable StaticByteBuffer (deep copy, capacity trimmed).
Sourcepub fn to_owned(&self) -> StaticByteBuffer
pub fn to_owned(&self) -> StaticByteBuffer
Convert to an immutable StaticByteBuffer (deep copy, capacity trimmed).
Sourcepub fn before_capacity(&self) -> usize
pub fn before_capacity(&self) -> usize
Returns the number of bytes available for prepending before the current view.
Sourcepub fn append_buf(&self, other: &impl ByteBuffer) -> Self
pub fn append_buf(&self, other: &impl ByteBuffer) -> Self
Append other buffer contents to end. Returns expanded view.
Sourcepub fn prepend_buf(&self, other: &impl ByteBuffer) -> Self
pub fn prepend_buf(&self, other: &impl ByteBuffer) -> Self
Prepend other buffer contents to start. Returns expanded view.
Trait Implementations§
Source§impl AsMut<[u8]> for DynamicByteBuffer
impl AsMut<[u8]> for DynamicByteBuffer
Source§impl AsRef<[u8]> for DynamicByteBuffer
impl AsRef<[u8]> for DynamicByteBuffer
Source§impl ByteBuffer for DynamicByteBuffer
impl ByteBuffer for DynamicByteBuffer
Source§impl ByteBufferMut for DynamicByteBuffer
impl ByteBufferMut for DynamicByteBuffer
Source§fn slice_start_mut(&self, start: usize) -> &mut [u8] ⓘ
fn slice_start_mut(&self, start: usize) -> &mut [u8] ⓘ
start offset to end.Source§fn slice_end_mut(&self, end: usize) -> &mut [u8] ⓘ
fn slice_end_mut(&self, end: usize) -> &mut [u8] ⓘ
end offset.Source§fn slice_both_mut(&self, start: usize, end: usize) -> &mut [u8] ⓘ
fn slice_both_mut(&self, start: usize, end: usize) -> &mut [u8] ⓘ
start to end offset.Source§fn split_mut(&self, divide: usize) -> (&mut [u8], &mut [u8])
fn split_mut(&self, divide: usize) -> (&mut [u8], &mut [u8])
divide point. Returns (left, right).Source§fn rebuffer_start(&self, start: usize) -> Self
fn rebuffer_start(&self, start: usize) -> Self
start bytes.Source§fn rebuffer_end(&self, end: usize) -> Self
fn rebuffer_end(&self, end: usize) -> Self
end offset from current start.Source§fn rebuffer_both(&self, start: usize, end: usize) -> Self
fn rebuffer_both(&self, start: usize, end: usize) -> Self
start and end adjusted from current start.Source§fn expand_start(&self, size: usize) -> Self
fn expand_start(&self, size: usize) -> Self
size bytes (into header space).Source§fn expand_end(&self, size: usize) -> Self
fn expand_end(&self, size: usize) -> Self
size bytes (into trailer space).Source§fn split_buf_start(&self, divide: usize) -> (Self, Self)
fn split_buf_start(&self, divide: usize) -> (Self, Self)
divide point. Returns (left, right).Source§fn split_buf_end(&self, divide: usize) -> (Self, Self)
fn split_buf_end(&self, divide: usize) -> (Self, Self)
len(buffer) - divide point. Returns (left, right).Source§fn ensure_size(&self, size: usize) -> Self
fn ensure_size(&self, size: usize) -> Self
size bytes, expanding or shrinking as needed.Source§impl Clone for DynamicByteBuffer
impl Clone for DynamicByteBuffer
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Zero-copy clone: increments the Arc<BufferHolder> refcount and produces a second
view into the same backing allocation.
§Aliasing invariant
Both the original and the clone share the same raw memory. The caller must ensure that
no two live mutable views (via slice_mut, set, etc.) to overlapping byte ranges
are used concurrently — including across threads, since DynamicByteBuffer: Send.
Non-overlapping views (e.g. produced by split_buf_start/split_buf_end) may be used independently.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more