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 &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [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

Determine if each yielded value is adjacent in memory.

Required Methods

Get a ptr to the current start of the iterator.

Get a slice to the current start of the iterator.

Get the total number of elements in the underlying slice.

Get the current index of the iterator in the slice.

Set the current index of the iterator in the slice.

Safety

Safe if index <= self.length().

Get the current number of values returned by the iterator.

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().

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.

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.

Advance the internal slice by N elements.

Safety

As long as the iterator is at least N elements, this is safe.

Provided Methods

Determine if the iterator is contiguous.

Check if the next element is a given value.

Check if the next element is a given value without case sensitivity.

Skip zeros from the start of the iterator

Advance the internal slice by 1 element.

Safety

Safe as long as the iterator is not empty.

Implementors