Trait lexical_util::iterator::BytesIter
source · [−]pub trait BytesIter<'a>: Iterator<Item = &'a u8> {
const IS_CONTIGUOUS: bool;
Show 18 methods
fn as_ptr(&self) -> *const u8;
fn as_slice(&self) -> &'a [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
;
fn length(&self) -> usize;
fn cursor(&self) -> usize;
unsafe fn set_cursor(&mut self, index: usize);
fn current_count(&self) -> usize;
fn is_consumed(&mut self) -> bool;
fn is_done(&self) -> bool;
unsafe fn peek_unchecked(&mut self) -> Self::Item;
fn peek(&mut self) -> Option<Self::Item>;
unsafe fn read_unchecked<V>(&self) -> V;
fn read<V>(&self) -> Option<V>;
unsafe fn step_by_unchecked(&mut self, count: usize);
fn is_contiguous(&self) -> bool { ... }
fn peek_is(&mut self, value: u8) -> bool { ... }
fn case_insensitive_peek_is(&mut self, value: u8) -> bool { ... }
fn skip_zeros(&mut self) -> usize { ... }
unsafe fn step_unchecked(&mut self) { ... }
}
Expand description
Iterator over a contiguous block of bytes.
This allows us to convert to-and-from-slices, raw pointers, and peek/query the data from either end cheaply.
A default implementation is provided for slice iterators.
This trait should never return null
from as_ptr
, or be
implemented for non-contiguous data.
Required Associated Constants
const IS_CONTIGUOUS: bool
const IS_CONTIGUOUS: bool
Determine if each yielded value is adjacent in memory.
Required Methods
Get a slice to the current start of the iterator.
unsafe fn set_cursor(&mut self, index: usize)
unsafe fn set_cursor(&mut self, index: usize)
fn current_count(&self) -> usize
fn current_count(&self) -> usize
Get the current number of values returned by the iterator.
fn is_consumed(&mut self) -> bool
fn is_consumed(&mut self) -> bool
Get if the iterator cannot return any more elements.
This may advance the internal iterator state, but not modify the next returned value.
Get if the buffer underlying the iterator is empty.
This might not be the same thing as is_consumed
: is_consumed
checks if any more elements may be returned, which may require
peeking the next value. Consumed merely checks if the
iterator has an empty slice. It is effectively a cheaper,
but weaker variant of is_consumed()
.
unsafe fn peek_unchecked(&mut self) -> Self::Item
unsafe fn peek_unchecked(&mut self) -> Self::Item
Peek the next value of the iterator, without checking bounds.
Safety
Safe as long as there is at least a single valid value left in the iterator. Note that the behavior of this may lead to out-of-bounds access (for contiguous iterators) or panics (for non-contiguous iterators).
Peek the next value of the iterator, without consuming it.
unsafe fn read_unchecked<V>(&self) -> V
unsafe fn read_unchecked<V>(&self) -> V
Read a value of a difference type from the iterator. This advances the internal state of the iterator.
Safety
Safe as long as the number of the buffer is contains as least as many bytes as the size of V.
Try to read a value of a different type from the iterator. This advances the internal state of the iterator.
unsafe fn step_by_unchecked(&mut self, count: usize)
unsafe fn step_by_unchecked(&mut self, count: usize)
Advance the internal slice by N
elements.
Safety
As long as the iterator is at least N
elements, this
is safe.
Provided Methods
fn is_contiguous(&self) -> bool
fn is_contiguous(&self) -> bool
Determine if the iterator is contiguous.
fn case_insensitive_peek_is(&mut self, value: u8) -> bool
fn case_insensitive_peek_is(&mut self, value: u8) -> bool
Check if the next element is a given value without case sensitivity.
fn skip_zeros(&mut self) -> usize
fn skip_zeros(&mut self) -> usize
Skip zeros from the start of the iterator