pub fn command_with_fallback<I, O, E>(
    config: Config,
    function: CommandFn<I, O, E>,
    fallback: FallbackFn<O, E>,
) -> Result<Command<I, O, E>, CriusError>
where
    E: From<CriusError>,
{
    command::Command::define_with_fallback(config, function, fallback)
}
/// Use this function to construct a circuit breaker *with* a fallback
/// function:
/// # Example:
///
/// ```
/// # use crius::{command_with_fallback, Config, CriusError};
/// # #[derive(PartialEq, Debug)]
/// # struct ExampleError;
/// # impl From<CriusError> for ExampleError {
/// #   fn from(_: CriusError) -> Self { ExampleError }
/// # }
/// # let double_if_lt_ten = |n| if n > 10 {
/// #     Err(ExampleError)
/// # } else {
/// #     Ok(n * 2)
/// # };
/// #
/// // Define a simple circuit breaker command:
/// let mut cmd = command_with_fallback(
///     Config::default(),
///
///     // Same function as in the `command`-example
///     double_if_lt_ten,
///
///     // Define a fallback:
///     |_err| 4, // It's always four.
/// ).unwrap();
///
/// // and run it with an example input:
/// let result = cmd.run(11);
/// assert_eq!(Ok(4), result)
/// ```
Use this function to construct a circuit breaker *with* a fallback
function.
Use this function to construct a circuit breaker * with * a fallback function .
pub fn command_with_fallback<I, O, E>(
    config: Config,
    function: CommandFn<I, O, E>,
    fallback: FallbackFn<O, E>,
) -> Result<Command<I, O, E>, CriusError>
where
    E: From<CriusError>,
{
    command::Command::define_with_fallback(config, function, fallback)
}
pub fn command_with_fallback < I , O , E > ( config : Config , function : CommandFn < I , O , E > , fallback : FallbackFn < O , E > , ) -> Result < Command < I , O , E > , CriusError > where E : From < CriusError > , { command :: Command :: define_with_fallback ( config , function , fallback ) }
Use this function to construct a circuit breaker *with* a fallback
function:
Use this function to construct a circuit breaker * with * a fallback function :
config
Config
function
CommandFn<I, O, E>
fallback
FallbackFn<O, E>
example:
None
use crius::{command_with_fallback, config, criuserror};
None
#[derive(partialeq, debug)]
None
struct exampleerror;
None
impl from<criuserror> for exampleerror {
None
fn from(_: criuserror) -> self { exampleerror }
None
}
None
let double_if_lt_ten = |n| if n > 10 {
None
err(exampleerror)
None
} else {
None
ok(n * 2)
None
};
Define a simple circuit breaker command:
let mut cmd = command_with_fallback(
Config::default().

Same function as in the `command`-example
double_if_lt_ten.

Define a fallback:
|_err| 4, // It's always four.

and run it with an example input:
let result = cmd.run(11);
assert_eq!(Ok(4), result)
```
Define a simple circuit breaker command : let mut cmd = command_with_fallback ( Config :: default () . Same function as in the ` command ` - example double_if_lt_ten . Define a fallback : |_err| 4 // It ' s always four . and run it with an example input : let result = cmd . run ( 11 ) ; assert_eq! ( Ok ( 4 ) result ) ` ` `