thin-provisioning-tools/tests/common/program.rs

50 lines
1.1 KiB
Rust
Raw Normal View History

use anyhow::Result;
use std::ffi::OsStr;
use std::path::PathBuf;
use crate::common::test_dir::TestDir;
//------------------------------------------
pub enum ArgType {
InputArg,
IoOptions,
}
pub trait Program<'a> {
fn name() -> &'a str;
fn path() -> &'a OsStr;
fn usage() -> &'a str;
fn arg_type() -> ArgType;
// error messages
fn bad_option_hint(option: &str) -> String;
}
pub trait InputProgram<'a>: Program<'a> {
fn mk_valid_input(td: &mut TestDir) -> Result<PathBuf>;
// error messages
fn missing_input_arg() -> &'a str;
fn file_not_found() -> &'a str;
fn corrupted_input() -> &'a str;
}
2021-08-30 21:49:44 +05:30
pub trait MetadataReader<'a>: InputProgram<'a> {}
pub trait OutputProgram<'a>: InputProgram<'a> {
// error messages
fn missing_output_arg() -> &'a str;
2021-08-30 21:49:44 +05:30
}
// programs that write existed files
pub trait MetadataWriter<'a>: OutputProgram<'a> {
// error messages
fn file_not_found() -> &'a str;
}
2021-08-30 21:49:44 +05:30
// programs that create output files (O_CREAT)
pub trait MetadataCreator<'a>: OutputProgram<'a> {}
//------------------------------------------