anthem-rs/src/output.rs

46 lines
833 B
Rust
Raw Normal View History

2020-05-12 04:25:49 +02:00
pub(crate) mod shell;
2020-02-02 20:27:30 +01:00
pub(crate) mod tptp;
2020-02-03 22:51:19 +01:00
pub use shell::ColorChoice;
2020-05-12 04:25:49 +02:00
pub(crate) use shell::Shell;
2020-02-05 01:10:33 +01:00
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
2020-02-03 22:51:19 +01:00
pub enum Format
{
HumanReadable,
TPTP,
}
pub struct InvalidFormatError;
impl std::fmt::Debug for InvalidFormatError
{
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
{
write!(formatter, "invalid output format")
}
}
impl std::fmt::Display for InvalidFormatError
{
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
{
write!(formatter, "{:?}", self)
}
}
impl std::str::FromStr for Format
{
type Err = InvalidFormatError;
fn from_str(s: &str) -> Result<Self, Self::Err>
{
match s
{
"human-readable" => Ok(Format::HumanReadable),
"tptp" => Ok(Format::TPTP),
_ => Err(InvalidFormatError),
}
}
}