pub trait JsonTreeVisitor {
type Error;
// Required method
fn enter(
&mut self,
value: &Value,
context: JsonTreeContext<'_>,
) -> Result<(), Self::Error>;
// Provided method
fn leave(
&mut self,
_value: &Value,
_context: JsonTreeContext<'_>,
) -> Result<(), Self::Error> { ... }
}Expand description
Receives enter and leave events for budget-admitted JSON tree nodes.
§Examples
use qubit_json::value::traverse::{
JsonTreeContext, JsonTreeVisitor,
};
use serde_json::Value;
struct CountingVisitor {
count: usize,
}
impl JsonTreeVisitor for CountingVisitor {
type Error = std::convert::Infallible;
fn enter(
&mut self,
_: &Value,
_: JsonTreeContext<'_>,
) -> Result<(), Self::Error> {
self.count += 1;
Ok(())
}
}
let _visitor = CountingVisitor { count: 0 };Required Associated Types§
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".