#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(missing_docs)]
use std::str::FromStr;
pub use crate::{
compound::Compound,
element::Element,
equation::{Equation, ReactionQuotient},
};
#[cfg(feature = "balance")]
#[cfg_attr(docsrs, doc(cfg(feature = "balance")))]
pub mod balance;
mod compound;
mod display;
mod element;
mod equation;
pub mod error;
mod parse;
pub const AVAGADRO_CONSTANT: f64 = 6.02214e23;
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum State {
Solid,
Liquid,
Gas,
#[default]
Aqueous,
}
impl FromStr for State {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"s" => Ok(Self::Solid),
"l" => Ok(Self::Liquid),
"g" => Ok(Self::Gas),
"aq" => Ok(Self::Aqueous),
_ => Err("Invalid state."),
}
}
}
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Direction {
Left,
#[default]
Right,
Reversible,
}
impl FromStr for Direction {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"<-" => Ok(Self::Left),
"->" => Ok(Self::Right),
"<->" => Ok(Self::Reversible),
_ => Err("Invalid direction."),
}
}
}