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
use serde::{Deserialize, Serialize};
/// This object represents a file ready to be downloaded. The file can be downloaded via the link `https://api.telegram.org/file/bot<token>/<file_path>`. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile.
/// # Documentation
/// <https://core.telegram.org/bots/api#file>
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct File {
/// Identifier for this file, which can be used to download or reuse the file
pub file_id: Box<str>,
/// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
pub file_unique_id: Box<str>,
/// File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
#[serde(skip_serializing_if = "Option::is_none")]
pub file_size: Option<i64>,
/// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>` to get the file.
#[serde(skip_serializing_if = "Option::is_none")]
pub file_path: Option<Box<str>>,
}
impl File {
/// Creates a new `File`.
///
/// # Arguments
/// * `file_id` - Identifier for this file, which can be used to download or reuse the file
/// * `file_unique_id` - Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
///
/// # Notes
/// Use builder methods to set optional fields.
#[must_use]
pub fn new<T0: Into<Box<str>>, T1: Into<Box<str>>>(file_id: T0, file_unique_id: T1) -> Self {
Self {
file_id: file_id.into(),
file_unique_id: file_unique_id.into(),
file_size: None,
file_path: None,
}
}
/// Identifier for this file, which can be used to download or reuse the file
#[must_use]
pub fn file_id<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.file_id = val.into();
this
}
/// Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
#[must_use]
pub fn file_unique_id<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.file_unique_id = val.into();
this
}
/// File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
#[must_use]
pub fn file_size<T: Into<i64>>(self, val: T) -> Self {
let mut this = self;
this.file_size = Some(val.into());
this
}
/// File size in bytes. It can be bigger than 2^31 and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit integer or double-precision float type are safe for storing this value.
#[must_use]
pub fn file_size_option<T: Into<i64>>(self, val: Option<T>) -> Self {
let mut this = self;
this.file_size = val.map(Into::into);
this
}
/// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>` to get the file.
#[must_use]
pub fn file_path<T: Into<Box<str>>>(self, val: T) -> Self {
let mut this = self;
this.file_path = Some(val.into());
this
}
/// File path. Use `https://api.telegram.org/file/bot<token>/<file_path>` to get the file.
#[must_use]
pub fn file_path_option<T: Into<Box<str>>>(self, val: Option<T>) -> Self {
let mut this = self;
this.file_path = val.map(Into::into);
this
}
}