rs_uptobox/input/
update_file.rs

1use serde::Serialize;
2
3/// Input
4#[derive(Serialize, Debug)]
5pub struct UpdateFile {
6    /// The file code
7    file_code: String,
8
9    /// New file name value
10    #[serde(skip_serializing_if = "Option::is_none")]
11    new_name: Option<String>,
12
13    /// New description vale
14    #[serde(skip_serializing_if = "Option::is_none")]
15    description: Option<String>,
16
17    /// New password value
18    #[serde(skip_serializing_if = "Option::is_none")]
19    password: Option<String>,
20
21    /// New public status
22    #[serde(skip_serializing_if = "Option::is_none")]
23    public: Option<bool>,
24}
25
26impl UpdateFile {
27    /// Create a new instance
28    ///
29    /// **1 modifier is requiered for the request to succeed (eg. name, description)**
30    pub fn new(file_code: impl Into<String>) -> Self {
31        Self {
32            file_code: file_code.into(),
33            ..Default::default()
34        }
35    }
36
37    /// Update the file name
38    pub fn name(&mut self, name: impl Into<String>) -> &mut Self {
39        let _ = self.new_name.insert(name.into());
40        self
41    }
42
43    /// Udate the file description
44    pub fn description(&mut self, description: impl Into<String>) -> &mut Self {
45        let _ = self.description.insert(description.into());
46        self
47    }
48
49    /// Update the file password
50    pub fn password(&mut self, password: impl Into<String>) -> &mut Self {
51        let _ = self.password.insert(password.into());
52        self
53    }
54
55    /// Update the file public status
56    pub fn public(&mut self, public: bool) -> &mut Self {
57        let _ = self.public.insert(public);
58        self
59    }
60}
61
62impl Default for UpdateFile {
63    fn default() -> Self {
64        Self {
65            file_code: "".into(),
66            new_name: None,
67            description: None,
68            password: None,
69            public: None,
70        }
71    }
72}