[][src]Struct crossref::Crossref

pub struct Crossref {
    pub base_url: String,
    pub client: Client,
}

Struct for Crossref search API methods

Fields

base_url: String

use another base url than api.crossref.org

client: Client

the reqwest client that handles the requests

Methods

impl Crossref[src]

pub fn builder() -> CrossrefBuilder[src]

Constructs a new CrossrefBuilder.

This is the same as Crossref::builder().

pub fn funder_works(&self, ident: WorksIdentQuery) -> Result<WorkList>[src]

Return one page of the components's Work that match the query

pub fn member_works(&self, ident: WorksIdentQuery) -> Result<WorkList>[src]

Return one page of the components's Work that match the query

pub fn type_works(&self, ident: WorksIdentQuery) -> Result<WorkList>[src]

Return one page of the components's Work that match the query

pub fn journal_works(&self, ident: WorksIdentQuery) -> Result<WorkList>[src]

Return one page of the components's Work that match the query

pub fn prefix_works(&self, ident: WorksIdentQuery) -> Result<WorkList>[src]

Return one page of the components's Work that match the query

pub fn works<T: Into<WorkListQuery>>(&self, query: T) -> Result<WorkList>[src]

Return the Work items that match a certain query.

To search only by query terms use the convenience query method [Crossref::query_works]

Example

This code runs with edition 2018
use crossref::{Crossref, WorksQuery, WorksFilter, FieldQuery};
let client = Crossref::builder().build()?;

let query = WorksQuery::new("Machine Learning")
    .filter(WorksFilter::HasOrcid)
    .order(crossref::Order::Asc)
    .field_query(FieldQuery::author("Some Author"))
    .sort(crossref::Sort::Score);

let works = client.works(query)?;

Errors

This method fails if the works element expands to a bad route ResourceNotFound Fails if the response body doesn't have message field MissingMessage. Fails if anything else than a WorkList is returned as message UnexpectedItem

pub fn work(&self, doi: &str) -> Result<Work>[src]

Return the Work that is identified by the doi.

Errors

This method fails if the doi could not identified ResourceNotFound

Important traits for WorkListIterator<'a>
pub fn deep_page<T: Into<WorkListQuery>>(&self, query: T) -> WorkListIterator[src]

Deep paging results Deep paging is supported for all queries, that return a list of Work, WorkList. This function returns a new iterator over pages of Work, which is returned as bulk of items as a WorkList by crossref. Usually a single page WorkList contains 20 items.

Example

Iterate over all Works linked to search term Machine Learning

This code runs with edition 2018
use crossref::{Crossref, WorksQuery, Work};
let client = Crossref::builder().build()?;

let all_works: Vec<Work> = client.deep_page(WorksQuery::new("Machine Learning")).flat_map(|x|x.items).collect();

Example

Iterate over all the pages (WorkList) of the funder with id funder id by using a combined query. A single WorkList usually holds 20 Work items.

This code runs with edition 2018
use crossref::{Crossref, Funders, WorksQuery, Work, WorkList};
let client = Crossref::builder().build()?;

let all_funder_work_list: Vec<WorkList> = client.deep_page(WorksQuery::default().into_combined_query::<Funders>("funder id")).collect();

Example

Iterate over all Work items of a specfic funder directly.

This code runs with edition 2018
use crossref::{Crossref, Funders, WorksQuery, Work, WorkList};
let client = Crossref::builder().build()?;

let all_works: Vec<Work> = client.deep_page(WorksQuery::default()
        .into_combined_query::<Funders>("funder id"))
        .into_work_iter()
        .collect();

Example

Alternatively deep page without an iterator by handling the cursor directly

This code runs with edition 2018
use crossref::{Crossref, WorksQuery, WorksFilter};
let client = Crossref::builder().build()?;

// request a next-cursor first
let query = WorksQuery::new("Machine Learning")
    .new_cursor();

let works = client.works(query.clone())?;

// this continues from where this first response stopped
// if no more work items are available then a empty list will be returned
let deep_works = client.works(
    query.next_cursor(&works.next_cursor.unwrap())
)?;

pub fn work_agency(&self, doi: &str) -> Result<WorkAgency>[src]

Return the Agency that registers the Work identified by the doi.

Errors

This method fails if the doi could not identified ResourceNotFound

pub fn funders(&self, funders: FundersQuery) -> Result<FunderList>[src]

Return the matching Funders items.

pub fn funder(&self, id: &str) -> Result<Funder>[src]

Return the Funder for the id

pub fn members(&self, members: MembersQuery) -> Result<MemberList>[src]

Return the matching Members items.

pub fn member(&self, member_id: &str) -> Result<Member>[src]

Return the Member for the id

pub fn prefix(&self, id: &str) -> Result<Prefix>[src]

Return the Prefix for the id

pub fn journal(&self, id: &str) -> Result<Journal>[src]

Return a specific Journal

pub fn types(&self) -> Result<TypeList>[src]

Return all available Type

pub fn type_(&self, id: &Type) -> Result<CrossrefType>[src]

Return the Type for the id

pub fn random_dois(&self, len: usize) -> Result<Vec<String>>[src]

Get a random set of DOIs

Example

This code runs with edition 2018
use crossref::Crossref;
// this will return 10 random dois from the crossref api
let random_dois = client.random_dois(10)?;

Trait Implementations

impl Clone for Crossref[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Crossref[src]

Auto Trait Implementations

impl Send for Crossref

impl Unpin for Crossref

impl Sync for Crossref

impl !UnwindSafe for Crossref

impl !RefUnwindSafe for Crossref

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

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

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