pub trait JsonTreeMutVisitor {
type Error;
// Required method
fn visit(
&mut self,
value: &mut Value,
context: JsonTreeContext<'_>,
) -> Result<JsonTreeControl, Self::Error>;
}Expand description
Mutates JSON nodes after the complete input tree has passed admission.
Output admission runs only after every visitor callback succeeds. Returning
JsonTreeControl::SkipSubtree skips descendant callbacks but does not
skip final output accounting.
§Examples
use qubit_json::value::traverse::{
JsonTreeContext, JsonTreeControl, JsonTreeMutVisitor,
};
use serde_json::Value;
struct Visitor;
impl JsonTreeMutVisitor for Visitor {
type Error = std::convert::Infallible;
fn visit(
&mut self,
value: &mut Value,
_: JsonTreeContext<'_>,
) -> Result<JsonTreeControl, Self::Error> {
*value = Value::Null;
Ok(JsonTreeControl::SkipSubtree)
}
}
let _visitor = Visitor;Required Associated Types§
Required Methods§
Sourcefn visit(
&mut self,
value: &mut Value,
context: JsonTreeContext<'_>,
) -> Result<JsonTreeControl, Self::Error>
fn visit( &mut self, value: &mut Value, context: JsonTreeContext<'_>, ) -> Result<JsonTreeControl, Self::Error>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".