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 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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PubChemClient
impl Debug for PubChemClient
Auto Trait Implementations§
impl Freeze for PubChemClient
impl !RefUnwindSafe for PubChemClient
impl Send for PubChemClient
impl Sync for PubChemClient
impl Unpin for PubChemClient
impl UnsafeUnpin for PubChemClient
impl !UnwindSafe for PubChemClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more