pub trait ResponseModel: Serialize {
// Provided methods
fn validate(&self) -> Result<(), ResponseValidationError> { ... }
fn model_name() -> &'static str { ... }
}Expand description
Trait for types that can be validated as response models.
This allows custom validation logic to be applied before serialization. Types implementing this trait can verify that the response data is valid according to the declared response model.
Provided Methods§
Sourcefn validate(&self) -> Result<(), ResponseValidationError>
fn validate(&self) -> Result<(), ResponseValidationError>
Validate the response model before serialization.
Returns Ok(()) if valid, or a validation error if invalid.
Sourcefn model_name() -> &'static str
fn model_name() -> &'static str
Get the model name for error messages.
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.