Struct spirit::validation::Action[][src]

pub struct Action { /* fields omitted */ }
Expand description

A validation action.

The validator (see config_validator) is supposed to either return an error or an action to be taken once validation completes.

By default, the Action is empty, but an on_success and on_abort callbacks can be attached to it. These’ll execute once the validation completes (only one of them will be called, depending on the result of validation).

Examples

use spirit::{Empty, Spirit};
use spirit::prelude::*;
use spirit::validation::Action;
Spirit::<Empty, Empty>::new()
    .config_validator(|_old_cfg, new_cfg, _opts| {
        let something = create_something(new_cfg)?;
        Ok(Action::new().on_success(move || install_something(something)))
    });

Or, if you want to only check the configuration:

use spirit::{Empty, Spirit};
use spirit::prelude::*;
use spirit::validation::Action;

Spirit::<Empty, Empty>::new()
    .config_validator(|_old_cfg, new_cfg, _opts| {
        looks_good(new_cfg)?;
        Ok(Action::new())
    });

Implementations

Creates actions wit both hooks empty.

Attaches (replaces) the success action.

Attaches (replaces) the failure action.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Turns self into the result.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.