Struct byte_str::ByteString
[−]
[src]
pub struct ByteString { /* fields omitted */ }
and Vec<u8>
.
Methods
impl ByteString
[src]
fn new() -> Self
[src]
Creates a new empty ByteString
without allocating any memory.
fn from_vec(vec: Vec<u8>) -> Self
[src]
Converts a vector of bytes into a ByteString
without clones or allocation.
fn from_slice(slice: &[u8]) -> Self
[src]
Creates a ByteString
from a slice.
fn as_vec(&self) -> &Vec<u8>
[src]
Returns a reference to the underlying byte vector.
fn as_mut_vec(&mut self) -> &mut Vec<u8>
[src]
Returns a mutable reference to the underlying byte vector.
fn into_vec(self) -> Vec<u8>
[src]
Converts self
into a vector without clones or allocation.
fn into_boxed_slice(self) -> Box<[u8]>
[src]
Converts self
into a boxed slice, dropping any excess capacity.
fn into_boxed_byte_str(self) -> Box<ByteStr>
[src]
Converts self
into a boxed ByteStr
, dropping any excess capacity.
fn as_byte_str(&self) -> &ByteStr
[src]
Returns a ByteStr
containing the entiere string.
fn as_mut_byte_str(&mut self) -> &mut ByteStr
[src]
Returns a mutable ByteStr
containing the entiere string.
fn capacity(&self) -> usize
[src]
Returns the number of byte the string can hold without reallocating.
fn reserve(&mut self, additional: usize)
[src]
Reserves capacity for at least additional
more bytes to be inserted into self
.
fn reserve_exact(&mut self, additional: usize)
[src]
Reserves the minimum capacity for exactly additional
more elements to be inserted
into self
.
fn shrink_to_fit(&mut self)
[src]
Shrinks the capacity of the string as much as possible.
fn truncate(&mut self, len: usize)
[src]
Shortens the string, keeping the first len
bytes.
fn clear(&mut self)
[src]
Clears the vector, removing all values and keeping the capacity of the string.
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.
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.
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.
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.
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.
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()
.
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()
.
fn dedup(&mut self)
[src]
Removes consecutive repeated elements in the vector.
If the vector is sorted, this removes all duplicates.
fn push(&mut self, element: u8)
[src]
Appends an element to the back of the string.
fn pop(&mut self) -> Option<u8>
[src]
Removes the last element from a string and returns it, or None
if it is empty.
fn push_slice(&mut self, other: &[u8])
[src]
Appends a slice to the back of the string.
fn push_byte_str(&mut self, other: &ByteStr)
[src]
Appends a ByteStr
to the back of the string.
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.
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.
fn drain(&mut self, start: Option<usize>, end: Option<usize>) -> Drain<u8>
[src]
Creates a draining iterator that removes the specified range in the vector and yields the removed items.
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>
fn as_slice(&self) -> &[u8]
[src]
Converts self
into a byte slice.
fn as_mut_slice(&mut self) -> &mut [u8]
[src]
Converts self
into a mutable byte slice.
fn to_vec(&self) -> Vec<u8>
[src]
Copies the self
into a Vec
.
fn to_byte_string(&self) -> ByteString
[src]
Copies the self
into a ByteString
.
fn len(&self) -> usize
[src]
Returns the length of self
.
fn is_empty(&self) -> bool
[src]
Returns true
if the length of self
is zero.
fn as_ptr(&self) -> *const u8
[src]
Converts self
into a raw pointer that points to the first byte of the string.
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.
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.
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.
fn first(&self) -> Option<&u8>
[src]
Returns a reference to the first byte of the string, or None
if it is empty.
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.
fn last(&self) -> Option<&u8>
[src]
Returns a reference to the last byte of the string, or None
if it is empty.
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.
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.
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.
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.
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.
fn iter<'a>(&'a self) -> Iter<'a, u8>
[src]
Returns an iterator over the string.
fn iter_mut<'a>(&'a mut self) -> IterMut<'a, u8>
[src]
Returns an iterator that allows modifying each value.
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()
.
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()
.
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()
.
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
.
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
.
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.
fn split_mut<'a, M: IntoMatcher>(&'a mut self, m: M) -> SplitMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
<M as IntoMatcher>::Matcher: ForwardSearcher,
Returns an iterator over mutable substrings of this string, separated by a matcher.
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.
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.
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.
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.
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.
fn rsplitn_mut<'a, M: IntoMatcher>(
&'a mut self,
n: usize,
m: M
) -> RSplitNMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
&'a mut self,
n: usize,
m: M
) -> RSplitNMut<'a, M::Matcher> where
<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.
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.
fn matches_mut<'a, M: IntoMatcher>(
&'a mut self,
m: M
) -> MatchesMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
&'a mut self,
m: M
) -> MatchesMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ForwardSearcher,
Returns an iterator over the mutable disjoint matches within the given string.
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.
fn rmatches_mut<'a, M: IntoMatcher>(
&'a mut self,
m: M
) -> RMatchesMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
&'a mut self,
m: M
) -> RMatchesMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ReverseSearcher,
Returns an iterator over the mutable disjoint matches within the given string, yielded in reverse order.
fn match_indices<'a, M: IntoMatcher>(
&'a self,
m: M
) -> MatchIndices<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
&'a self,
m: M
) -> MatchIndices<'a, M::Matcher> where
<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.
fn match_indices_mut<'a, M: IntoMatcher>(
&'a mut self,
m: M
) -> MatchIndicesMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ForwardSearcher,
[src]
&'a mut self,
m: M
) -> MatchIndicesMut<'a, M::Matcher> where
<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.
fn rmatch_indices<'a, M: IntoMatcher>(
&'a self,
m: M
) -> RMatchIndices<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
&'a self,
m: M
) -> RMatchIndices<'a, M::Matcher> where
<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.
fn rmatch_indices_mut<'a, M: IntoMatcher>(
&'a mut self,
m: M
) -> RMatchIndicesMut<'a, M::Matcher> where
<M as IntoMatcher>::Matcher: ReverseSearcher,
[src]
&'a mut self,
m: M
) -> RMatchIndicesMut<'a, M::Matcher> where
<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.
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.
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.
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.
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.
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.
fn swap(&mut self, a: usize, b: usize)
[src]
fn reverse(&mut self)
[src]
Reverses the order of bytes in the slice.
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
.
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 Clone for ByteString
[src]
fn clone(&self) -> ByteString
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for ByteString
[src]
fn default() -> ByteString
[src]
Returns the "default value" for a type. Read more
impl PartialEq for ByteString
[src]
fn eq(&self, __arg_0: &ByteString) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &ByteString) -> bool
[src]
This method tests for !=
.
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<Vec<u8>> for ByteString
[src]
impl From<Box<[u8]>> for ByteString
[src]
impl From<Box<ByteStr>> for ByteString
[src]
impl From<Box<str>> for ByteString
[src]
impl From<String> 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>,
Creates a value from an iterator. Read more
impl Debug for ByteString
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
Formats the value using the given formatter.
impl Deref for ByteString
[src]
type Target = ByteStr
The resulting type after dereferencing.
fn deref(&self) -> &ByteStr
[src]
Dereferences the value.
impl DerefMut for ByteString
[src]
impl Borrow<ByteStr> for ByteString
[src]
impl BorrowMut<ByteStr> for ByteString
[src]
fn borrow_mut(&mut self) -> &mut ByteStr
[src]
Mutably borrows from an owned value. Read more