[−][src]Struct spirit::validation::Action
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoResult<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,