pub trait Visitor {
// Required method
fn new() -> Self;
// Provided methods
fn visit_or(&mut self, _index: usize) { ... }
fn visit_concat(&mut self) { ... }
fn visit_optional(&mut self, _was_chosen: bool) { ... }
fn visit_repetition(&mut self, _reps: usize) { ... }
fn visit_reference(&mut self, _index: usize) { ... }
fn visit_literal(&mut self, _s: &str) { ... }
fn visit_bytes(&mut self, _val: &[u8]) { ... }
fn visit_regex(&mut self, _val: &[u8]) { ... }
fn visit_group(&mut self) { ... }
fn visit_u16(&mut self, _num: u16) { ... }
fn visit_str(&mut self, _s: &str) { ... }
}Expand description
Defines state that is built during Grammar::expression.
This is implemented for
Stringto produce string expressionsVec<u8>to produce byte sequencesu64to produce equivalence class IDs of the traversal path.
You can implement this yourself, for example if you want to implement equivalence classes that
- ignore order
- ignore certain rules
- are more accurate
- care about characterics of the arbitrary data, such as if a string is ascii or not.
Required Methods§
Provided Methods§
fn visit_or(&mut self, _index: usize)
fn visit_concat(&mut self)
fn visit_optional(&mut self, _was_chosen: bool)
fn visit_repetition(&mut self, _reps: usize)
fn visit_reference(&mut self, _index: usize)
fn visit_literal(&mut self, _s: &str)
fn visit_bytes(&mut self, _val: &[u8])
fn visit_regex(&mut self, _val: &[u8])
fn visit_group(&mut self)
fn visit_u16(&mut self, _num: u16)
fn visit_str(&mut self, _s: &str)
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Visitor for u64
Returns an identifier of the path taken during the traversal.
impl Visitor for u64
Returns an identifier of the path taken during the traversal.
fn new() -> Self
fn visit_or(&mut self, index: usize)
fn visit_concat(&mut self)
fn visit_optional(&mut self, was_chosen: bool)
fn visit_reference(&mut self, index: usize)
fn visit_repetition(&mut self, reps: usize)
fn visit_literal(&mut self, _: &str)
fn visit_bytes(&mut self, _: &[u8])
fn visit_regex(&mut self, _: &[u8])
fn visit_group(&mut self)
Source§impl Visitor for String
Returns an arbitrary expression String matching the grammar.
impl Visitor for String
Returns an arbitrary expression String matching the grammar.
§Panics
Panics if the regex or byte sequence evaluates to non-utf8. This can be avoided by avoiding such regexes or non-utf8 bytes in the grammar.