State

Enum State 

Source
pub enum State<V, R, E> {
    Ok(Generator<V, R>),
    Suspended(SuspendedGenerator<V, R>, E),
}
Expand description

Generator states which may occur after a call to try_write_next.

If you want to abort on an error, use halt_if_suspended. If you want to continue despite the error, use SuspendedGenerator::resume.

Variants§

§

Ok(Generator<V, R>)

The vertex was written successfully.

§

Suspended(SuspendedGenerator<V, R>, E)

The vertex was not written because of an error.

Implementations§

Source§

impl<V, R, E> State<V, R, E>

Source

pub fn halt_if_suspended(self) -> Result<Generator<V, R>, E>

Return the generator if ok, or drop the suspended generator and return the error if not.

Source

pub fn try_write_next<I, F, W>( self, writer: &mut W, f: F, ) -> Result<State<V, R, R::Error>, W::Error>
where R: TryRamify<V>, I: IntoIterator<Item = V>, F: FnOnce(E) -> I, W: DiagramWrite,

Either write the next vertex or resume from the suspended state with a closure.

If this is a State::Ok, this calls Generator::try_write_next, and if this is a State::Suspended, the provided closure is applied to the error to provide a new list of children.

Source

pub fn try_write_all<I, F, W>( self, writer: &mut W, f: F, ) -> Result<(), W::Error>
where R: TryRamify<V, Error = E>, I: IntoIterator<Item = V>, F: FnMut(E) -> I, W: DiagramWrite,

A convenience function to repeatedly try to write the next vertex or resume from the suspended state with a closure.

Note that instead of using this method, it may be possible to directly implement Ramify by inlining the closure into try_ramify and instead using Generator::write_all.

Source

pub fn is_empty(&self) -> bool

Whether or not there are any active vertices.

If this is a State::Ok, this checks if the generator is non-empty, and if this is State::Suspended it always returns false since there is at least one active vertex.

Source

pub fn into_active_vertices(self) -> impl ExactSizeIterator<Item = V>

Consume the state, returning an iterator over the active vertices in an unspecified order.

Auto Trait Implementations§

§

impl<V, R, E> Freeze for State<V, R, E>
where E: Freeze, R: Freeze,

§

impl<V, R, E> RefUnwindSafe for State<V, R, E>

§

impl<V, R, E> Send for State<V, R, E>
where E: Send, R: Send, V: Send,

§

impl<V, R, E> Sync for State<V, R, E>
where E: Sync, R: Sync, V: Sync,

§

impl<V, R, E> Unpin for State<V, R, E>
where E: Unpin, R: Unpin, V: Unpin,

§

impl<V, R, E> UnwindSafe for State<V, R, E>
where E: UnwindSafe, R: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.