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//!
31//! ## Author Struct
32//!
33//! The [`Author`](crate::structs::Author) struct represents an author from Semantic Scholar.
34//!
35//! ```rust
36//! use ss_tools::structs::Author;
37//!
38//! let author = Author::default();
39//! assert!(author.author_id.is_none());
40//! assert!(author.name.is_none());
41//! ```
42//!
43//! ### Key Author Fields
44//!
45//! | Field | Type | Description |
46//! |-------|------|-------------|
47//! | `author_id` | `Option<String>` | Unique author ID |
48//! | `name` | `Option<String>` | Author name |
49//! | `affiliations` | `Option<Vec<String>>` | Author affiliations |
50//! | `paper_count` | `Option<u32>` | Number of papers |
51//! | `citation_count` | `Option<u32>` | Total citations |
52//! | `hindex` | `Option<u32>` | H-index |
53//!
54//! ## Field Enums
55//!
56//! ### PaperField
57//!
58//! Use [`PaperField`](crate::structs::PaperField) to specify which paper fields to request.
59//!
60//! ```rust
61//! use ss_tools::structs::PaperField;
62//!
63//! let fields = vec![
64//!     PaperField::Title,
65//!     PaperField::Abstract,
66//!     PaperField::Year,
67//!     PaperField::CitationCount,
68//! ];
69//! ```
70//!
71//! ### AuthorField
72//!
73//! Use [`AuthorField`](crate::structs::AuthorField) to specify which author fields to request.
74//!
75//! ```rust
76//! use ss_tools::structs::AuthorField;
77//!
78//! let fields = vec![
79//!     AuthorField::Name,
80//!     AuthorField::PaperCount,
81//!     AuthorField::CitationCount,
82//!     AuthorField::HIndex,
83//! ];
84//! ```
85//!
86//! ## Response Structs
87//!
88//! ### AuthorSearchResponse
89//!
90//! Response from searching authors by name.
91//!
92//! ```rust
93//! use ss_tools::structs::AuthorSearchResponse;
94//!
95//! // Contains offset, next, total, and data (Vec<Author>)
96//! let response = AuthorSearchResponse::default();
97//! assert!(response.data.is_empty());
98//! ```
99//!
100//! ### AuthorPapersResponse
101//!
102//! Response from querying an author's papers.
103//!
104//! ```rust
105//! use ss_tools::structs::AuthorPapersResponse;
106//!
107//! // Contains offset, next, and data (Vec<Paper>)
108//! let response = AuthorPapersResponse::default();
109//! assert!(response.data.is_empty());
110//! ```
111//!
112//! ### PaperAuthorsResponse
113//!
114//! Response from querying a paper's authors.
115//!
116//! ```rust
117//! use ss_tools::structs::PaperAuthorsResponse;
118//!
119//! // Contains offset, next, and data (Vec<Author>)
120//! let response = PaperAuthorsResponse::default();
121//! assert!(response.data.is_empty());
122//! ```