Skip to main content

ss_tools/tutorials/
step_2.rs

1//! # Step 2 - Paper & Author Structs
2//!
3//! This tutorial covers the main data structures used in `ss-tools`.
4//!
5//! ## Paper Struct
6//!
7//! The [`Paper`](crate::structs::Paper) struct represents a scientific paper from Semantic Scholar.
8//! All fields are optional since the API returns only requested fields.
9//!
10//! ```rust
11//! use ss_tools::structs::Paper;
12//!
13//! // Paper struct has many optional fields
14//! let paper = Paper::default();
15//! assert!(paper.paper_id.is_none());
16//! assert!(paper.title.is_none());
17//! ```
18//!
19//! ### Key Paper Fields
20//!
21//! | Field | Type | Description |
22//! |-------|------|-------------|
23//! | `paper_id` | `Option<String>` | Unique paper ID |
24//! | `title` | `Option<String>` | Paper title |
25//! | `abstract_text` | `Option<String>` | Paper abstract |
26//! | `year` | `Option<u32>` | Publication year |
27//! | `citation_count` | `Option<u32>` | Number of citations |
28//! | `reference_count` | `Option<u32>` | Number of references |
29//! | `authors` | `Option<Vec<Author>>` | List of authors |
30//! | `external_ids` | `Option<ExternalIds>` | External IDs (ArXiv, DOI, etc.) |
31//! | `open_access_pdf` | `Option<OpenAccessPdf>` | Open access PDF URL |
32//!
33//! ## ExternalIds Struct
34//!
35//! The [`ExternalIds`](crate::structs::ExternalIds) struct provides access to external identifiers
36//! such as ArXiv ID, DOI, DBLP, PubMed, MAG, ACL, and CorpusId.
37//!
38//! ```rust
39//! use ss_tools::structs::ExternalIds;
40//!
41//! let ids = ExternalIds::default();
42//! assert!(ids.arxiv.is_none());
43//! assert!(ids.doi.is_none());
44//! ```
45//!
46//! ### ExternalIds Fields
47//!
48//! | Field | Type | Description |
49//! |-------|------|-------------|
50//! | `arxiv` | `Option<String>` | ArXiv ID (e.g., "1706.03762") |
51//! | `doi` | `Option<String>` | DOI (e.g., "10.48550/arXiv.1706.03762") |
52//! | `dblp` | `Option<String>` | DBLP ID |
53//! | `pubmed` | `Option<String>` | PubMed ID |
54//! | `pubmed_central` | `Option<String>` | PubMed Central ID |
55//! | `mag` | `Option<String>` | Microsoft Academic Graph ID |
56//! | `acl` | `Option<String>` | ACL Anthology ID |
57//! | `corpus_id` | `Option<u64>` | Semantic Scholar Corpus ID |
58//!
59//! ## Author Struct
60//!
61//! The [`Author`](crate::structs::Author) struct represents an author from Semantic Scholar.
62//!
63//! ```rust
64//! use ss_tools::structs::Author;
65//!
66//! let author = Author::default();
67//! assert!(author.author_id.is_none());
68//! assert!(author.name.is_none());
69//! ```
70//!
71//! ### Key Author Fields
72//!
73//! | Field | Type | Description |
74//! |-------|------|-------------|
75//! | `author_id` | `Option<String>` | Unique author ID |
76//! | `name` | `Option<String>` | Author name |
77//! | `affiliations` | `Option<Vec<String>>` | Author affiliations |
78//! | `paper_count` | `Option<u32>` | Number of papers |
79//! | `citation_count` | `Option<u32>` | Total citations |
80//! | `hindex` | `Option<u32>` | H-index |
81//!
82//! ## Field Enums
83//!
84//! ### PaperField
85//!
86//! Use [`PaperField`](crate::structs::PaperField) to specify which paper fields to request.
87//!
88//! ```rust
89//! use ss_tools::structs::PaperField;
90//!
91//! let fields = vec![
92//!     PaperField::Title,
93//!     PaperField::Abstract,
94//!     PaperField::Year,
95//!     PaperField::CitationCount,
96//!     PaperField::ExternalIds,
97//! ];
98//! ```
99//!
100//! ### AuthorField
101//!
102//! Use [`AuthorField`](crate::structs::AuthorField) to specify which author fields to request.
103//!
104//! ```rust
105//! use ss_tools::structs::AuthorField;
106//!
107//! let fields = vec![
108//!     AuthorField::Name,
109//!     AuthorField::PaperCount,
110//!     AuthorField::CitationCount,
111//!     AuthorField::HIndex,
112//! ];
113//! ```
114//!
115//! ## Response Structs
116//!
117//! ### AuthorSearchResponse
118//!
119//! Response from searching authors by name.
120//!
121//! ```rust
122//! use ss_tools::structs::AuthorSearchResponse;
123//!
124//! // Contains offset, next, total, and data (Vec<Author>)
125//! let response = AuthorSearchResponse::default();
126//! assert!(response.data.is_empty());
127//! ```
128//!
129//! ### AuthorPapersResponse
130//!
131//! Response from querying an author's papers.
132//!
133//! ```rust
134//! use ss_tools::structs::AuthorPapersResponse;
135//!
136//! // Contains offset, next, and data (Vec<Paper>)
137//! let response = AuthorPapersResponse::default();
138//! assert!(response.data.is_empty());
139//! ```
140//!
141//! ### PaperAuthorsResponse
142//!
143//! Response from querying a paper's authors.
144//!
145//! ```rust
146//! use ss_tools::structs::PaperAuthorsResponse;
147//!
148//! // Contains offset, next, and data (Vec<Author>)
149//! let response = PaperAuthorsResponse::default();
150//! assert!(response.data.is_empty());
151//! ```