[][src]Struct bytes::buf::Iter

pub struct Iter<T> { /* fields omitted */ }

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: Debug> Debug for Iter<T>[src]

impl<T: Buf> ExactSizeIterator for Iter<T>[src]

impl<T: Buf> Iterator for Iter<T>[src]

type Item = u8

The type of the elements being iterated over.

Auto Trait Implementations

impl<T> RefUnwindSafe for Iter<T> where
    T: RefUnwindSafe

impl<T> Send for Iter<T> where
    T: Send

impl<T> Sync for Iter<T> where
    T: Sync

impl<T> Unpin for Iter<T> where
    T: Unpin

impl<T> UnwindSafe for Iter<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.