use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
use std::io;
use std::result;
#[derive(Debug)]
pub enum Error {
UnknownFlag(String),
DisallowedFlag(String, String),
#[expect(clippy::enum_variant_names)]
SpawnError(io::Error),
}
impl From<io::Error> for Error {
fn from(other: io::Error) -> Self {
Self::SpawnError(other)
}
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
match *self {
Self::UnknownFlag(ref flag) => {
f.write_fmt(format_args!(
"The flag '{flag}' was passed to the Rust test process, but rusty-fork does not know how to handle it."
))
},
Self::DisallowedFlag(ref flag, ref message) => {
f.write_fmt(format_args!(
"The flag '{flag}' was passed to the Rust test process, but rusty-fork cannot handle it; reason: {message}"
))
},
Self::SpawnError(ref err) => {
f.write_fmt(format_args!("Spawn failed: {err}"))
},
}
}
}
pub type Result<T> = result::Result<T, Error>;