fallible/
fallible.rs

1use std::io;
2
3use fault_injection::{fallible, set_trigger_function, FAULT_INJECT_COUNTER};
4
5fn trigger_fn(crate_name: &str, file_name: &str, line_number: u32) {
6    println!(
7        "fault injected at {} {} {}",
8        crate_name, file_name, line_number
9    );
10}
11
12fn do_io() -> io::Result<()> {
13    Ok(())
14}
15
16fn main() -> io::Result<()> {
17    set_trigger_function(trigger_fn);
18    FAULT_INJECT_COUNTER.store(1, std::sync::atomic::Ordering::Release);
19
20    fallible!(do_io());
21
22    Ok(())
23}