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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use super::send_method;
use crate::{
errors,
internal::{BoxFuture, Client},
prelude::*,
types::inline_query,
Token,
};
use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
#[must_use = "methods do nothing unless turned into a future"]
pub struct AnswerInlineQuery<'a, C> {
#[serde(skip)]
client: &'a Client<C>,
#[serde(skip)]
token: Token,
inline_query_id: inline_query::id::Ref<'a>,
results: &'a [inline_query::Result<'a>],
#[serde(skip_serializing_if = "Option::is_none")]
cache_time: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
is_personal: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
next_offset: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
switch_pm_text: Option<&'a str>,
#[serde(skip_serializing_if = "Option::is_none")]
switch_pm_parameter: Option<&'a str>,
}
impl<'a, C> AnswerInlineQuery<'a, C> {
pub(crate) const fn new(
client: &'a Client<C>,
token: Token,
inline_query_id: inline_query::id::Ref<'a>,
results: &'a [inline_query::Result<'a>],
) -> Self {
Self {
client,
token,
inline_query_id,
results,
cache_time: None,
is_personal: None,
next_offset: None,
switch_pm_text: None,
switch_pm_parameter: None,
}
}
pub fn cache_time(mut self, time: u64) -> Self {
self.cache_time = Some(time);
self
}
pub fn personal(mut self, is_personal: bool) -> Self {
self.is_personal = Some(is_personal);
self
}
pub fn next_offset(mut self, offset: &'a str) -> Self {
self.next_offset = Some(offset);
self
}
pub fn switch_pm(mut self, text: &'a str, parameter: &'a str) -> Self {
self.switch_pm_text = Some(text);
self.switch_pm_parameter = Some(parameter);
self
}
}
impl<C> IntoFuture for AnswerInlineQuery<'_, C>
where
C: hyper::client::connect::Connect + Sync + 'static,
C::Transport: 'static,
C::Future: 'static,
{
type Future = BoxFuture<Self::Item, Self::Error>;
type Item = ();
type Error = errors::MethodCall;
fn into_future(self) -> Self::Future {
Box::new(
send_method::<bool, C>(
self.client,
&self.token,
"answerInlineQuery",
None,
serde_json::to_vec(&self).unwrap(),
)
.map(|_| ()),
)
}
}