Skip to main content

use_compound/
registry.rs

1use std::fmt;
2
3/// A compound identifier registry namespace.
4#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub enum CompoundRegistry {
6    /// CAS Registry Number namespace.
7    CasNumber,
8    /// PubChem Compound Identifier namespace.
9    PubChemCid,
10    /// InChI namespace.
11    Inchi,
12    /// InChIKey namespace.
13    InchiKey,
14    /// SMILES namespace.
15    Smiles,
16    /// A custom namespace.
17    Custom(String),
18}
19
20impl CompoundRegistry {
21    /// Returns the registry namespace text.
22    #[must_use]
23    pub fn as_str(&self) -> &str {
24        match self {
25            Self::CasNumber => "CAS",
26            Self::PubChemCid => "PubChem CID",
27            Self::Inchi => "InChI",
28            Self::InchiKey => "InChIKey",
29            Self::Smiles => "SMILES",
30            Self::Custom(namespace) => namespace.as_str(),
31        }
32    }
33}
34
35impl fmt::Display for CompoundRegistry {
36    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
37        formatter.write_str(self.as_str())
38    }
39}