conogram/entities/passport_element_error.rs
1use serde::{Deserialize, Serialize};
2
3use crate::entities::{
4 passport_element_error_data_field::PassportElementErrorDataField,
5 passport_element_error_file::PassportElementErrorFile,
6 passport_element_error_files::PassportElementErrorFiles,
7 passport_element_error_front_side::PassportElementErrorFrontSide,
8 passport_element_error_reverse_side::PassportElementErrorReverseSide,
9 passport_element_error_selfie::PassportElementErrorSelfie,
10 passport_element_error_translation_file::PassportElementErrorTranslationFile,
11 passport_element_error_translation_files::PassportElementErrorTranslationFiles,
12 passport_element_error_unspecified::PassportElementErrorUnspecified,
13};
14
15/// This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. It should be one of:
16///
17/// * [PassportElementErrorDataField](https://core.telegram.org/bots/api/#passportelementerrordatafield)
18/// * [PassportElementErrorFrontSide](https://core.telegram.org/bots/api/#passportelementerrorfrontside)
19/// * [PassportElementErrorReverseSide](https://core.telegram.org/bots/api/#passportelementerrorreverseside)
20/// * [PassportElementErrorSelfie](https://core.telegram.org/bots/api/#passportelementerrorselfie)
21/// * [PassportElementErrorFile](https://core.telegram.org/bots/api/#passportelementerrorfile)
22/// * [PassportElementErrorFiles](https://core.telegram.org/bots/api/#passportelementerrorfiles)
23/// * [PassportElementErrorTranslationFile](https://core.telegram.org/bots/api/#passportelementerrortranslationfile)
24/// * [PassportElementErrorTranslationFiles](https://core.telegram.org/bots/api/#passportelementerrortranslationfiles)
25/// * [PassportElementErrorUnspecified](https://core.telegram.org/bots/api/#passportelementerrorunspecified)
26///
27/// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerror)
28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
29#[serde(tag = "source")]
30pub enum PassportElementError {
31 /// Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
32 ///
33 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrordatafield)
34 #[serde(rename = "data")]
35 DataField(PassportElementErrorDataField),
36
37 /// Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes.
38 ///
39 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrorfrontside)
40 #[serde(rename = "front_side")]
41 FrontSide(PassportElementErrorFrontSide),
42
43 /// Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes.
44 ///
45 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrorreverseside)
46 #[serde(rename = "reverse_side")]
47 ReverseSide(PassportElementErrorReverseSide),
48
49 /// Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
50 ///
51 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrorselfie)
52 #[serde(rename = "selfie")]
53 Selfie(PassportElementErrorSelfie),
54
55 /// Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
56 ///
57 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrorfile)
58 #[serde(rename = "file")]
59 File(PassportElementErrorFile),
60
61 /// Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
62 ///
63 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrorfiles)
64 #[serde(rename = "files")]
65 Files(PassportElementErrorFiles),
66
67 /// Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes.
68 ///
69 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrortranslationfile)
70 #[serde(rename = "translation_file")]
71 TranslationFile(PassportElementErrorTranslationFile),
72
73 /// Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change.
74 ///
75 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrortranslationfiles)
76 #[serde(rename = "translation_files")]
77 TranslationFiles(PassportElementErrorTranslationFiles),
78
79 /// Represents an issue in an unspecified place. The error is considered resolved when new data is added.
80 ///
81 /// API Reference: [link](https://core.telegram.org/bots/api/#passportelementerrorunspecified)
82 #[serde(rename = "unspecified")]
83 Unspecified(PassportElementErrorUnspecified),
84}
85
86impl Default for PassportElementError {
87 fn default() -> Self {
88 Self::DataField(PassportElementErrorDataField::default())
89 }
90}
91
92impl From<PassportElementErrorDataField> for PassportElementError {
93 fn from(value: PassportElementErrorDataField) -> Self {
94 Self::DataField(value)
95 }
96}
97
98impl From<PassportElementErrorFrontSide> for PassportElementError {
99 fn from(value: PassportElementErrorFrontSide) -> Self {
100 Self::FrontSide(value)
101 }
102}
103
104impl From<PassportElementErrorReverseSide> for PassportElementError {
105 fn from(value: PassportElementErrorReverseSide) -> Self {
106 Self::ReverseSide(value)
107 }
108}
109
110impl From<PassportElementErrorSelfie> for PassportElementError {
111 fn from(value: PassportElementErrorSelfie) -> Self {
112 Self::Selfie(value)
113 }
114}
115
116impl From<PassportElementErrorFile> for PassportElementError {
117 fn from(value: PassportElementErrorFile) -> Self {
118 Self::File(value)
119 }
120}
121
122impl From<PassportElementErrorFiles> for PassportElementError {
123 fn from(value: PassportElementErrorFiles) -> Self {
124 Self::Files(value)
125 }
126}
127
128impl From<PassportElementErrorTranslationFile> for PassportElementError {
129 fn from(value: PassportElementErrorTranslationFile) -> Self {
130 Self::TranslationFile(value)
131 }
132}
133
134impl From<PassportElementErrorTranslationFiles> for PassportElementError {
135 fn from(value: PassportElementErrorTranslationFiles) -> Self {
136 Self::TranslationFiles(value)
137 }
138}
139
140impl From<PassportElementErrorUnspecified> for PassportElementError {
141 fn from(value: PassportElementErrorUnspecified) -> Self {
142 Self::Unspecified(value)
143 }
144}
145
146// Divider: all content below this line will be preserved after code regen