Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[macro_use]
- extern crate serde_derive;
- extern crate serde;
- extern crate serde_json;
- fn main() {
- }
- fn get_file_id(update: &Update) {
- let file_id = if let Some(document) = update.message.document {
- Some(&document.file_id)
- } else if let Some(photo) = update.message.photo {
- photo.get(0).map(|x| &x.file_id)
- } else {
- None
- };
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct Chat {
- pub id: i64,
- #[serde(rename = "type")]
- pub chat_type: String,
- pub first_name: Option<String>,
- pub last_name: Option<String>,
- pub username: Option<String>,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct Document {
- pub file_id: String,
- pub file_name: Option<String>,
- pub mime_type: Option<String>,
- pub thumb: Option<PhotoSize>,
- pub file_size: Option<i64>,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct PhotoSize {
- pub file_id: String,
- pub file_size: Option<i64>,
- pub width: i64,
- pub height: i64,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct User {
- pub id: i64,
- pub is_bot: bool,
- pub first_name: String,
- pub last_name: Option<String>,
- pub username: Option<String>,
- pub language_code: Option<String>,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct Message {
- pub message_id: i64,
- pub from: Option<User>,
- pub chat: Chat,
- pub date: i64,
- pub text: Option<String>,
- pub photo: Option<Vec<PhotoSize>>,
- pub document: Option<Document>,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct File {
- pub file_id: String,
- pub file_size: Option<i64>,
- pub file_path: Option<String>,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct GetFileResponse {
- pub ok: bool,
- pub result: File,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct Update {
- pub update_id: i64,
- pub message: Message,
- }
- #[derive(Debug, Clone, Deserialize)]
- pub struct ApiResult<T> {
- pub ok: bool,
- pub result: T,
- }
Add Comment
Please, Sign In to add comment