1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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>;
}