rust_tdlib/types/
add_saved_animation.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Manually adds a new animation to the list of saved animations. The new animation is added to the beginning of the list. If the animation was already in the list, it is removed first. Only non-secret video animations with MIME type "video/mp4" can be added to the list
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct AddSavedAnimation {
8    #[doc(hidden)]
9    #[serde(rename(serialize = "@extra", deserialize = "@extra"))]
10    extra: Option<String>,
11    #[serde(rename(serialize = "@client_id", deserialize = "@client_id"))]
12    client_id: Option<i32>,
13    /// The animation file to be added. Only animations known to the server (i.e., successfully sent via a message) can be added to the list
14
15    #[serde(skip_serializing_if = "InputFile::_is_default")]
16    animation: InputFile,
17
18    #[serde(rename(serialize = "@type"))]
19    td_type: String,
20}
21
22impl RObject for AddSavedAnimation {
23    #[doc(hidden)]
24    fn extra(&self) -> Option<&str> {
25        self.extra.as_deref()
26    }
27    #[doc(hidden)]
28    fn client_id(&self) -> Option<i32> {
29        self.client_id
30    }
31}
32
33impl RFunction for AddSavedAnimation {}
34
35impl AddSavedAnimation {
36    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
37        Ok(serde_json::from_str(json.as_ref())?)
38    }
39    pub fn builder() -> AddSavedAnimationBuilder {
40        let mut inner = AddSavedAnimation::default();
41        inner.extra = Some(Uuid::new_v4().to_string());
42
43        inner.td_type = "addSavedAnimation".to_string();
44
45        AddSavedAnimationBuilder { inner }
46    }
47
48    pub fn animation(&self) -> &InputFile {
49        &self.animation
50    }
51}
52
53#[doc(hidden)]
54pub struct AddSavedAnimationBuilder {
55    inner: AddSavedAnimation,
56}
57
58#[deprecated]
59pub type RTDAddSavedAnimationBuilder = AddSavedAnimationBuilder;
60
61impl AddSavedAnimationBuilder {
62    pub fn build(&self) -> AddSavedAnimation {
63        self.inner.clone()
64    }
65
66    pub fn animation<T: AsRef<InputFile>>(&mut self, animation: T) -> &mut Self {
67        self.inner.animation = animation.as_ref().clone();
68        self
69    }
70}
71
72impl AsRef<AddSavedAnimation> for AddSavedAnimation {
73    fn as_ref(&self) -> &AddSavedAnimation {
74        self
75    }
76}
77
78impl AsRef<AddSavedAnimation> for AddSavedAnimationBuilder {
79    fn as_ref(&self) -> &AddSavedAnimation {
80        &self.inner
81    }
82}