1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use crate::{
    contexts::{
        fields,
        methods::{Copyable, Forwardable, Pinnable},
    },
    types::{message, Chat},
};

callback! {
    struct MessageDataCallback {
        /// Data from the callback.
        data: String,
        message: crate::types::Message,
    } -> EventLoop::message_data_callback
}

impl fields::Message for MessageDataCallback {
    fn message_id(&self) -> message::Id {
        self.message.id
    }

    fn from(&self) -> Option<&message::From> {
        self.message.from.as_ref()
    }

    fn date(&self) -> i64 {
        self.message.date
    }

    fn chat(&self) -> &Chat {
        &self.message.chat
    }
}

impl Copyable for MessageDataCallback {}
impl Forwardable for MessageDataCallback {}
impl Pinnable for MessageDataCallback {}

callback! {
    struct InlineDataCallback {
        /// Data from the callback.
        data: String,
        inline_message_id: String,
    } -> EventLoop::inline_data_callback
}