Struct by::ByteStr[][src]

pub struct ByteStr { /* fields omitted */ }

Borrowed reference to a byte string. It provides similar functionality as str and [u8].

Implementations

impl ByteStr[src]

pub fn empty<'a>() -> &'a Self[src]

Creates an empty ByteStr.

pub fn empty_mut<'a>() -> &'a mut Self[src]

Creates an empty mutable ByteStr.

pub fn from_slice(bytes: &[u8]) -> &Self[src]

Creates a ByteStr from a byte slice.

pub fn from_slice_mut(bytes: &mut [u8]) -> &mut Self[src]

Create a mutable ByteStr from a byte slice.

pub unsafe fn from_raw_parts<'a>(ptr: *const u8, len: usize) -> &'a Self[src]

Forms a ByteStr from a pointer and a length.

pub unsafe fn from_raw_parts_mut<'a>(ptr: *mut u8, len: usize) -> &'a mut Self[src]

Forms a mutable ByteStr from a pointer and a length.

pub fn as_slice(&self) -> &[u8][src]

Converts self into a byte slice.

pub fn as_mut_slice(&mut self) -> &mut [u8][src]

Converts self into a mutable byte slice.

pub fn to_vec(&self) -> Vec<u8>[src]

Copies the self into a Vec.

pub fn to_byte_string(&self) -> ByteString[src]

Copies the self into a ByteString.

pub fn into_boxed_slice(self: Box<Self>) -> Box<[u8]>[src]

Converts self into a boxed slice without clones or allocation.

pub fn into_vec(self: Box<Self>) -> Vec<u8>[src]

Converts self into a vector without clones or allocation.

pub fn into_byte_string(self: Box<Self>) -> ByteString[src]

Converts self into a ByteString without clones or allocation.

pub fn len(&self) -> usize[src]

Returns the length of self.

pub fn is_empty(&self) -> bool[src]

Returns true if the length of self is zero.

pub fn as_ptr(&self) -> *const u8[src]

Converts self into a raw pointer that points to the first byte of the string.

pub fn as_mut_ptr(&mut self) -> *mut u8[src]

Converts self into a mutable raw pointer that points to the first byte of the string.

pub fn get(&self, index: usize) -> Option<&u8>[src]

Returns a reference to an element of the slice, or None if the index is out of bounds.

pub fn get_mut(&mut self, index: usize) -> Option<&mut u8>[src]

Returns a mutable reference to an element of the slice, or None if the index is out of bounds.

pub fn first(&self) -> Option<&u8>[src]

Returns a reference to the first byte of the string, or None if it is empty.

pub fn first_mut(&mut self) -> Option<&mut u8>[src]

Returns a mutable reference to the first byte of the string, or None if it is empty.

pub fn last(&self) -> Option<&u8>[src]

Returns a reference to the last byte of the string, or None if it is empty.

pub fn last_mut(&mut self) -> Option<&mut u8>[src]

Returns a mutable reference to the last byte of the string, or None if it is empty.

pub fn split_first(&self) -> Option<(&u8, &ByteStr)>[src]

Returns the first and all the rest of the bytes of the slice, or None if it is empty.

pub fn split_first_mut(&mut self) -> Option<(&mut u8, &mut ByteStr)>[src]

Returns the first and all the rest of the bytes of the slice, or None if it is empty.

pub fn split_last(&self) -> Option<(&u8, &ByteStr)>[src]

Returns the last and all the rest of the bytes of the slice, or None if it is empty.

pub fn split_last_mut(&mut self) -> Option<(&mut u8, &mut ByteStr)>[src]

Returns the last and all the rest of the bytes of the slice, or None if it is empty.

pub fn iter<'a>(&'a self) -> Iter<'a, u8>[src]

Returns an iterator over the string.

pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, u8>[src]

Returns an iterator that allows modifying each value.

pub fn windows<'a>(&'a self, size: usize) -> Windows<'a>

Notable traits for Windows<'a>

impl<'a> Iterator for Windows<'a> type Item = &'a ByteStr;
[src]

Returns an iterator over all contiguous windows of length size. The windows overlap. If the string is shorter than size, the iterator returns no values.

Similar to slice::windows().

pub fn chunks<'a>(&'a self, size: usize) -> Chunks<'a>

Notable traits for Chunks<'a>

impl<'a> Iterator for Chunks<'a> type Item = &'a ByteStr;
[src]

Returns an iterator over size bytes of the string at a time. The chunks do not overlap. If size does not divide the length of the slice, then the last chunk will not have length size.

Similar to slice::chunks().

pub fn chunks_mut<'a>(&'a mut self, size: usize) -> ChunksMut<'a>

Notable traits for ChunksMut<'a>

impl<'a> Iterator for ChunksMut<'a> type Item = &'a ByteStr;
[src]

Returns an iterator over size elements of the slice at a time. The chunks are mutable strings and do not overlap. If size does not divide the length of the slice, then the last chunk will not have length size.

Similar to slice::chunks_mut().

pub fn split_at(&self, mid: usize) -> (&ByteStr, &ByteStr)[src]

Divides one string into two at an index.

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

Similar to slice::split_at().

Panics

Panics if mid > len.

pub fn split_at_mut(&mut self, mid: usize) -> (&mut ByteStr, &mut ByteStr)[src]

Divides one &mut string into two at an index.

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

Similar to slice::split_at_mut().

Panics

Panics if mid > len.

pub fn split<'a, M: IntoMatcher>(&'a self, m: M) -> Split<'a, M::Matcher>

Notable traits for Split<'a, M>

impl<'a, M: ForwardSearcher> Iterator for Split<'a, M> type Item = &'a ByteStr;
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over substrings of this string, separated by a matcher.

pub fn split_mut<'a, M: IntoMatcher>(
    &'a mut self,
    m: M
) -> SplitMut<'a, M::Matcher>

Notable traits for SplitMut<'a, M>

impl<'a, M: ForwardSearcher> Iterator for SplitMut<'a, M> type Item = &'a mut ByteStr;
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over mutable substrings of this string, separated by a matcher.

pub fn rsplit<'a, M: IntoMatcher>(&'a self, m: M) -> RSplit<'a, M::Matcher>

Notable traits for RSplit<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RSplit<'a, M> type Item = &'a ByteStr;
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over substrings of this string, separated by a matcher, starting at the end of the slice and working backwards.

pub fn rsplit_mut<'a, M: IntoMatcher>(
    &'a mut self,
    m: M
) -> RSplitMut<'a, M::Matcher>

Notable traits for RSplitMut<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RSplitMut<'a, M> type Item = &'a mut ByteStr;
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over mutable substrings of this string, separated by a matcher, starting at the end of the slice and working backwards.

pub fn splitn<'a, M: IntoMatcher>(
    &'a self,
    n: usize,
    m: M
) -> SplitN<'a, M::Matcher>

Notable traits for SplitN<'a, M>

impl<'a, M: ForwardSearcher> Iterator for SplitN<'a, M> type Item = &'a ByteStr;
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over substrings of this string, separated by a matcher, returning at most n items.

If n substrings are returned, the last substring will contain the remainder of the string.

pub fn splitn_mut<'a, M: IntoMatcher>(
    &'a mut self,
    n: usize,
    m: M
) -> SplitNMut<'a, M::Matcher>

Notable traits for SplitNMut<'a, M>

impl<'a, M: ForwardSearcher> Iterator for SplitNMut<'a, M> type Item = &'a mut ByteStr;
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over mutable substrings of this string, separated by a matcher, returning at most n items.

If n substrings are returned, the last substring will contain the remainder of the string.

pub fn rsplitn<'a, M: IntoMatcher>(
    &'a self,
    n: usize,
    m: M
) -> RSplitN<'a, M::Matcher>

Notable traits for RSplitN<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RSplitN<'a, M> type Item = &'a ByteStr;
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over substrings of this string, separated by a matcher and stating from the end of the string, returning at most n items.

If n substrings are returned, the last substring will contain the remainder of the string.

pub fn rsplitn_mut<'a, M: IntoMatcher>(
    &'a mut self,
    n: usize,
    m: M
) -> RSplitNMut<'a, M::Matcher>

Notable traits for RSplitNMut<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RSplitNMut<'a, M> type Item = &'a mut ByteStr;
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over mutable substrings of this string, separated by a matcher and stating from the end of the string, returning at most n items.

If n substrings are returned, the last substring will contain the remainder of the string.

pub fn matches<'a, M: IntoMatcher>(&'a self, m: M) -> Matches<'a, M::Matcher>

Notable traits for Matches<'a, M>

impl<'a, M: ForwardSearcher> Iterator for Matches<'a, M> type Item = &'a ByteStr;
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over the disjoint matches within the given string.

pub fn matches_mut<'a, M: IntoMatcher>(
    &'a mut self,
    m: M
) -> MatchesMut<'a, M::Matcher>

Notable traits for MatchesMut<'a, M>

impl<'a, M: ForwardSearcher> Iterator for MatchesMut<'a, M> type Item = &'a mut ByteStr;
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over the mutable disjoint matches within the given string.

pub fn rmatches<'a, M: IntoMatcher>(&'a self, m: M) -> RMatches<'a, M::Matcher>

Notable traits for RMatches<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RMatches<'a, M> type Item = &'a ByteStr;
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over the disjoint matches within the given string, yielded in reverse order.

pub fn rmatches_mut<'a, M: IntoMatcher>(
    &'a mut self,
    m: M
) -> RMatchesMut<'a, M::Matcher>

Notable traits for RMatchesMut<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RMatchesMut<'a, M> type Item = &'a mut ByteStr;
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over the mutable disjoint matches within the given string, yielded in reverse order.

pub fn match_indices<'a, M: IntoMatcher>(
    &'a self,
    m: M
) -> MatchIndices<'a, M::Matcher>

Notable traits for MatchIndices<'a, M>

impl<'a, M: ForwardSearcher> Iterator for MatchIndices<'a, M> type Item = (usize, &'a ByteStr);
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over the disjoint matches within the given string, as well as the index that the match starts at.

pub fn match_indices_mut<'a, M: IntoMatcher>(
    &'a mut self,
    m: M
) -> MatchIndicesMut<'a, M::Matcher>

Notable traits for MatchIndicesMut<'a, M>

impl<'a, M: ForwardSearcher> Iterator for MatchIndicesMut<'a, M> type Item = (usize, &'a mut ByteStr);
where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns an iterator over the mutable disjoint matches within the given string, as well as the index that the match starts at.

pub fn rmatch_indices<'a, M: IntoMatcher>(
    &'a self,
    m: M
) -> RMatchIndices<'a, M::Matcher>

Notable traits for RMatchIndices<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RMatchIndices<'a, M> type Item = (usize, &'a ByteStr);
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over the disjoint matches within the given string, yielded in reverse order, as well as the index that the match starts at.

pub fn rmatch_indices_mut<'a, M: IntoMatcher>(
    &'a mut self,
    m: M
) -> RMatchIndicesMut<'a, M::Matcher>

Notable traits for RMatchIndicesMut<'a, M>

impl<'a, M: ReverseSearcher> Iterator for RMatchIndicesMut<'a, M> type Item = (usize, &'a mut ByteStr);
where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns an iterator over the mutable disjoint matches within the given string, yielded in reverse order, as well as the index that the match starts at.

pub fn contains<M: IntoMatcher>(&self, m: M) -> bool where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns true if the string contains a substring that matches the given matcher.

pub fn starts_with<M: IntoMatcher>(&self, m: M) -> bool where
    <M as IntoMatcher>::Matcher: PrefixMatcher
[src]

Returns true if the string beginning a matches the given matcher.

pub fn ends_with<M: IntoMatcher>(&self, m: M) -> bool where
    <M as IntoMatcher>::Matcher: SufixMatcher
[src]

Returns true if the string ending a matches the given matcher.

pub fn find<M: IntoMatcher>(&self, m: M) -> Option<usize> where
    <M as IntoMatcher>::Matcher: ForwardSearcher
[src]

Returns the byte index of the first character of self that matches the matcher or None it it doesn’t match.

pub fn rfind<M: IntoMatcher>(&self, m: M) -> Option<usize> where
    <M as IntoMatcher>::Matcher: ReverseSearcher
[src]

Returns the byte index of the last character of self that matches the matcher or None it it doesn’t match.

pub fn swap(&mut self, a: usize, b: usize)[src]

Swaps two bytes in the string, indexed by a and b.

Panics

Panics if a or b are out of bounds.

pub fn reverse(&mut self)[src]

Reverses the order of bytes in the slice.

pub fn copy_from_slice(&mut self, src: &[u8])[src]

Copies all elements from src into self, using a memcpy.

The length of src must be the same as self.

pub fn copy_from_byte_str(&mut self, src: &ByteStr)[src]

Copies all elements from src into self, using a memcpy.

The length of src must be the same as self.

Trait Implementations

impl AsMut<[u8]> for ByteStr[src]

impl AsMut<ByteStr> for ByteStr[src]

impl AsMut<ByteStr> for ByteString[src]

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

impl AsRef<ByteStr> for ByteStr[src]

impl AsRef<ByteStr> for ByteString[src]

impl Borrow<ByteStr> for ByteString[src]

impl BorrowMut<ByteStr> for ByteString[src]

impl Debug for ByteStr[src]

impl<'a> Default for &'a ByteStr[src]

impl<'a> Default for &'a mut ByteStr[src]

impl Eq for ByteStr[src]

impl<'a> From<&'a ByteStr> for ByteString[src]

impl Index<Range<usize>> for ByteStr[src]

type Output = ByteStr

The returned type after indexing.

impl Index<RangeFrom<usize>> for ByteStr[src]

type Output = ByteStr

The returned type after indexing.

impl Index<RangeFull> for ByteStr[src]

type Output = ByteStr

The returned type after indexing.

impl Index<RangeTo<usize>> for ByteStr[src]

type Output = ByteStr

The returned type after indexing.

impl Index<usize> for ByteStr[src]

type Output = u8

The returned type after indexing.

impl IndexMut<Range<usize>> for ByteStr[src]

impl IndexMut<RangeFrom<usize>> for ByteStr[src]

impl IndexMut<RangeFull> for ByteStr[src]

impl IndexMut<RangeTo<usize>> for ByteStr[src]

impl IndexMut<usize> for ByteStr[src]

impl<'a> IntoIterator for &'a ByteStr[src]

type Item = &'a u8

The type of the elements being iterated over.

type IntoIter = Iter<'a, u8>

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut ByteStr[src]

type Item = &'a mut u8

The type of the elements being iterated over.

type IntoIter = IterMut<'a, u8>

Which kind of iterator are we turning this into?

impl<'a, T: ?Sized> PartialEq<&'a T> for ByteStr where
    ByteStr: PartialEq<T>, 
[src]

impl PartialEq<[u8; 0]> for ByteStr[src]

impl<'a> PartialEq<[u8; 0]> for &'a ByteStr[src]

impl PartialEq<[u8; 1]> for ByteStr[src]

impl<'a> PartialEq<[u8; 1]> for &'a ByteStr[src]

impl PartialEq<[u8; 10]> for ByteStr[src]

impl<'a> PartialEq<[u8; 10]> for &'a ByteStr[src]

impl PartialEq<[u8; 11]> for ByteStr[src]

impl<'a> PartialEq<[u8; 11]> for &'a ByteStr[src]

impl PartialEq<[u8; 12]> for ByteStr[src]

impl<'a> PartialEq<[u8; 12]> for &'a ByteStr[src]

impl PartialEq<[u8; 13]> for ByteStr[src]

impl<'a> PartialEq<[u8; 13]> for &'a ByteStr[src]

impl PartialEq<[u8; 14]> for ByteStr[src]

impl<'a> PartialEq<[u8; 14]> for &'a ByteStr[src]

impl PartialEq<[u8; 15]> for ByteStr[src]

impl<'a> PartialEq<[u8; 15]> for &'a ByteStr[src]

impl PartialEq<[u8; 16]> for ByteStr[src]

impl<'a> PartialEq<[u8; 16]> for &'a ByteStr[src]

impl PartialEq<[u8; 17]> for ByteStr[src]

impl<'a> PartialEq<[u8; 17]> for &'a ByteStr[src]

impl PartialEq<[u8; 18]> for ByteStr[src]

impl<'a> PartialEq<[u8; 18]> for &'a ByteStr[src]

impl PartialEq<[u8; 19]> for ByteStr[src]

impl<'a> PartialEq<[u8; 19]> for &'a ByteStr[src]

impl PartialEq<[u8; 2]> for ByteStr[src]

impl<'a> PartialEq<[u8; 2]> for &'a ByteStr[src]

impl PartialEq<[u8; 20]> for ByteStr[src]

impl<'a> PartialEq<[u8; 20]> for &'a ByteStr[src]

impl PartialEq<[u8; 21]> for ByteStr[src]

impl<'a> PartialEq<[u8; 21]> for &'a ByteStr[src]

impl PartialEq<[u8; 22]> for ByteStr[src]

impl<'a> PartialEq<[u8; 22]> for &'a ByteStr[src]

impl PartialEq<[u8; 23]> for ByteStr[src]

impl<'a> PartialEq<[u8; 23]> for &'a ByteStr[src]

impl PartialEq<[u8; 24]> for ByteStr[src]

impl<'a> PartialEq<[u8; 24]> for &'a ByteStr[src]

impl PartialEq<[u8; 25]> for ByteStr[src]

impl<'a> PartialEq<[u8; 25]> for &'a ByteStr[src]

impl PartialEq<[u8; 26]> for ByteStr[src]

impl<'a> PartialEq<[u8; 26]> for &'a ByteStr[src]

impl PartialEq<[u8; 27]> for ByteStr[src]

impl<'a> PartialEq<[u8; 27]> for &'a ByteStr[src]

impl PartialEq<[u8; 28]> for ByteStr[src]

impl<'a> PartialEq<[u8; 28]> for &'a ByteStr[src]

impl PartialEq<[u8; 29]> for ByteStr[src]

impl<'a> PartialEq<[u8; 29]> for &'a ByteStr[src]

impl PartialEq<[u8; 3]> for ByteStr[src]

impl<'a> PartialEq<[u8; 3]> for &'a ByteStr[src]

impl PartialEq<[u8; 30]> for ByteStr[src]

impl<'a> PartialEq<[u8; 30]> for &'a ByteStr[src]

impl PartialEq<[u8; 31]> for ByteStr[src]

impl<'a> PartialEq<[u8; 31]> for &'a ByteStr[src]

impl PartialEq<[u8; 32]> for ByteStr[src]

impl<'a> PartialEq<[u8; 32]> for &'a ByteStr[src]

impl PartialEq<[u8; 4]> for ByteStr[src]

impl<'a> PartialEq<[u8; 4]> for &'a ByteStr[src]

impl PartialEq<[u8; 5]> for ByteStr[src]

impl<'a> PartialEq<[u8; 5]> for &'a ByteStr[src]

impl PartialEq<[u8; 6]> for ByteStr[src]

impl<'a> PartialEq<[u8; 6]> for &'a ByteStr[src]

impl PartialEq<[u8; 7]> for ByteStr[src]

impl<'a> PartialEq<[u8; 7]> for &'a ByteStr[src]

impl PartialEq<[u8; 8]> for ByteStr[src]

impl<'a> PartialEq<[u8; 8]> for &'a ByteStr[src]

impl PartialEq<[u8; 9]> for ByteStr[src]

impl<'a> PartialEq<[u8; 9]> for &'a ByteStr[src]

impl PartialEq<[u8]> for ByteStr[src]

impl<'a> PartialEq<[u8]> for &'a ByteStr[src]

impl PartialEq<ByteStr> for ByteStr[src]

impl<'a> PartialEq<ByteStr> for &'a ByteStr[src]

impl PartialEq<ByteString> for ByteStr[src]

impl<'a> PartialEq<ByteString> for &'a ByteStr[src]

impl<'b> PartialEq<Cow<'b, ByteStr>> for ByteStr[src]

impl<'a, 'b> PartialEq<Cow<'b, ByteStr>> for &'a ByteStr[src]

impl StructuralEq for ByteStr[src]

impl StructuralPartialEq for ByteStr[src]

impl ToOwned for ByteStr[src]

type Owned = ByteString

The resulting type after obtaining ownership.

Auto Trait Implementations

impl RefUnwindSafe for ByteStr

impl Send for ByteStr

impl !Sized for ByteStr

impl Sync for ByteStr

impl Unpin for ByteStr

impl UnwindSafe for ByteStr

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]