pub struct SharedBytes { /* private fields */ }Expand description
SharedBytes is a reference-counted, sliceable byte buffer.
It holds an Arc<[u8]> plus a (start, len) view, allowing cheap
zero-copy slicing that still dereferences to &[u8].
Implementations§
Sourcepub fn from_vec(vec: Vec<u8>) -> Self
pub fn from_vec(vec: Vec<u8>) -> Self
Creates a new SharedBytes from a Vec by taking ownership.
Sourcepub fn from_arc(data: Arc<[u8]>) -> Self
pub fn from_arc(data: Arc<[u8]>) -> Self
Creates a new SharedBytes from an Arc<u8> covering the full slice.
Sourcepub fn slice(&self, start: usize, len: usize) -> Self
pub fn slice(&self, start: usize, len: usize) -> Self
Creates a sub-slice view into the current buffer without copying. Panics if the requested range is out of bounds.
Sourcepub fn into_full_arc(self) -> Option<Arc<[u8]>>
pub fn into_full_arc(self) -> Option<Arc<[u8]>>
Returns the inner Arc if the view covers the whole buffer.
Trait Implementations§
Source§fn clone(&self) -> SharedBytes
fn clone(&self) -> SharedBytes
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
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