pub struct EuropePmcClient { /* private fields */ }Expand description
Client for the Europe PMC REST API.
Provides cross-source search, JATS full-text retrieval, reference and
citation graphs, external database links, and supplementary file downloads.
No API key is required; transport-level configuration (timeout, user agent,
retry, rate limiting, caching) is shared with the rest of the workspace via
ClientConfig.
§Example
use pubmed_client::europe_pmc::{EuropePmcClient, EuropePmcId};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = EuropePmcClient::new();
let results = client.search("malaria vaccine", 10).await?;
for r in &results {
println!("{}/{}: {}", r.source, r.id, r.title.as_deref().unwrap_or(""));
}
let article = client.fetch_full_text(&EuropePmcId::pmc("PMC3258128")?).await?;
println!("Title: {}", article.title().unwrap_or("Untitled"));
Ok(())
}Implementations§
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub async fn get_citations_page(
&self,
id: &EuropePmcId,
page: u32,
page_size: u32,
) -> Result<EuropePmcCitationList>
pub async fn get_citations_page( &self, id: &EuropePmcId, page: u32, page_size: u32, ) -> Result<EuropePmcCitationList>
Fetch a single page of the citation list (citing articles) for a record.
Sourcepub async fn get_citations(
&self,
id: &EuropePmcId,
) -> Result<Vec<EuropePmcCitation>>
pub async fn get_citations( &self, id: &EuropePmcId, ) -> Result<Vec<EuropePmcCitation>>
Fetch all citing articles for a record, following page numbers until exhausted.
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub fn with_config(config: ClientConfig) -> Self
pub fn with_config(config: ClientConfig) -> Self
Create a new Europe PMC client with custom configuration.
Transport settings (timeout, user agent, retry, rate limit, cache) are
taken from config. The NCBI-specific base_url field is ignored; the
Europe PMC base URL is used instead.
Sourcepub fn with_client(client: Client) -> Self
pub fn with_client(client: Client) -> Self
Create a new Europe PMC client with a custom HTTP client and default config.
Sourcepub fn with_base_url(self, base_url: String) -> Self
pub fn with_base_url(self, base_url: String) -> Self
Override the base URL (e.g. to target a proxy or a wiremock test server).
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear the full-text cache, if one is configured.
Sourcepub fn cache_entry_count(&self) -> u64
pub fn cache_entry_count(&self) -> u64
Return the number of cached full-text entries (best-effort).
Sourcepub async fn sync_cache(&self)
pub async fn sync_cache(&self)
Flush pending cache operations (useful in tests).
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub async fn fetch_full_text(&self, id: &EuropePmcId) -> Result<PmcArticle>
pub async fn fetch_full_text(&self, id: &EuropePmcId) -> Result<PmcArticle>
Fetch and parse the full text of a Europe PMC record into a PmcArticle.
Europe PMC serves full text as JATS XML, which is parsed by the same
parser used for NCBI PMC. Parsing into a PmcArticle requires a PMC id,
so this method only supports PMC-sourced records; for other sources use
EuropePmcClient::fetch_full_text_xml to get the raw JATS instead.
Results are cached when a cache is configured (key epmc-ft:<source>:<id>).
§Errors
ParseError::PmcNotAvailable— the record is not PMC-sourced.crate::PubMedError::ApiError— the HTTP request failed.
Sourcepub async fn fetch_full_text_xml(&self, id: &EuropePmcId) -> Result<String>
pub async fn fetch_full_text_xml(&self, id: &EuropePmcId) -> Result<String>
Fetch the raw JATS XML full text for a Europe PMC record.
Works for any source that has full text available. Returns the response body verbatim.
Unlike the list endpoints, Europe PMC addresses full text by the record
id alone (/{id}/fullTextXML) rather than by (source, id); a
source-qualified path answers 404.
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub async fn get_database_links_page(
&self,
id: &EuropePmcId,
page: u32,
page_size: u32,
) -> Result<EuropePmcDatabaseLinkList>
pub async fn get_database_links_page( &self, id: &EuropePmcId, page: u32, page_size: u32, ) -> Result<EuropePmcDatabaseLinkList>
Fetch a single page of external database cross-references for a record.
Sourcepub async fn get_database_links(
&self,
id: &EuropePmcId,
) -> Result<Vec<EuropePmcDatabaseLink>>
pub async fn get_database_links( &self, id: &EuropePmcId, ) -> Result<Vec<EuropePmcDatabaseLink>>
Fetch all external database cross-references for a record.
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub async fn get_references_page(
&self,
id: &EuropePmcId,
page: u32,
page_size: u32,
) -> Result<EuropePmcReferenceList>
pub async fn get_references_page( &self, id: &EuropePmcId, page: u32, page_size: u32, ) -> Result<EuropePmcReferenceList>
Fetch a single page of the reference list (works cited) for a record.
Sourcepub async fn get_references(
&self,
id: &EuropePmcId,
) -> Result<Vec<EuropePmcReference>>
pub async fn get_references( &self, id: &EuropePmcId, ) -> Result<Vec<EuropePmcReference>>
Fetch all references for a record, following page numbers until exhausted.
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub async fn search(
&self,
query: &str,
limit: usize,
) -> Result<Vec<EuropePmcResult>>
pub async fn search( &self, query: &str, limit: usize, ) -> Result<Vec<EuropePmcResult>>
Search Europe PMC and return up to limit lite results.
Convenience wrapper over EuropePmcClient::search_all using
ResultType::Lite. For cursor control or core detail, use
EuropePmcClient::search_page / EuropePmcClient::search_all.
Sourcepub async fn search_page(
&self,
query: &str,
opts: &EuropePmcSearchOptions,
) -> Result<EuropePmcSearchResponse>
pub async fn search_page( &self, query: &str, opts: &EuropePmcSearchOptions, ) -> Result<EuropePmcSearchResponse>
Fetch a single page of search results.
The returned EuropePmcSearchResponse::next_cursor_mark is the cursor
to pass back via opts.cursor_mark to fetch the following page.
Sourcepub async fn search_all(
&self,
query: &str,
max_results: usize,
opts: &EuropePmcSearchOptions,
) -> Result<Vec<EuropePmcResult>>
pub async fn search_all( &self, query: &str, max_results: usize, opts: &EuropePmcSearchOptions, ) -> Result<Vec<EuropePmcResult>>
Fetch search results across pages until max_results is reached or the
result set is exhausted.
Follows the nextCursorMark chain. Europe PMC signals the end of results
by returning the same cursor it was given, so the loop also stops when the
cursor stops advancing.
Source§impl EuropePmcClient
impl EuropePmcClient
Sourcepub async fn fetch_supplementary_files(
&self,
id: &EuropePmcId,
) -> Result<Vec<u8>>
pub async fn fetch_supplementary_files( &self, id: &EuropePmcId, ) -> Result<Vec<u8>>
Fetch the supplementary-files ZIP archive for a record into memory.
Returns the raw bytes of the ZIP. As with full text, Europe PMC
addresses this endpoint by the record id alone
(/{id}/supplementaryFiles) rather than by (source, id).
Sourcepub async fn download_supplementary_files(
&self,
id: &EuropePmcId,
output_path: impl AsRef<Path>,
) -> Result<PathBuf>
pub async fn download_supplementary_files( &self, id: &EuropePmcId, output_path: impl AsRef<Path>, ) -> Result<PathBuf>
Download the supplementary-files ZIP archive for a record to output_path.
output_path is the full path of the ZIP file to write. Parent
directories are created if needed. Returns the written path.
Trait Implementations§
Source§impl Clone for EuropePmcClient
impl Clone for EuropePmcClient
Source§fn clone(&self) -> EuropePmcClient
fn clone(&self) -> EuropePmcClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for EuropePmcClient
impl !RefUnwindSafe for EuropePmcClient
impl Send for EuropePmcClient
impl Sync for EuropePmcClient
impl Unpin for EuropePmcClient
impl !UnwindSafe for EuropePmcClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().