pub trait Invariant {
type InternalState: 'static + Send + Default;
// Required methods
fn triggers(&self) -> &[ActionKind];
fn check<S: Service>(
self,
internal_state: &mut Self::InternalState,
store: &Store<S>,
action: &ActionWithMeta,
) -> InvariantResult;
// Provided method
fn is_global(&self) -> bool { ... }
}Required Associated Types§
Sourcetype InternalState: 'static + Send + Default
type InternalState: 'static + Send + Default
Internal state of the invariant.
If some state needs to be preserved across checks, this is the place.
Required Methods§
Sourcefn triggers(&self) -> &[ActionKind]
fn triggers(&self) -> &[ActionKind]
Invariant triggers define a list actions, which should cause
Invariant::check to be called.
If empty, an invariant will never be checked!
Sourcefn check<S: Service>(
self,
internal_state: &mut Self::InternalState,
store: &Store<S>,
action: &ActionWithMeta,
) -> InvariantResult
fn check<S: Service>( self, internal_state: &mut Self::InternalState, store: &Store<S>, action: &ActionWithMeta, ) -> InvariantResult
Checks the state for invariant violation.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".