use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BondOrder {
Single,
Double,
Triple,
Aromatic,
}
impl BondOrder {
pub fn as_f64(self) -> f64 {
match self {
Self::Single => 1.0,
Self::Double => 2.0,
Self::Triple => 3.0,
Self::Aromatic => 1.5,
}
}
pub fn valence_contribution(self) -> u8 {
match self {
Self::Single | Self::Aromatic => 1,
Self::Double => 2,
Self::Triple => 3,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Bond {
pub order: BondOrder,
pub is_aromatic: bool,
pub is_ring: bool,
}
impl Bond {
pub fn new(order: BondOrder) -> Self {
Self {
is_aromatic: order == BondOrder::Aromatic,
order,
is_ring: false,
}
}
}