Trait bytes::str::ByteStr [] [src]

pub trait ByteStr: Clone + Sized + Send + Sync + Any + ToBytes + Index<usize, Output = u8> + 'static {
    type Buf: Buf + 'static;
    fn buf(&self) -> Self::Buf;
    fn concat<B: ByteStr + 'static>(&self, other: &B) -> Bytes;
    fn len(&self) -> usize;
    fn slice(&self, begin: usize, end: usize) -> Bytes;

    fn is_empty(&self) -> bool { ... }
    fn slice_from(&self, begin: usize) -> Bytes { ... }
    fn slice_to(&self, end: usize) -> Bytes { ... }
    fn split_at(&self, mid: usize) -> (Bytes, Bytes) { ... }
}

An immutable sequence of bytes. Operations will not mutate the original value. Since only immutable access is permitted, operations do not require copying (though, sometimes copying will happen as an optimization).

Associated Types

Required Methods

Returns a read-only Buf for accessing the byte contents of the ByteStr.

Returns a new Bytes value representing the concatenation of self with the given Bytes.

Returns the number of bytes in the ByteStr

Returns a new ByteStr value containing the byte range between begin (inclusive) and end (exclusive)

Provided Methods

Returns true if the length of the ByteStr is 0

Returns a new ByteStr value containing the byte range starting from begin (inclusive) to the end of the byte str.

Equivalent to bytes.slice(begin, bytes.len())

Returns a new ByteStr value containing the byte range from the start up to end (exclusive).

Equivalent to bytes.slice(0, end)

Divides the value into two Bytes at the given index.

The first will contain all bytes from [0, mid] (excluding the index mid itself) and the second will contain all indices from [mid, len) (excluding the index len itself).

Panics if mid > len.

Implementors