pub struct PubChemClient { /* private fields */ }Expand description
PubChem REST API client with built-in rate limiting and in-memory caching.
Cheap to clone — all internal state is reference-counted.
Implementations§
Source§impl PubChemClient
impl PubChemClient
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a client with PubChem’s default rate limit (5 req/s).
§Panics
Panics if the TLS backend cannot be initialised (extremely rare; indicates a broken system environment).
Sourcepub fn builder() -> PubChemClientBuilder
pub fn builder() -> PubChemClientBuilder
Start building a customised client.
Sourcepub async fn lookup(&self, id: &SubstanceIdentifier) -> Result<PubChemCompound>
pub async fn lookup(&self, id: &SubstanceIdentifier) -> Result<PubChemCompound>
Look up a compound by the best available identifier.
Priority: CAS number → InChIKey → InChI → SMILES → IUPAC name.
Results are cached by CID, so repeated calls for the same compound are free after the first network request.
§Errors
PubChemError::NotFound— no compound matched.PubChemError::NoUsableIdentifier— the identifier has no usable field.PubChemError::Http— network or server error.PubChemError::RateLimitExceeded— PubChem returned HTTP 429.
Sourcepub async fn enrich(&self, id: &mut SubstanceIdentifier) -> Result<()>
pub async fn enrich(&self, id: &mut SubstanceIdentifier) -> Result<()>
Enrich id in place with PubChem data, filling any missing fields.
On PubChemError::NotFound or PubChemError::NoUsableIdentifier
this is a silent no-op (enrichment is best-effort).
Other errors (network, parse) are propagated.
Trait Implementations§
Source§impl Clone for PubChemClient
impl Clone for PubChemClient
Source§fn clone(&self) -> PubChemClient
fn clone(&self) -> PubChemClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more