Skip to main content

DynamicByteBuffer

Struct DynamicByteBuffer 

Source
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

Source

pub fn copy(&self) -> Self

Convert to an immutable StaticByteBuffer (deep copy, capacity trimmed).

Source

pub fn to_owned(&self) -> StaticByteBuffer

Convert to an immutable StaticByteBuffer (deep copy, capacity trimmed).

Source

pub fn before_capacity(&self) -> usize

Returns the number of bytes available for prepending before the current view.

Source

pub fn append_buf(&self, other: &impl ByteBuffer) -> Self

Append other buffer contents to end. Returns expanded view.

Source

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

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for DynamicByteBuffer

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl ByteBuffer for DynamicByteBuffer

Source§

fn len(&self) -> usize

Returns the length of the current view in bytes.
Source§

fn get(&self, at: usize) -> &u8

Get byte at at index. Panics if out of bounds.
Source§

fn slice(&self) -> &[u8]

Get immutable slice of entire buffer.
Source§

fn slice_start(&self, start: usize) -> &[u8]

Get immutable slice from start offset to end.
Source§

fn slice_end(&self, end: usize) -> &[u8]

Get immutable slice from beginning to end offset.
Source§

fn slice_both(&self, start: usize, end: usize) -> &[u8]

Get immutable slice from start to end offset.
Source§

fn split(&self, divide: usize) -> (&[u8], &[u8])

Split into two immutable slices at divide point. Returns (left, right).
Source§

fn is_empty(&self) -> bool

Returns true if buffer length is zero.
Source§

impl ByteBufferMut for DynamicByteBuffer

Source§

fn set(&self, at: usize, value: u8)

Set byte at at index to value. Panics if out of bounds.
Source§

fn slice_mut(&self) -> &mut [u8]

Get mutable slice of entire buffer.
Source§

fn slice_start_mut(&self, start: usize) -> &mut [u8]

Get mutable slice from start offset to end.
Source§

fn slice_end_mut(&self, end: usize) -> &mut [u8]

Get mutable slice from beginning to end offset.
Source§

fn slice_both_mut(&self, start: usize, end: usize) -> &mut [u8]

Get mutable slice from start to end offset.
Source§

fn split_mut(&self, divide: usize) -> (&mut [u8], &mut [u8])

Split into two mutable slices at divide point. Returns (left, right).
Source§

fn rebuffer_start(&self, start: usize) -> Self

Create view with start shifted forward by start bytes.
Source§

fn rebuffer_end(&self, end: usize) -> Self

Create view with end at end offset from current start.
Source§

fn rebuffer_both(&self, start: usize, end: usize) -> Self

Create view with both start and end adjusted from current start.
Source§

fn expand_start(&self, size: usize) -> Self

Expand view backward by size bytes (into header space).
Source§

fn expand_end(&self, size: usize) -> Self

Expand view forward by size bytes (into trailer space).
Source§

fn split_buf_start(&self, divide: usize) -> (Self, Self)

Split into two buffer views at divide point. Returns (left, right).
Source§

fn split_buf_end(&self, divide: usize) -> (Self, Self)

Split into two buffer views at len(buffer) - divide point. Returns (left, right).
Source§

fn append(&self, other: &[u8]) -> Self

Append other slice to end. Returns expanded view.
Source§

fn prepend(&self, other: &[u8]) -> Self

Prepend other slice to start. Returns expanded view.
Source§

fn ensure_size(&self, size: usize) -> Self

Ensure buffer has at least size bytes, expanding or shrinking as needed.
Source§

impl Clone for DynamicByteBuffer

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for DynamicByteBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult

Formats the value using the given formatter. Read more
Source§

impl Fill for DynamicByteBuffer

Source§

fn try_fill<R: Rng + ?Sized>(&mut self, rng: &mut R) -> Result<(), Error>

Fill self with random data
Source§

impl<const N: usize> From<&DynamicByteBuffer> for [u8; N]

Source§

fn from(val: &DynamicByteBuffer) -> Self

Converts to this type from the input type.
Source§

impl From<DynamicByteBuffer> for Vec<u8>

Source§

fn from(val: DynamicByteBuffer) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DynamicByteBuffer

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V