rust_tdlib/types/
delete_profile_photo.rs

1use crate::errors::Result;
2use crate::types::*;
3use uuid::Uuid;
4
5/// Deletes a profile photo
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct DeleteProfilePhoto {
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    /// Identifier of the profile photo to delete
14
15    #[serde(
16        deserialize_with = "super::_common::number_from_string",
17        serialize_with = "super::_common::string_to_number"
18    )]
19    #[serde(default)]
20    profile_photo_id: i64,
21
22    #[serde(rename(serialize = "@type"))]
23    td_type: String,
24}
25
26impl RObject for DeleteProfilePhoto {
27    #[doc(hidden)]
28    fn extra(&self) -> Option<&str> {
29        self.extra.as_deref()
30    }
31    #[doc(hidden)]
32    fn client_id(&self) -> Option<i32> {
33        self.client_id
34    }
35}
36
37impl RFunction for DeleteProfilePhoto {}
38
39impl DeleteProfilePhoto {
40    pub fn from_json<S: AsRef<str>>(json: S) -> Result<Self> {
41        Ok(serde_json::from_str(json.as_ref())?)
42    }
43    pub fn builder() -> DeleteProfilePhotoBuilder {
44        let mut inner = DeleteProfilePhoto::default();
45        inner.extra = Some(Uuid::new_v4().to_string());
46
47        inner.td_type = "deleteProfilePhoto".to_string();
48
49        DeleteProfilePhotoBuilder { inner }
50    }
51
52    pub fn profile_photo_id(&self) -> i64 {
53        self.profile_photo_id
54    }
55}
56
57#[doc(hidden)]
58pub struct DeleteProfilePhotoBuilder {
59    inner: DeleteProfilePhoto,
60}
61
62#[deprecated]
63pub type RTDDeleteProfilePhotoBuilder = DeleteProfilePhotoBuilder;
64
65impl DeleteProfilePhotoBuilder {
66    pub fn build(&self) -> DeleteProfilePhoto {
67        self.inner.clone()
68    }
69
70    pub fn profile_photo_id(&mut self, profile_photo_id: i64) -> &mut Self {
71        self.inner.profile_photo_id = profile_photo_id;
72        self
73    }
74}
75
76impl AsRef<DeleteProfilePhoto> for DeleteProfilePhoto {
77    fn as_ref(&self) -> &DeleteProfilePhoto {
78        self
79    }
80}
81
82impl AsRef<DeleteProfilePhoto> for DeleteProfilePhotoBuilder {
83    fn as_ref(&self) -> &DeleteProfilePhoto {
84        &self.inner
85    }
86}