Diffstat (limited to 'src/builtins/visitor/request_hint.rs')
| -rw-r--r-- | src/builtins/visitor/request_hint.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/builtins/visitor/request_hint.rs b/src/builtins/visitor/request_hint.rs new file mode 100644 index 0000000..6ab797a --- /dev/null +++ b/src/builtins/visitor/request_hint.rs @@ -0,0 +1,23 @@ +//! Protocol for requesting a visitor give a hint to walker. +/// +/// 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. +use crate::protocol::{Implementer, Protocol}; + +/// Protocol for requesting a visitor give a hint. +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`][crate::builtins::walker::hint::Hint] protocol. + 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>; +} |