pub trait Validate {
type Constraint: Default + Clone + Join + 'static;
// Required methods
fn validate(&self, constraint: &Self::Constraint) -> bool;
fn validate_with_id(&self, constraint: &Self::Constraint, id: usize) -> bool;
fn replay(&mut self, constraint: &Self::Constraint);
}Expand description
A type that can be validated against constraints.
Typical crate usage does not require you to interact with its trait. However, it can be useful if you want to integrate comemo’s tracking and constraint validation mechanism directly into your code.
This trait is implemented by the #[track] macro alongside Track.
Required Associated Types§
sourcetype Constraint: Default + Clone + Join + 'static
type Constraint: Default + Clone + Join + 'static
The constraints for this type.
Required Methods§
sourcefn validate(&self, constraint: &Self::Constraint) -> bool
fn validate(&self, constraint: &Self::Constraint) -> bool
Whether this value fulfills the given constraints.
For a type Foo, empty constraints can be created with <Foo as Validate>::Constraint::default() and filled with
track_with or
track_mut_with.
sourcefn validate_with_id(&self, constraint: &Self::Constraint, id: usize) -> bool
fn validate_with_id(&self, constraint: &Self::Constraint, id: usize) -> bool
sourcefn replay(&mut self, constraint: &Self::Constraint)
fn replay(&mut self, constraint: &Self::Constraint)
Replay recorded mutations to the value.
Object Safety§
This trait is not object safe.