[][src]Struct esl01_minibytes::Bytes

pub struct Bytes { /* fields omitted */ }

Immutable bytes with zero-copy slicing and cloning.

Methods

impl Bytes[src]

pub fn slice(&self, range: impl RangeBounds<usize>) -> Self[src]

Returns a slice of self for the provided range. This operation is O(1).

pub fn slice_to_bytes(&self, slice: &[u8]) -> Self[src]

Attempt to convert slice to a zero-copy slice of this Bytes. Copy the slice if zero-copy cannot be done.

This is similar to bytes::Bytes::slice_ref from bytes 0.5.4, but does not panic.

pub fn range_of_slice(&self, slice: &[u8]) -> Option<Range<usize>>[src]

Return a range x so that self[x] matches slice exactly (not only content, but also internal pointer addresses).

Returns None if slice is outside the memory range of this Bytes.

This operation is O(1).

pub fn new() -> Self[src]

Creates an empty Bytes.

pub fn from_static(value: &'static [u8]) -> Self[src]

Creates Bytes from a static slice.

pub fn from_owner(value: impl BytesOwner) -> Self[src]

Creates Bytes from a BytesOwner (for example, Vec<u8>).

pub fn copy_from_slice(data: &[u8]) -> Self[src]

Creates Bytes instance from slice, by copying it.

Trait Implementations

impl AsRef<[u8]> for Bytes[src]

impl Borrow<[u8]> for Bytes[src]

impl Clone for Bytes[src]

impl Debug for Bytes[src]

impl Default for Bytes[src]

impl Deref for Bytes[src]

type Target = [u8]

The resulting type after dereferencing.

impl<'de> Deserialize<'de> for Bytes[src]

impl Eq for Bytes[src]

impl<T: BytesOwner> From<T> for Bytes[src]

impl Hash for Bytes[src]

impl Ord for Bytes[src]

impl<T: AsRef<[u8]>> PartialEq<T> for Bytes[src]

impl<T: AsRef<[u8]>> PartialOrd<T> for Bytes[src]

impl Send for Bytes[src]

impl Serialize for Bytes[src]

impl Sync for Bytes[src]

Auto Trait Implementations

impl !RefUnwindSafe for Bytes

impl Unpin for Bytes

impl !UnwindSafe for Bytes

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.