[−][src]Struct bytes::buf::Iter
Iterator over the bytes contained by the buffer.
This struct is created by the iter
method on Buf
.
Examples
Basic usage:
use bytes::{Buf, IntoBuf, Bytes}; let buf = Bytes::from(&b"abc"[..]).into_buf(); let mut iter = buf.iter(); assert_eq!(iter.next(), Some(b'a')); assert_eq!(iter.next(), Some(b'b')); assert_eq!(iter.next(), Some(b'c')); assert_eq!(iter.next(), None);
Methods
impl<T> Iter<T>
[src][−]
pub fn into_inner(self) -> T
[src][−]
Consumes this Iter
, returning the underlying value.
Examples
use bytes::{Buf, IntoBuf, Bytes}; let buf = Bytes::from(&b"abc"[..]).into_buf(); let mut iter = buf.iter(); assert_eq!(iter.next(), Some(b'a')); let buf = iter.into_inner(); assert_eq!(2, buf.remaining());
pub fn get_ref(&self) -> &T
[src][−]
Gets a reference to the underlying Buf
.
It is inadvisable to directly read from the underlying Buf
.
Examples
use bytes::{Buf, IntoBuf, Bytes}; let buf = Bytes::from(&b"abc"[..]).into_buf(); let mut iter = buf.iter(); assert_eq!(iter.next(), Some(b'a')); assert_eq!(2, iter.get_ref().remaining());
pub fn get_mut(&mut self) -> &mut T
[src][−]
Gets a mutable reference to the underlying Buf
.
It is inadvisable to directly read from the underlying Buf
.
Examples
use bytes::{Buf, IntoBuf, BytesMut}; let buf = BytesMut::from(&b"abc"[..]).into_buf(); let mut iter = buf.iter(); assert_eq!(iter.next(), Some(b'a')); iter.get_mut().set_position(0); assert_eq!(iter.next(), Some(b'a'));
Trait Implementations
impl<T: Buf> Iterator for Iter<T>
[src][+]
impl<T: Buf> ExactSizeIterator for Iter<T>
[src][+]
impl<T: Debug> Debug for Iter<T>
[src][+]
Auto Trait Implementations
Blanket Implementations
impl<I> IntoIterator for I where
I: Iterator,
[src][−]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src][−]
impl<T> From for T
[src][−]
impl<T, U> Into for T where
U: From<T>,
[src][−]
U: From<T>,
impl<T, U> TryFrom for T where
T: From<U>,
[src][−]
T: From<U>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src][−]
impl<T> Borrow for T where
T: ?Sized,
[src][−]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src][−]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src][−]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src][−]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src][−]
impl<T> Any for T where
T: 'static + ?Sized,
[src][−]
T: 'static + ?Sized,