Diffstat (limited to 'src/protocols.rs')
| -rw-r--r-- | src/protocols.rs | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/src/protocols.rs b/src/protocols.rs index e5f0ae4..cd0164e 100644 --- a/src/protocols.rs +++ b/src/protocols.rs @@ -1,33 +1,24 @@ pub mod recoverable { - use crate::{error::UniError, protocol::Protocol, Visitor}; + use crate::{protocol::Protocol, ControlFlow, Visitor}; - pub trait Accessor<'value, 'ctx: 'value, WalkerErr, VisitorErr> { + pub trait Accessor<'ctx> { /// Each time this is called the walker resets. - fn walk_new( - &mut self, - visitor: &mut dyn Visitor<'value, 'ctx, WalkerErr, Error = VisitorErr>, - ) -> Result<(), UniError<WalkerErr, VisitorErr>>; + fn new_walk(&mut self, visitor: &mut dyn Visitor<'ctx>) -> ControlFlow; } pub enum Recoverable {} impl Protocol for Recoverable { - type Hint<'value, 'ctx: 'value> = (); + type Hint<'ctx> = (); - type Known<'value, 'ctx: 'value> = (); + type Known<'ctx> = (); - type Accessor< - 'walking, - 'value: 'walking, - 'ctx: 'value, - WalkerErr: 'value, - VisitorErr: 'value, - > = &'walking mut dyn Accessor<'value, 'ctx, WalkerErr, VisitorErr>; + type Accessor<'walking, 'ctx: 'walking> = &'walking mut dyn Accessor<'ctx>; } } pub mod sequence { - use crate::{error::UniError, protocol::Protocol, Visitor}; + use crate::{protocol::Protocol, ControlFlow, Visitor}; pub struct Hint { pub min_len: Option<usize>, @@ -38,27 +29,18 @@ pub mod sequence { pub len: Option<usize>, } - pub trait Accessor<'value, 'ctx: 'value, WalkerErr, VisitorErr> { - fn next( - &mut self, - visitor: &mut dyn Visitor<'value, 'ctx, WalkerErr, Error = VisitorErr>, - ) -> Result<(), UniError<WalkerErr, VisitorErr>>; + pub trait Accessor<'ctx> { + fn next(&mut self, visitor: &mut dyn Visitor<'ctx>) -> ControlFlow; } pub enum Sequence {} impl Protocol for Sequence { - type Hint<'value, 'ctx: 'value> = Hint; + type Hint<'ctx> = Hint; - type Known<'value, 'ctx: 'value> = Known; + type Known<'ctx> = Known; - type Accessor< - 'walking, - 'value: 'walking, - 'ctx: 'value, - WalkerErr: 'value, - VisitorErr: 'value, - > = &'walking mut dyn Accessor<'value, 'ctx, WalkerErr, VisitorErr>; + type Accessor<'walking, 'ctx: 'walking> = &'walking mut dyn Accessor<'ctx>; } } @@ -69,7 +51,6 @@ pub mod reference { pub enum Kind { Walking, - Value, Context, Static, } @@ -88,16 +69,14 @@ pub mod reference { pub len: Option<usize>, } - pub enum Ref<'walking, 'value: 'walking, 'ctx: 'value, T: ?Sized + 'static> { + pub enum Ref<'walking, 'ctx, T: ?Sized + Any> { Walking(&'walking T), - Value(&'value T), Context(&'ctx T), Static(&'static T), } - pub enum Mut<'walking, 'value: 'walking, 'ctx: 'value, T: ?Sized + 'static> { + pub enum Mut<'walking, 'ctx, T: ?Sized + Any> { Walking(&'walking mut T), - Value(&'value mut T), Context(&'ctx mut T), Static(&'static mut T), } @@ -107,30 +86,18 @@ pub mod reference { pub struct ReferenceMut<T: ?Sized + Any>(PhantomData<fn() -> T>); impl<T: ?Sized + Any> Protocol for Reference<T> { - type Hint<'value, 'ctx: 'value> = Hint; + type Hint<'ctx> = Hint; - type Known<'value, 'ctx: 'value> = Known; + type Known<'ctx> = Known; - type Accessor< - 'walking, - 'value: 'walking, - 'ctx: 'value, - WalkerErr: 'value, - VisitorErr: 'value, - > = Ref<'walking, 'value, 'ctx, T>; + type Accessor<'walking, 'ctx: 'walking> = Ref<'walking, 'ctx, T>; } impl<T: ?Sized + Any> Protocol for ReferenceMut<T> { - type Hint<'value, 'ctx: 'value> = Hint; + type Hint<'ctx> = Hint; - type Known<'value, 'ctx: 'value> = Known; + type Known<'ctx> = Known; - type Accessor< - 'walking, - 'value: 'walking, - 'ctx: 'value, - WalkerErr: 'value, - VisitorErr: 'value, - > = Mut<'walking, 'value, 'ctx, T>; + type Accessor<'walking, 'ctx: 'walking> = Mut<'walking, 'ctx, T>; } } |