#[cfg(coverage)]
use std::io::Write;
use std::{
fs::File,
path::PathBuf,
};
use super::output_tee::OutputTee;
pub(crate) struct OutputCaptureOptions {
pub(crate) max_bytes: Option<usize>,
pub(crate) tee: Option<OutputTee>,
}
impl OutputCaptureOptions {
pub(crate) fn new(
max_bytes: Option<usize>,
file: Option<File>,
file_path: Option<PathBuf>,
) -> Self {
let tee = file.map(|file| OutputTee {
writer: Box::new(file),
path: file_path.unwrap_or_default(),
});
Self { max_bytes, tee }
}
#[cfg(coverage)]
pub(crate) fn new_writer(
max_bytes: Option<usize>,
writer: Box<dyn Write + Send>,
path: PathBuf,
) -> Self {
Self {
max_bytes,
tee: Some(OutputTee { writer, path }),
}
}
}