Trait Invariant

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

Source

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§

Source

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!

Source

fn check<S: Service>( self, internal_state: &mut Self::InternalState, store: &Store<S>, action: &ActionWithMeta, ) -> InvariantResult

Checks the state for invariant violation.

Provided Methods§

Source

fn is_global(&self) -> bool

Whether or not invariant is cluster-wide, or for just local node.

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§