Struct constriction::backends::FallibleIteratorReadWords[][src]

pub struct FallibleIteratorReadWords<Iter: Iterator> { /* fields omitted */ }
Expand description

Adapter that turns an iterator over Result<Word, ReadError> into a data source.

Wraps an iterator over Result<Word, ReadError> and implements ReadWords<Word, S, ReadError=ReadError> by pulling the iterator each time a client reads from it. If the iterator implements ExactSizeIterator then this wrapper also implements BoundedReadWords.

Implements ReadWord for arbitrary Semantics. This is legal since it doesn’t implement WriteWords, so the question how reads relate to writes is moot.

See also InfallibleIteratorReadWords, and module-level documentation for a detailed usage example.

Implementations

impl<Iter: Iterator> FallibleIteratorReadWords<Iter>[src]

pub fn new<I, Word, ReadError>(iter: I) -> Self where
    I: IntoIterator<IntoIter = Iter>,
    Iter: Iterator<Item = Result<Word, ReadError>>, 
[src]

Creates the adapter for the provided iterator.

The provided iterator iter does not need to be fused (i.e., it may return Some after the first None even though a ReadWords wouldn’t be allowed to do the equivalent of that). The adapter calls iter.fuse() to ensure correct behavior.

You can get the (fused) iterator back by calling IntoIterator::into_iter.

Trait Implementations

impl<Iter, S, Word> BoundedReadWords<Word, S> for FallibleIteratorReadWords<Iter> where
    Self: ReadWords<Word, S>,
    Iter: ExactSizeIterator,
    S: Semantics
[src]

fn remaining(&self) -> usize[src]

Returns the number of Words that are left for reading. Read more

fn is_exhausted(&self) -> bool[src]

Whether or not there is no data left to read. Read more

impl<Iter: Clone + Iterator> Clone for FallibleIteratorReadWords<Iter>[src]

fn clone(&self) -> FallibleIteratorReadWords<Iter>[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<Iter: Debug + Iterator> Debug for FallibleIteratorReadWords<Iter>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<Iter: Iterator> IntoIterator for FallibleIteratorReadWords<Iter>[src]

type Item = Iter::Item

The type of the elements being iterated over.

type IntoIter = Fuse<Iter>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl<Iter, S, Word, ReadError> ReadWords<Word, S> for FallibleIteratorReadWords<Iter> where
    Iter: Iterator<Item = Result<Word, ReadError>>,
    S: Semantics,
    ReadError: Debug
[src]

Since FallibleIteratorReadWords doesn’t implement WriteWords, it is allowed to implement ReadWords for all ReadWriteLogics

type ReadError = ReadError

The error type that can occur when reading from the data source, or Infallible. Read more

fn read(&mut self) -> Result<Option<Word>, Self::ReadError>[src]

Reads a single Word from the data source and advances the state of the data source accordingly (i.e., so that the next read won’t read the same Word again). Read more

fn maybe_exhausted(&self) -> bool[src]

Returns true if the data source could be out of data. Read more

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.