nvd_api/
pagination.rs

1//! Paging management for unified API response
2use crate::error::ErrorResponse;
3use crate::v2::products::{MatchStrings, Products};
4use crate::v2::vulnerabilities::{CveChanges, Vulnerabilities};
5use chrono::NaiveDateTime;
6use serde::{Deserialize, Serialize};
7
8/// The API returns seven primary objects in the body of the response: resultsPerPage, startIndex, totalResults, format, version, timestamp, and [Object].
9/// The format and version objects identify the format and version of the API response. timestamp identifies when the response was generated.
10#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
11#[serde(rename_all = "camelCase")]
12pub struct ListResponse {
13  /// results [Object]
14  #[serde(flatten)]
15  pub results: Object,
16  /// pagination [Pagination]
17  #[serde(flatten)]
18  pub pagination: Pagination,
19  /// format
20  pub format: String,
21  /// version
22  pub version: String,
23  /// timestamp
24  pub timestamp: NaiveDateTime,
25}
26/// If the value of totalResults is greater than the value of resultsPerPage, then additional requests are necessary to return the remaining [Object].
27/// The parameter startIndex may be used in subsequent requests to identify the starting point for the next request. More information and the best practices for using resultsPerPage and startIndex are described above.
28///
29#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
30#[serde(rename_all = "camelCase")]
31pub struct Pagination {
32  /// resultsPerPage
33  pub results_per_page: u32,
34  /// startIndex
35  pub start_index: u32,
36  /// totalResults
37  pub total_results: u32,
38}
39#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
40#[serde(rename_all = "camelCase")]
41pub enum Object {
42  Vulnerabilities(Vec<Vulnerabilities>),
43  CveChanges(Vec<CveChanges>),
44  Products(Vec<Products>),
45  MatchStrings(Vec<MatchStrings>),
46  Error {
47    #[serde(flatten)]
48    error: ErrorResponse,
49  },
50}