Struct dia_assert::Assert
[−]
[src]
pub struct Assert { /* fields omitted */ }Use this struct with Level to assert a user action.
Methods
impl Assert[src]
pub fn new(custom_formats: Option<(String, String)>, exit_code: i32) -> Assert[src]
Makes new instance.
-
custom_formats: currently Rust doesn't support runtime formatting. So it's impossible to provide you a simpler solution. This is a workaround: the first string will be placed before the generated-string to be displayed to the user. The second string will be placed after that. If you provideNone, a pre-defined format will be used. -
exit_code: will be passed toprocess::exit().
pub fn try(&self, level: &Level) -> Result<(), Failed>[src]
Tries an assert.
The function generates a string with difficulty based on level. Then asks the user to type that string.
pub fn try_n(&self, level: &Level, n: u8)[src]
Tries n times.
This function calls try().
- If the user passed, it returns peacefully.
- For other cases (the user fails, or stdout failure...), it calls
process::exit()with the exit code you provided in::new().
pub fn try_once(&self, level: &Level)[src]
Tries once.
This function calls try_n() with 1 passed as n.