anthem-rs/src/output.rs

43 lines
739 B
Rust
Raw Normal View History

2020-02-04 00:27:04 +01:00
pub(crate) mod human_readable;
2020-02-02 20:27:30 +01:00
pub(crate) mod tptp;
2020-02-03 22:51:19 +01:00
#[derive(Debug)]
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),
}
}
}