relegram/responses/
queries.rs1use responses::user::User;
2use responses::message::Message;
3use super::raw::queries;
4use error::UnexpectedResponse;
5use try_from::TryFrom;
6
7#[derive(Debug, Clone)]
8pub struct CallbackQuery {
9 pub id: String,
10 pub from: User,
11 pub message: Option<Message>,
12 pub inline_message_id: Option<String>,
13 pub chat_instance: String,
14 pub data: Option<String>,
15 pub game_short_name: Option<String>,
16}
17
18impl TryFrom<queries::CallbackQuery> for CallbackQuery {
19 type Error = UnexpectedResponse;
20
21 fn try_from(value: queries::CallbackQuery) -> Result<Self, UnexpectedResponse> {
22 match value {
23 queries::CallbackQuery { id, from, message, inline_message_id, data, game_short_name, chat_instance } => {
24 let message =
25 message
26 .map(TryFrom::try_from)
27 .map_or(Ok(None), |x| x.map(Some));
28 message.map(|message| CallbackQuery {
29 id,
30 from,
31 message,
32 inline_message_id,
33 chat_instance,
34 data,
35 game_short_name,
36 })
37 }
38 }
39 }
40}