EuropePmcClient

Struct EuropePmcClient 

Source
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

Source

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.

Source

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

Source

pub fn new() -> Self

Create a new Europe PMC client with default configuration.

Source

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.

Source

pub fn with_client(client: Client) -> Self

Create a new Europe PMC client with a custom HTTP client and default config.

Source

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).

Source

pub async fn clear_cache(&self)

Clear the full-text cache, if one is configured.

Source

pub fn cache_entry_count(&self) -> u64

Return the number of cached full-text entries (best-effort).

Source

pub async fn sync_cache(&self)

Flush pending cache operations (useful in tests).

Source§

impl EuropePmcClient

Source

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
Source

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

Fetch a single page of external database cross-references for a record.

Fetch all external database cross-references for a record.

Source§

impl EuropePmcClient

Source

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.

Source

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

Source

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.

Source

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.

Source

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

Source

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).

Source

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

Source§

fn clone(&self) -> EuropePmcClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for EuropePmcClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,