Trait ValidatorCollection
pub trait ValidatorCollection<V> {
// Required methods
fn add_validator(self, validator: V) -> Self;
fn sort_by_priority(self) -> Self;
}Expand description
Helper trait for creating validator collections with type erasure.
This trait provides utilities for building collections of validators with automatic
priority-based sorting and type erasure through Box wrappers.
§Usage Examples
use dotscope::metadata::validation::{ValidatorCollection, RawValidator, RawValidationContext};
use dotscope::Result;
struct TestValidator;
impl RawValidator for TestValidator {
fn validate_raw(&self, _context: &RawValidationContext) -> Result<()> { Ok(()) }
fn name(&self) -> &'static str { "TestValidator" }
}
let mut validators: Vec<Box<dyn RawValidator>> = Vec::new();
let validators = validators
.add_validator(Box::new(TestValidator))
.sort_by_priority();Required Methods§
fn add_validator(self, validator: V) -> Self
fn add_validator(self, validator: V) -> Self
fn sort_by_priority(self) -> Self
fn sort_by_priority(self) -> Self
Sorts validators by priority (highest first).
Validators with higher priority values are placed first in the collection, ensuring they execute before lower-priority validators.
§Returns
Returns the collection sorted by validator priority in descending order.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".