conogram/methods/
set_sticker_mask_position.rs

1use std::{
2    future::{Future, IntoFuture},
3    pin::Pin,
4};
5
6use serde::Serialize;
7
8use crate::{
9    api::API, entities::mask_position::MaskPosition, errors::ConogramError, impl_into_future,
10    request::RequestT,
11};
12
13#[derive(Debug, Clone, Serialize)]
14pub struct SetStickerMaskPositionParams {
15    pub sticker: String,
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub mask_position: Option<MaskPosition>,
18}
19
20impl_into_future!(SetStickerMaskPositionRequest<'a>);
21
22///Use this method to change the [mask position](https://core.telegram.org/bots/api/#maskposition) of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns *True* on success.
23#[derive(Clone)]
24pub struct SetStickerMaskPositionRequest<'a> {
25    api: &'a API,
26    params: SetStickerMaskPositionParams,
27}
28
29impl<'a> RequestT for SetStickerMaskPositionRequest<'a> {
30    type ParamsType = SetStickerMaskPositionParams;
31    type ReturnType = bool;
32    fn get_name() -> &'static str {
33        "setStickerMaskPosition"
34    }
35    fn get_api_ref(&self) -> &API {
36        self.api
37    }
38    fn get_params_ref(&self) -> &Self::ParamsType {
39        &self.params
40    }
41    fn is_multipart() -> bool {
42        false
43    }
44}
45impl<'a> SetStickerMaskPositionRequest<'a> {
46    pub fn new(api: &'a API, sticker: impl Into<String>) -> Self {
47        Self {
48            api,
49            params: SetStickerMaskPositionParams {
50                sticker: sticker.into(),
51                mask_position: Option::default(),
52            },
53        }
54    }
55
56    ///File identifier of the sticker
57    #[must_use]
58    pub fn sticker(mut self, sticker: impl Into<String>) -> Self {
59        self.params.sticker = sticker.into();
60        self
61    }
62
63    ///A JSON-serialized object with the position where the mask should be placed on faces. Omit the parameter to remove the mask position.
64    #[must_use]
65    pub fn mask_position(mut self, mask_position: impl Into<MaskPosition>) -> Self {
66        self.params.mask_position = Some(mask_position.into());
67        self
68    }
69}
70
71impl API {
72    ///Use this method to change the [mask position](https://core.telegram.org/bots/api/#maskposition) of a mask sticker. The sticker must belong to a sticker set that was created by the bot. Returns *True* on success.
73    pub fn set_sticker_mask_position(
74        &self,
75        sticker: impl Into<String>,
76    ) -> SetStickerMaskPositionRequest {
77        SetStickerMaskPositionRequest::new(self, sticker)
78    }
79}
80
81// Divider: all content below this line will be preserved after code regen