pub struct ZeroCopyBuffer { /* private fields */ }Expand description
Zero-copy buffer for efficient data transfer
Uses Bytes internally which provides reference-counted, immutable byte buffers
that can be sliced without copying.
Implementations§
Source§impl ZeroCopyBuffer
impl ZeroCopyBuffer
Sourcepub fn from_static(bytes: &'static [u8]) -> Self
pub fn from_static(bytes: &'static [u8]) -> Self
Create from a static byte slice
Sourcepub fn slice(&self, range: Range<usize>) -> Self
pub fn slice(&self, range: Range<usize>) -> Self
Create a zero-copy slice of this buffer
This operation is very efficient as it only increments a reference count and doesn’t copy any data.
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Get the underlying Bytes
Sourcepub fn split_at(&self, at: usize) -> (Self, Self)
pub fn split_at(&self, at: usize) -> (Self, Self)
Split the buffer at an index
Returns two zero-copy buffers: [0, at) and [at, len). This is a zero-copy operation.
Sourcepub fn split_from(&self, at: usize) -> Self
pub fn split_from(&self, at: usize) -> Self
Split off the last n bytes
Trait Implementations§
Source§impl AsRef<[u8]> for ZeroCopyBuffer
impl AsRef<[u8]> for ZeroCopyBuffer
Source§impl Clone for ZeroCopyBuffer
impl Clone for ZeroCopyBuffer
Source§fn clone(&self) -> ZeroCopyBuffer
fn clone(&self) -> ZeroCopyBuffer
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 moreSource§impl Debug for ZeroCopyBuffer
impl Debug for ZeroCopyBuffer
Source§impl From<&'static [u8]> for ZeroCopyBuffer
impl From<&'static [u8]> for ZeroCopyBuffer
Source§impl From<Bytes> for ZeroCopyBuffer
impl From<Bytes> for ZeroCopyBuffer
Auto Trait Implementations§
impl !Freeze for ZeroCopyBuffer
impl RefUnwindSafe for ZeroCopyBuffer
impl Send for ZeroCopyBuffer
impl Sync for ZeroCopyBuffer
impl Unpin for ZeroCopyBuffer
impl UnwindSafe for ZeroCopyBuffer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)