tbot/contexts/
edited_photo.rs

1use crate::{
2    contexts::fields::{self, Album, AnyText, Caption},
3    types::{message::Text, PhotoSize},
4};
5
6edited_message! {
7    struct EditedPhoto {
8        /// The photo.
9        photo: Vec<PhotoSize>,
10        /// The caption of the photo.
11        caption: Text,
12        /// The media group's ID.
13        media_group_id: Option<String>,
14    } -> EventLoop::edited_photo
15
16    fn new(caption: Text, media_group_id: Option<String>,) -> Self {
17        Self {
18            caption: caption,
19            media_group_id: media_group_id,
20        }
21    }
22}
23
24impl fields::Photo for EditedPhoto {
25    #[must_use]
26    fn photo(&self) -> &[PhotoSize] {
27        &self.photo[..]
28    }
29}
30
31impl Caption for EditedPhoto {
32    #[must_use]
33    fn caption(&self) -> &Text {
34        &self.caption
35    }
36}
37
38impl AnyText for EditedPhoto {
39    #[must_use]
40    fn text(&self) -> &Text {
41        &self.caption
42    }
43}
44
45impl Album for EditedPhoto {
46    #[must_use]
47    fn media_group_id(&self) -> Option<&str> {
48        self.media_group_id.as_ref().map(String::as_ref)
49    }
50}