Struct by::ByteString [−][src]
and Vec<u8>
.
Implementations
impl ByteString
[src]
pub fn new() -> Self
[src]
Creates a new empty ByteString
without allocating any memory.
pub fn from_vec(vec: Vec<u8>) -> Self
[src]
Converts a vector of bytes into a ByteString
without clones or allocation.
pub fn from_slice(slice: &[u8]) -> Self
[src]
Creates a ByteString
from a slice.
pub fn as_vec(&self) -> &Vec<u8>
[src]
Returns a reference to the underlying byte vector.
pub fn as_mut_vec(&mut self) -> &mut Vec<u8>
[src]
Returns a mutable reference to the underlying byte vector.
pub fn into_vec(self) -> Vec<u8>
[src]
Converts self
into a vector without clones or allocation.
pub fn into_boxed_slice(self) -> Box<[u8]>
[src]
Converts self
into a boxed slice, dropping any excess capacity.
pub fn into_boxed_byte_str(self) -> Box<ByteStr>
[src]
Converts self
into a boxed ByteStr
, dropping any excess capacity.
pub fn as_byte_str(&self) -> &ByteStr
[src]
Returns a ByteStr
containing the entiere string.
pub fn as_mut_byte_str(&mut self) -> &mut ByteStr
[src]
Returns a mutable ByteStr
containing the entiere string.
pub fn capacity(&self) -> usize
[src]
Returns the number of byte the string can hold without reallocating.
pub fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more bytes to be inserted into self
.
pub fn reserve_exact(&mut self, additional: usize)
[src]
Reserves the minimum capacity for exactly additional
more elements to be inserted
into self
.
pub fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity of the string as much as possible.
pub fn truncate(&mut self, len: usize)
[src]
Shortens the string, keeping the first len
bytes.
pub fn clear(&mut self)
[src]
Clears the vector, removing all values and keeping the capacity of the string.
pub unsafe fn set_len(&mut self, len: usize)
[src]
Sets the length of a vector.
This will explicitly set the size of the vector, without actually modifying its buffers, so it is up to the caller to ensure that the vector is actually the specified size.
pub fn swap_remove(&mut self, index: usize) -> u8
[src]
Removes an element from the vector and returns it.
The removed element is replaced by the last element of the vector.
This does not preserve ordering, but is O(1).
Panics
Panics if index
is out of bounds.
pub fn insert(&mut self, index: usize, element: u8)
[src]
Inserts an element at position index
within the string, shifting all elements
after it to the right.
Panics
Panics if index
is out of bounds.
pub fn remove(&mut self, index: usize) -> u8
[src]
Removes and returns the element at position index
within the string, shifting
all elements after it to the left.
Panics
Panics if index
is out of bounds.
pub fn retain<F>(&mut self, f: F) where
F: FnMut(u8) -> bool,
[src]
F: FnMut(u8) -> bool,
Retains only the elements specified by the predicate.
pub fn dedup_by_key<F, K>(&mut self, key: F) where
F: FnMut(&mut u8) -> K,
K: PartialEq<K>,
[src]
F: FnMut(&mut u8) -> K,
K: PartialEq<K>,
Removes all but the first of consecutive elements in the string that resolve to the same key.
Similar to Vec::dedup_by_key()
.
pub fn dedup_by<F>(&mut self, same_bucket: F) where
F: FnMut(&mut u8, &mut u8) -> bool,
[src]
F: FnMut(&mut u8, &mut u8) -> bool,
Removes all but the first of consecutive elements in the string satisfying a given equality relation.
Similar to Vec::dedup_by()
.
pub fn dedup(&mut self)
[src]
Removes consecutive repeated elements in the vector.
If the vector is sorted, this removes all duplicates.
pub fn push(&mut self, element: u8)
[src]
Appends an element to the back of the string.
pub fn pop(&mut self) -> Option<u8>
[src]
Removes the last element from a string and returns it, or None
if it is empty.
pub fn push_slice(&mut self, other: &[u8])
[src]
Appends a slice to the back of the string.
pub fn push_byte_str(&mut self, other: &ByteStr)
[src]
Appends a ByteStr
to the back of the string.
pub fn insert_slice(&mut self, index: usize, other: &[u8])
[src]
Inserts a slice at position index
within the string, shifting all elements
after it to the right.
Panics
Panics if index
is out of bounds.
pub fn insert_byte_str(&mut self, index: usize, other: &ByteStr)
[src]
Inserts a ByteStr
at position index
within the string, shifting all elements
after it to the right.
Panics
Panics if index
is out of bounds.
pub fn drain(
&mut self,
start: Option<usize>,
end: Option<usize>
) -> Drain<'_, u8>
[src]
&mut self,
start: Option<usize>,
end: Option<usize>
) -> Drain<'_, u8>
Creates a draining iterator that removes the specified range in the vector and yields the removed items.
pub fn split_off(&mut self, at: usize) -> Self
[src]
Splits the string into two at the given index.
Returns a newly allocated ByteString
. self
contains elements [0, at)
, and
the returned ByteString
contains elements [at, len)
.
Panics
Panics if at > len
.
Methods from Deref<Target = ByteStr>
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 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>ⓘ
[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>ⓘ
[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>ⓘ
[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>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
<M as IntoMatcher>::Matcher: ForwardSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
&'a mut self,
m: M
) -> SplitMut<'a, M::Matcher>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
<M as IntoMatcher>::Matcher: ReverseSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
&'a mut self,
m: M
) -> RSplitMut<'a, M::Matcher>ⓘ where
<M as IntoMatcher>::Matcher: ReverseSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
&'a self,
n: usize,
m: M
) -> SplitN<'a, M::Matcher>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
&'a mut self,
n: usize,
m: M
) -> SplitNMut<'a, M::Matcher>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
&'a self,
n: usize,
m: M
) -> RSplitN<'a, M::Matcher>ⓘ where
<M as IntoMatcher>::Matcher: ReverseSearcher,
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]
&'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;
<M as IntoMatcher>::Matcher: ReverseSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
<M as IntoMatcher>::Matcher: ForwardSearcher,
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]
&'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;
<M as IntoMatcher>::Matcher: ForwardSearcher,
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>ⓘ where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
<M as IntoMatcher>::Matcher: ReverseSearcher,
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]
&'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;
<M as IntoMatcher>::Matcher: ReverseSearcher,
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]
&'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);
<M as IntoMatcher>::Matcher: ForwardSearcher,
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]
&'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);
<M as IntoMatcher>::Matcher: ForwardSearcher,
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]
&'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);
<M as IntoMatcher>::Matcher: ReverseSearcher,
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]
&'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);
<M as IntoMatcher>::Matcher: ReverseSearcher,
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]
<M as IntoMatcher>::Matcher: ForwardSearcher,
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]
<M as IntoMatcher>::Matcher: PrefixMatcher,
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]
<M as IntoMatcher>::Matcher: SufixMatcher,
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]
<M as IntoMatcher>::Matcher: ForwardSearcher,
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]
<M as IntoMatcher>::Matcher: ReverseSearcher,
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]
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 ByteString
[src]
impl AsMut<ByteStr> for ByteString
[src]
impl AsRef<[u8]> for ByteString
[src]
impl AsRef<ByteStr> for ByteString
[src]
impl Borrow<[u8]> for ByteString
[src]
impl Borrow<ByteStr> for ByteString
[src]
impl BorrowMut<[u8]> for ByteString
[src]
fn borrow_mut(&mut self) -> &mut [u8]
[src]
impl BorrowMut<ByteStr> for ByteString
[src]
fn borrow_mut(&mut self) -> &mut ByteStr
[src]
impl Clone for ByteString
[src]
fn clone(&self) -> ByteString
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ByteString
[src]
impl Default for ByteString
[src]
fn default() -> ByteString
[src]
impl Deref for ByteString
[src]
impl DerefMut for ByteString
[src]
impl Eq for ByteString
[src]
impl<'a> From<&'a [u8]> for ByteString
[src]
impl<'a> From<&'a ByteStr> for ByteString
[src]
impl<'a> From<&'a str> for ByteString
[src]
impl From<Box<[u8], Global>> for ByteString
[src]
impl From<Box<ByteStr, Global>> for ByteString
[src]
impl From<Box<str, Global>> for ByteString
[src]
impl From<String> for ByteString
[src]
impl From<Vec<u8, Global>> for ByteString
[src]
impl FromIterator<u8> for ByteString
[src]
fn from_iter<T>(iter: T) -> Self where
T: IntoIterator<Item = u8>,
[src]
T: IntoIterator<Item = u8>,
impl PartialEq<ByteString> for ByteStr
[src]
fn eq(&self, other: &ByteString) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> PartialEq<ByteString> for &'a ByteStr
[src]
fn eq(&self, other: &ByteString) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<ByteString> for ByteString
[src]
fn eq(&self, other: &ByteString) -> bool
[src]
fn ne(&self, other: &ByteString) -> bool
[src]
impl StructuralEq for ByteString
[src]
impl StructuralPartialEq for ByteString
[src]
Auto Trait Implementations
impl RefUnwindSafe for ByteString
impl Send for ByteString
impl Sync for ByteString
impl Unpin for ByteString
impl UnwindSafe for ByteString
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,