1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pub mod recoverable {
    use crate::*;

    pub trait Accessor<'value, Err> {
        /// Each time this is called the walker resets.
        fn walk_new(&mut self, visitor: &mut dyn Visitor<'value, Err>) -> Result<(), Err>;
    }

    pub enum Recoverable {}

    impl<'value> Protocol<'value> for Recoverable {
        type Hint = ();

        type Known = ();

        type Accessor<'walking, Err: Error<'value>> = &'walking dyn Accessor<'value, Err>
        where
            'value: 'walking;
    }
}

pub mod str {
    use crate::*;

    pub enum Kind {
        Walking,
        Value,
        Static,
    }

    pub struct Hint {
        pub kind: Option<Kind>,
        pub min_len: Option<usize>,
        pub max_len: Option<usize>,
    }

    pub struct Known {
        pub kind: Option<Kind>,
        pub len: Option<usize>,
    }

    pub enum Data<'walking, 'value> {
        Walking(&'walking str),
        Value(&'value str),
        Static(&'static str),
    }

    pub enum Str {}

    impl<'value> Protocol<'value> for Str {
        type Hint = Hint;

        type Known = Known;

        type Accessor<'walking, Err: Error<'value>> = Data<'walking, 'value>
        where
            'value: 'walking;
    }
}