pubmed_client/europe_pmc/
links.rs1use tracing::instrument;
4
5use pubmed_parser::europe_pmc::{
6 EuropePmcDatabaseLink, EuropePmcDatabaseLinkList, parse_database_links_response,
7};
8
9use crate::error::Result;
10
11use super::client::EuropePmcClient;
12use super::id::EuropePmcId;
13use super::paged::PagedList;
14
15const SEGMENT: &str = "databaseLinks";
17
18impl PagedList for EuropePmcDatabaseLinkList {
19 type Item = EuropePmcDatabaseLink;
20
21 fn hit_count(&self) -> u64 {
22 self.hit_count
23 }
24
25 fn into_items(self) -> Vec<Self::Item> {
26 self.links
27 }
28}
29
30impl EuropePmcClient {
31 #[instrument(skip(self), fields(id = %id, page, page_size))]
33 pub async fn get_database_links_page(
34 &self,
35 id: &EuropePmcId,
36 page: u32,
37 page_size: u32,
38 ) -> Result<EuropePmcDatabaseLinkList> {
39 self.get_list_page(id, SEGMENT, page, page_size, parse_database_links_response)
40 .await
41 }
42
43 #[instrument(skip(self), fields(id = %id))]
45 pub async fn get_database_links(&self, id: &EuropePmcId) -> Result<Vec<EuropePmcDatabaseLink>> {
46 self.collect_list_pages(id, SEGMENT, parse_database_links_response)
47 .await
48 }
49}