Diffstat (limited to 'src/protocol/visitor/recoverable.rs')
| -rw-r--r-- | src/protocol/visitor/recoverable.rs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/protocol/visitor/recoverable.rs b/src/protocol/visitor/recoverable.rs index 90c671b..e23c69e 100644 --- a/src/protocol/visitor/recoverable.rs +++ b/src/protocol/visitor/recoverable.rs @@ -1,14 +1,19 @@ use crate::{ - any::{TypeName, WithContextLt}, bijective_higher_ranked_type, effect::{Effect, Future}, hkt::AnySizedSend, protocol::{walker::hint::HintMeta, Visitor}, Flow + any::{TypeName, WithContextLt}, + bijective_higher_ranked_type, + effect::{Effect, Future}, + hkt::AnySizedSend, + protocol::{walker::hint::HintMeta, Visitor}, + Status, }; -use super::Status; +use super::VisitResult; pub trait Recoverable<'ctx, E: Effect> { fn visit<'a>( &'a mut self, scope: DynRecoverableScope<'a, 'ctx, E>, - ) -> Future<'a, Flow, E>; + ) -> Future<'a, VisitResult<DynRecoverableScope<'a, 'ctx, E>>, E>; } bijective_higher_ranked_type! { @@ -30,7 +35,7 @@ bijective_higher_ranked_type! { } pub trait RecoverableScope<'ctx, E: Effect> { - fn new_walk<'a>(&'a mut self, visitor: Visitor<'a, 'ctx>) -> Future<'a, Flow, E>; + fn new_walk<'a>(&'a mut self, visitor: Visitor<'a, 'ctx>) -> Future<'a, Status, E>; } pub type DynRecoverableScope<'a, 'ctx, E> = &'a mut (dyn RecoverableScope<'ctx, E> + Send + 'a); @@ -48,23 +53,12 @@ impl<'ctx, E: Effect> HintMeta<'ctx> for DynRecoverable<'ctx, E> { pub fn visit_recoverable<'a, 'ctx, E: Effect>( visitor: Visitor<'a, 'ctx>, scope: DynRecoverableScope<'a, 'ctx, E>, -) -> Future<'a, Status, E> { +) -> Future<'a, VisitResult<DynRecoverableScope<'a, 'ctx, E>>, E> { if let Some(object) = visitor.upcast_mut::<DynRecoverable<'ctx, E>>() { // Allow the visitor to give a hint if it wants. - E::map(object.visit(scope), |flow| match flow { - Flow::Continue => { - // The visitor wants the walker to continue to it's normal - // walking. - Status::r#continue() - } - Flow::Break | Flow::Done => { - // The visitor is done (either because of an error or because - // it already used a hint). - Status::r#break() - } - }) + object.visit(scope) } else { // If the visitor doesn't support request hint then we continue. - E::ready(Status::skipped()) + E::ready(VisitResult::Skipped(scope)) } } |