Diffstat (limited to 'src/build/protocols.rs')
| -rw-r--r-- | src/build/protocols.rs | 94 |
1 files changed, 0 insertions, 94 deletions
diff --git a/src/build/protocols.rs b/src/build/protocols.rs index 30dc074..fbd4fc0 100644 --- a/src/build/protocols.rs +++ b/src/build/protocols.rs @@ -1,33 +1,4 @@ pub mod hint { - use crate::protocol::{Implementer, Protocol}; - - /// Protocol for requesting a visitor give a hint. - /// - /// This protocol is implemented by visitors. - /// - /// Some walkers don't know what the data they are walking actually represents. - /// This protocol allows such walkers to request the visitor to give a hint of what - /// it is expecting. - /// - /// This can also be paired with the [`Recoverable`][super::recoverable::Recoverable] - /// protocol to place the walker in a recoverable mode for the visitor to try multiple - /// protocols. - pub enum RequestHint {} - - /// Object implementing the [`RequestHint`] protocol. - pub trait RequestHintObject<'ctx> { - /// Call this to request a hint. - /// - /// `hints` is expected to be the walker. This is what the visitor (`Self`) - /// will call to give a hint using the [`Hint`] protocol. - /// - /// `needs_hints` can be `false` if the walker can continue without a hint. - fn request_hint(&mut self, hints: &mut dyn Implementer<'ctx>) -> Result<(), ()>; - } - - impl Protocol for RequestHint { - type Object<'a, 'ctx: 'a> = &'a mut dyn RequestHintObject<'ctx>; - } } pub mod recoverable { @@ -90,45 +61,6 @@ pub mod owned { } pub mod borrowed { - use core::marker::PhantomData; - - use crate::{protocol::Protocol, walk::protocols::hint::Meta}; - - pub struct Borrowed<T: 'static>(PhantomData<fn() -> T>); - - pub enum Value<'a, 'ctx, T: 'static> { - Temp(&'a T), - Context(&'ctx T), - Static(&'static T), - } - - pub trait Object<'ctx, T: 'static> { - fn visit(&mut self, value: Value<'_, 'ctx, T>) -> Result<(), ()>; - } - - impl<T: 'static> Protocol for Borrowed<T> { - type Object<'a, 'ctx: 'a> = &'a mut dyn Object<'ctx, T>; - } - - pub enum Kind { - Temp, - Context, - Static, - } - - pub struct Known { - pub kind: Option<Kind>, - } - - pub struct Hint { - pub kind: Option<Kind>, - } - - impl<T: 'static> Meta for Borrowed<T> { - type Known<'a, 'ctx: 'a> = Known; - - type Hint<'a, 'ctx: 'a> = Hint; - } } pub mod borrowed_mut { @@ -174,32 +106,6 @@ pub mod borrowed_mut { } pub mod tagged { - use crate::{ - protocol::{Implementer, Protocol}, - walk::protocols::hint::Meta, - }; - - pub enum Tagged {} - - pub trait TaggedWalker<'ctx> { - fn walk_tag(&mut self, visitor: &mut dyn Implementer<'ctx>) -> Result<(), ()>; - - fn walk_value(&mut self, visitor: &mut dyn Implementer<'ctx>) -> Result<(), ()>; - } - - pub trait Object<'ctx> { - fn visit(&mut self, walker: &mut dyn TaggedWalker<'ctx>) -> Result<(), ()>; - } - - impl Protocol for Tagged { - type Object<'a, 'ctx: 'a> = &'a mut dyn Object<'ctx>; - } - - impl Meta for Tagged { - type Known<'a, 'ctx: 'a> = (); - - type Hint<'a, 'ctx: 'a> = (); - } } pub mod sequence { |