pub struct Engine { /* private fields */ }Expand description
Cheap to clone: clones, and views made with
with_options, share the cache, providers’
pacing and requests in flight. Hold one per process.
Implementations§
Source§impl Engine
impl Engine
Sourcepub async fn abstracts(&self, works: &[&SourceRecord]) -> AbstractsReport
pub async fn abstracts(&self, works: &[&SourceRecord]) -> AbstractsReport
The abstract for each work: its own record’s if present, otherwise the first other provider’s (by priority) that has one. Works are identified by their records’ identifiers; pass a record with merged identifiers to widen the search.
Source§impl Engine
impl Engine
Sourcepub async fn add_notices(&self, report: &mut LookupReport)
pub async fn add_notices(&self, report: &mut LookupReport)
Adds editorial notices, in both directions, to records that another provider supplied, from the providers that report them in detail (Crossref): an original then lists its corrections and retractions, a correction the work it corrects. Notices are typed as such and dated by when they appeared. Batched and cached, like lookups.
Sourcepub async fn add_open_access(&self, report: &mut LookupReport)
pub async fn add_open_access(&self, report: &mut LookupReport)
Fills in where works can be read free, for records whose provider didn’t say, from the first provider (by priority) that does.
Source§impl Engine
impl Engine
Sourcepub async fn lookup_inputs(
&self,
inputs: &[String],
extras: Extras,
) -> InputsReport
pub async fn lookup_inputs( &self, inputs: &[String], extras: Extras, ) -> InputsReport
Looks up each input as written: one batched lookup, a second for
DOIs not found unless their trailing punctuation is kept, then
extras. Never fails as a whole.
Source§impl Engine
impl Engine
Sourcepub async fn lookup(&self, ids: &[WorkId], fields: FieldSet) -> LookupReport
pub async fn lookup(&self, ids: &[WorkId], fields: FieldSet) -> LookupReport
Looks up every ID, falling through providers by priority. Never fails as a whole: per-ID outcomes are in the report.
Source§impl Engine
impl Engine
Sourcepub async fn cross_check(
&self,
report: &mut LookupReport,
) -> Vec<Vec<Disagreement>>
pub async fn cross_check( &self, report: &mut LookupReport, ) -> Vec<Vec<Disagreement>>
For each result, where its record contradicts the registry’s record of the same DOI; empty when they agree, or there’s nothing to compare (no DOI, or the registry answered itself). Cached, like lookups.
Source§impl Engine
impl Engine
Sourcepub async fn resolve(&self, claim: &Claim, limit: u32) -> ResolveReport
pub async fn resolve(&self, claim: &Claim, limit: u32) -> ResolveReport
Gathers and scores every candidate for claim. limit caps results
per provider search.
Sourcepub async fn verify(&self, claim: &Claim, limit: u32) -> Verification
pub async fn verify(&self, claim: &Claim, limit: u32) -> Verification
Decides whether claim refers to a real work, stopping early once it
does.
Sourcepub fn verify_many<'a>(
&'a self,
claims: &'a [Claim],
limit: u32,
) -> impl Stream<Item = (usize, Verification)> + 'a
pub fn verify_many<'a>( &'a self, claims: &'a [Claim], limit: u32, ) -> impl Stream<Item = (usize, Verification)> + 'a
Verifies many claims, several at a time (each provider’s pacing still applies), yielding each with its claim’s index as soon as it completes: a slow claim doesn’t hold up the rest.
Sourcepub async fn prefetch(&self, claims: &[Claim]) -> LookupReport
pub async fn prefetch(&self, claims: &[Claim]) -> LookupReport
Looks up every identifier the claims assert, in one batched call per provider. With a cache attached, this warms it so verifying the claims one by one (and streaming results) doesn’t look them up one by one.
Source§impl Engine
impl Engine
Sourcepub async fn search(
&self,
source: Option<&str>,
query: &SearchQuery,
) -> Result<SearchReport, EngineError>
pub async fn search( &self, source: Option<&str>, query: &SearchQuery, ) -> Result<SearchReport, EngineError>
Searches one provider: source if given, otherwise the first that
supports the query’s mode.
Source§impl Engine
impl Engine
Sourcepub async fn latest_versions(&self, works: &[&SourceRecord]) -> VersionsReport
pub async fn latest_versions(&self, works: &[&SourceRecord]) -> VersionsReport
The latest version of each work its record says is superseded
(Work::newer_version), asking
the providers that report notices. One batched lookup per step along
the chains.
Source§impl Engine
impl Engine
pub fn builder() -> EngineBuilder
Sourcepub fn with_options(&self, options: CallOptions) -> Engine
pub fn with_options(&self, options: CallOptions) -> Engine
This engine for a caller with different patience; it shares everything else.
pub fn options(&self) -> CallOptions
Providers refusing calls now, and why: a spent quota (until it resets), rejected credentials, or an open circuit breaker.
Sourcepub fn budgets(&self) -> Vec<(ProviderId, Budget)>
pub fn budgets(&self) -> Vec<(ProviderId, Budget)>
Each provider’s budget as its last response reported it: what’s left without spending any. Only providers with budgets (OpenAlex) report one, and only once called.