wallabag_api/types/
patch_entry.rs1use chrono::{DateTime, Utc};
5
6use serde::{Deserialize, Serialize};
7
8use super::Entry;
9use crate::utils::serde::bool_to_int;
10
11#[derive(Deserialize, Serialize, Debug)]
16pub struct PatchEntry {
17 pub title: Option<String>,
18
19 pub tags: Option<Vec<String>>,
21
22 #[serde(serialize_with = "bool_to_int")]
23 pub archive: Option<bool>,
24 #[serde(serialize_with = "bool_to_int")]
25 pub starred: Option<bool>,
26 #[serde(serialize_with = "bool_to_int")]
27 pub public: Option<bool>,
28
29 pub content: Option<String>,
30 pub language: Option<String>,
31 pub preview_picture: Option<String>,
32 pub published_at: Option<DateTime<Utc>>,
33
34 pub authors: Option<String>,
36
37 pub origin_url: Option<String>,
38}
39
40impl Default for PatchEntry {
47 fn default() -> Self {
48 Self {
49 title: None,
50 tags: None,
51 archive: None,
52 starred: None,
53 public: None,
54 content: None,
55 language: None,
56 preview_picture: None,
57 published_at: None,
58 authors: None,
59 origin_url: None,
60 }
61 }
62}
63
64impl From<&Entry> for PatchEntry {
66 fn from(entry: &Entry) -> Self {
67 let tags: Vec<String> = entry.tags.iter().map(|t| t.label.clone()).collect();
68 Self {
69 title: entry.title.clone(),
70 tags: Some(tags),
71 archive: Some(entry.is_archived),
72 starred: Some(entry.is_starred),
73 public: Some(entry.is_public),
74 content: entry.content.clone(),
75 language: entry.language.clone(),
76 preview_picture: entry.preview_picture.clone(),
77 published_at: entry.published_at,
78 authors: None,
79 origin_url: entry.origin_url.clone(),
80 }
81 }
82}