Skip to main content

Engine

Struct Engine 

Source
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

Source

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

Source

pub async fn check( &self, claims: &[Claim], limit: u32, progress: impl FnMut(usize), ) -> Vec<Checked>

Verifies every claim and derives findings, including duplicates across claims; in claim order. progress is called with each claim’s index as it completes, in any order.

Source§

impl Engine

Source

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.

Source

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

Source

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

Source

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

Source

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

Source

pub async fn resolve(&self, claim: &Claim, limit: u32) -> ResolveReport

Gathers and scores every candidate for claim. limit caps results per provider search.

Source

pub async fn verify(&self, claim: &Claim, limit: u32) -> Verification

Decides whether claim refers to a real work, stopping early once it does.

Source

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.

Source

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

Source

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

Source

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

Source

pub fn builder() -> EngineBuilder

Source

pub fn with_options(&self, options: CallOptions) -> Engine

This engine for a caller with different patience; it shares everything else.

Source

pub fn options(&self) -> CallOptions

Source

pub fn unavailable(&self) -> Vec<(ProviderId, Error)>

Providers refusing calls now, and why: a spent quota (until it resets), rejected credentials, or an open circuit breaker.

Source

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.

Source

pub fn providers(&self) -> impl Iterator<Item = &Arc<dyn Provider>>

Registered providers, in priority order.

Trait Implementations§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Engine

§

impl !UnwindSafe for Engine

§

impl Forget for Engine

§

impl Freeze for Engine

§

impl Move for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

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.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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