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>
impl<V, R, E> State<V, R, E>
Sourcepub fn halt_if_suspended(self) -> Result<Generator<V, R>, E>
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.
Sourcepub fn try_write_next<I, F, W>(
self,
writer: &mut W,
f: F,
) -> Result<State<V, R, R::Error>, W::Error>
pub fn try_write_next<I, F, W>( self, writer: &mut W, f: F, ) -> Result<State<V, R, R::Error>, W::Error>
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.
Sourcepub fn try_write_all<I, F, W>(
self,
writer: &mut W,
f: F,
) -> Result<(), W::Error>
pub fn try_write_all<I, F, W>( self, writer: &mut W, f: F, ) -> Result<(), W::Error>
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.
Sourcepub fn is_empty(&self) -> bool
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.
Sourcepub fn into_active_vertices(self) -> impl ExactSizeIterator<Item = V>
pub fn into_active_vertices(self) -> impl ExactSizeIterator<Item = V>
Consume the state, returning an iterator over the active vertices in an unspecified order.