Skip to main content

ChaosFile

Type Alias ChaosFile 

Source
pub type ChaosFile = ChaosWriter<File>;
Expand description

Convenience: a ChaosWriter<File>.

Open a real file and wrap it for failure injection on writes.

§Example (ignored: requires a real filesystem path)

use dev_chaos::{io::ChaosFile, FailureMode, FailureSchedule};
use std::io::Write;

let schedule = FailureSchedule::on_attempts(&[3], FailureMode::PartialWrite);
let mut f = ChaosFile::create("/tmp/x.log", schedule).unwrap();
f.write_all(b"data").unwrap();

Aliased Type§

pub struct ChaosFile { /* private fields */ }

Implementations§

Source§

impl ChaosFile

Source

pub fn create(path: impl AsRef<Path>, schedule: FailureSchedule) -> Result<Self>

Create a new file at path and wrap it.

Source

pub fn append(path: impl AsRef<Path>, schedule: FailureSchedule) -> Result<Self>

Open an existing file at path for appending and wrap it.