use std::fmt;
use crate::ReactionDirection;
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ReactionArrow {
#[default]
Forward,
Reverse,
Reversible,
Equilibrium,
}
impl ReactionArrow {
#[must_use]
pub const fn direction(self) -> ReactionDirection {
match self {
Self::Forward => ReactionDirection::Forward,
Self::Reverse => ReactionDirection::Reverse,
Self::Reversible => ReactionDirection::Reversible,
Self::Equilibrium => ReactionDirection::Equilibrium,
}
}
#[must_use]
pub const fn is_reversible(self) -> bool {
matches!(self, Self::Reversible | Self::Equilibrium)
}
#[must_use]
pub const fn is_forward(self) -> bool {
matches!(self, Self::Forward)
}
#[must_use]
pub const fn is_reverse(self) -> bool {
matches!(self, Self::Reverse)
}
}
impl fmt::Display for ReactionArrow {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
let value = match self {
Self::Forward => "->",
Self::Reverse => "<-",
Self::Reversible => "<->",
Self::Equilibrium => "⇌",
};
formatter.write_str(value)
}
}