pub struct CrossrefClient { /* private fields */ }Expand description
High-level API client.
Wraps the synchronous crossref::Crossref client (created fresh per
blocking call) and a shared reqwest::Client for async Unpaywall queries.
Implementations§
Source§impl CrossrefClient
impl CrossrefClient
Sourcepub fn new(config: Arc<Config>) -> Result<Self>
pub fn new(config: Arc<Config>) -> Result<Self>
Construct a new client from the resolved configuration.
Sourcepub fn new_with_base_urls(
config: Arc<Config>,
crossref_url: Option<String>,
unpaywall_url: Option<String>,
) -> Result<Self>
pub fn new_with_base_urls( config: Arc<Config>, crossref_url: Option<String>, unpaywall_url: Option<String>, ) -> Result<Self>
Construct a client with custom base URLs (for testing and integration environments).
Sourcepub async fn fetch_work(&self, doi: &str) -> Result<WorkMeta>
pub async fn fetch_work(&self, doi: &str) -> Result<WorkMeta>
Fetch metadata for a single DOI, then enrich with Unpaywall OA data.
Sourcepub async fn fetch_works(&self, dois: &[&str]) -> Vec<Result<WorkMeta>> ⓘ
pub async fn fetch_works(&self, dois: &[&str]) -> Vec<Result<WorkMeta>> ⓘ
Fetch metadata for multiple DOIs, returning results in order.
Sourcepub async fn search(&self, query: &SearchQuery) -> Result<SearchResult>
pub async fn search(&self, query: &SearchQuery) -> Result<SearchResult>
Execute a search query and return a page of results.
Sourcepub async fn fetch_unpaywall(&self, doi: &str) -> Result<UnpaywallRecord>
pub async fn fetch_unpaywall(&self, doi: &str) -> Result<UnpaywallRecord>
Query Unpaywall for OA information about a DOI.
Sourcepub async fn download_pdf(&self, doi: &str, dest_dir: &Path) -> Result<PathBuf>
pub async fn download_pdf(&self, doi: &str, dest_dir: &Path) -> Result<PathBuf>
Download the best OA PDF to dest_dir / <DOI>.pdf.
Falls back to EZproxy if the direct URL returns a non-200 status,
and finally returns a https://doi.org/{doi} link if no PDF is
accessible.
Returns the path where the file was written, or the best-effort URL if the PDF was not downloaded.
Auto Trait Implementations§
impl Freeze for CrossrefClient
impl !RefUnwindSafe for CrossrefClient
impl Send for CrossrefClient
impl Sync for CrossrefClient
impl Unpin for CrossrefClient
impl UnsafeUnpin for CrossrefClient
impl !UnwindSafe for CrossrefClient
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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