Skip to main content

ResponseModel

Trait ResponseModel 

Source
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§

Source

fn validate(&self) -> Result<(), ResponseValidationError>

Validate the response model before serialization.

Returns Ok(()) if valid, or a validation error if invalid.

Source

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.

Implementors§