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

pub struct Action { /* fields omitted */ }

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

impl Action[src]

pub fn new() -> Self[src]

Creates actions wit both hooks empty.

pub fn on_success<F: FnOnce() + 'static>(self, f: F) -> Self[src]

Attaches (replaces) the success action.

pub fn on_abort<F: FnOnce() + 'static>(self, f: F) -> Self[src]

Attaches (replaces) the failure action.

Trait Implementations

impl Default for Action[src]

Auto Trait Implementations

impl !RefUnwindSafe for Action

impl !Send for Action

impl !Sync for Action

impl Unpin for Action

impl !UnwindSafe for Action

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoResult<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.