Skip to main content

open_library_api_rs/models/
changes.rs

1// v0.0.1
2use serde::{Deserialize, Serialize};
3
4use super::common::ChangeKind;
5
6/// One entry in the recent-changes feed.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct RecentChange {
9    #[serde(default)]
10    pub kind: Option<ChangeKind>,
11    #[serde(default)]
12    pub key: Option<String>,
13    #[serde(default)]
14    pub author: Option<ChangeAuthor>,
15    #[serde(default)]
16    pub ip: Option<String>,
17    #[serde(default)]
18    pub timestamp: Option<String>,
19    #[serde(default)]
20    pub comment: Option<String>,
21    #[serde(default)]
22    pub changes: Option<Vec<ChangeDetail>>,
23}
24
25/// The user who made a change.
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct ChangeAuthor {
28    #[serde(default)]
29    pub key: Option<String>,
30    #[serde(default)]
31    pub displayname: Option<String>,
32}
33
34/// An individual field change within a recent-changes entry.
35#[derive(Debug, Clone, Serialize, Deserialize)]
36pub struct ChangeDetail {
37    #[serde(default)]
38    pub key: Option<String>,
39    #[serde(default)]
40    pub value: Option<serde_json::Value>,
41    #[serde(rename = "type")]
42    #[serde(default)]
43    pub kind: Option<String>,
44}
45
46/// Parameters for the recent-changes endpoints.
47#[derive(Debug, Clone, Default)]
48pub struct ChangesParams {
49    pub limit: Option<u32>,
50    pub offset: Option<u32>,
51    /// If `Some(true)`, include bot edits; if `Some(false)`, exclude them.
52    pub bot: Option<bool>,
53}