pub trait ModelHooks {
// Provided methods
fn before_model(_input: &mut Value, _ctx: &mut ValidationContext) { ... }
fn before_field(
_field: &str,
_input: &mut Value,
_ctx: &mut ValidationContext,
) { ... }
fn after_fields(&self, _ctx: &mut ValidationContext) { ... }
fn after_model(&self, _ctx: &mut ValidationContext) { ... }
fn computed_fields(
&self,
_out: &mut Map<String, Value>,
_opts: &DumpOptions,
) -> Result<(), DumpError> { ... }
fn computed_schema(
_properties: &mut Map<String, Value>,
_registry: &mut SchemaRegistry,
) { ... }
fn serialize_field(
&self,
_field: &str,
value: Value,
) -> Result<Value, DumpError> { ... }
fn serialize_model(&self, value: Value) -> Result<Value, DumpError> { ... }
}Expand description
Hooks a model can provide. Every method defaults to doing nothing.
Provided Methods§
Sourcefn before_model(_input: &mut Value, _ctx: &mut ValidationContext)
fn before_model(_input: &mut Value, _ctx: &mut ValidationContext)
Model before-validators, run on the raw input object.
Sourcefn before_field(_field: &str, _input: &mut Value, _ctx: &mut ValidationContext)
fn before_field(_field: &str, _input: &mut Value, _ctx: &mut ValidationContext)
Field before-validators for the field whose Rust name is field,
run on its raw input slot (location already set to the field).
Sourcefn after_fields(&self, _ctx: &mut ValidationContext)
fn after_fields(&self, _ctx: &mut ValidationContext)
Field after-validators (each reports at its field’s location).
Sourcefn after_model(&self, _ctx: &mut ValidationContext)
fn after_model(&self, _ctx: &mut ValidationContext)
Model after-validators.
Sourcefn computed_fields(
&self,
_out: &mut Map<String, Value>,
_opts: &DumpOptions,
) -> Result<(), DumpError>
fn computed_fields( &self, _out: &mut Map<String, Value>, _opts: &DumpOptions, ) -> Result<(), DumpError>
Insert computed fields into the serialized object.
§Errors
Serialization failures of computed values.
Sourcefn computed_schema(
_properties: &mut Map<String, Value>,
_registry: &mut SchemaRegistry,
)
fn computed_schema( _properties: &mut Map<String, Value>, _registry: &mut SchemaRegistry, )
Document computed fields (added as readOnly properties).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".