From 6e76d0441d990a4480d20e95a8ff3290ad054ddd Mon Sep 17 00:00:00 2001 From: Waffle Date: Fri, 13 Sep 2019 00:58:08 +0300 Subject: [PATCH] Fix compilers warnings (unused imports, unused fields, etc) --- src/core/network/mod.rs | 15 ++++++++++----- src/core/requests/form_builder.rs | 1 - src/core/requests/forward_message.rs | 7 +++++-- src/core/requests/send_message.rs | 7 +++++-- src/core/requests/send_photo.rs | 2 -- src/core/requests/stop_message_live_location.rs | 11 ++++++----- src/core/requests/utils.rs | 11 +++++++---- 7 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/core/network/mod.rs b/src/core/network/mod.rs index 8fdde960..244c6d63 100644 --- a/src/core/network/mod.rs +++ b/src/core/network/mod.rs @@ -9,7 +9,6 @@ use reqwest::{ StatusCode, }; use serde::{de::DeserializeOwned, Serialize}; -use serde_json::Value; const TELEGRAM_API_URL: &str = "https://api.telegram.org"; @@ -63,7 +62,7 @@ pub async fn request_multipart( TelegramResponse::Err { description, error_code, - response_parameters, + response_parameters: _, .. } => Err(RequestError::ApiError { description, @@ -95,7 +94,7 @@ pub async fn request_json( TelegramResponse::Err { description, error_code, - response_parameters, + response_parameters: _, .. } => Err(RequestError::ApiError { description, @@ -108,11 +107,17 @@ pub async fn request_json( #[serde(untagged)] enum TelegramResponse { Ok { - ok: bool, // true + /// Dummy field. Used for deserialization. + #[allow(dead_code)] + ok: bool, // TODO: True type + result: R, }, Err { - ok: bool, // false + /// Dummy field. Used for deserialization. + #[allow(dead_code)] + ok: bool, // TODO: False type + description: String, error_code: u16, response_parameters: Option, diff --git a/src/core/requests/form_builder.rs b/src/core/requests/form_builder.rs index e266c837..d9bd8b69 100644 --- a/src/core/requests/form_builder.rs +++ b/src/core/requests/form_builder.rs @@ -6,7 +6,6 @@ use crate::core::{ }; use reqwest::r#async::multipart::Form; -use serde::Serialize; /// This is a convenient struct that builds `reqwest::r#async::multipart::Form` /// from scratch. diff --git a/src/core/requests/forward_message.rs b/src/core/requests/forward_message.rs index 8e61bce6..dc751bfd 100644 --- a/src/core/requests/forward_message.rs +++ b/src/core/requests/forward_message.rs @@ -1,8 +1,11 @@ use crate::core::{ network, requests::{ - form_builder::FormBuilder, ChatId, Request, RequestContext, - RequestFuture, ResponseResult, + ChatId, + Request, + RequestFuture, + RequestContext, + ResponseResult, }, types::Message, }; diff --git a/src/core/requests/send_message.rs b/src/core/requests/send_message.rs index 889bcb14..d3bf2421 100644 --- a/src/core/requests/send_message.rs +++ b/src/core/requests/send_message.rs @@ -1,8 +1,11 @@ use crate::core::{ network, requests::{ - form_builder::FormBuilder, ChatId, Request, RequestContext, - RequestFuture, ResponseResult, + ChatId, + Request, + RequestFuture, + RequestContext, + ResponseResult, }, types::{Message, ParseMode, ReplyMarkup}, }; diff --git a/src/core/requests/send_photo.rs b/src/core/requests/send_photo.rs index 0d4e40e3..9d2a07b5 100644 --- a/src/core/requests/send_photo.rs +++ b/src/core/requests/send_photo.rs @@ -1,5 +1,3 @@ -use std::path::Path; - use crate::core::{ network, requests::{ diff --git a/src/core/requests/stop_message_live_location.rs b/src/core/requests/stop_message_live_location.rs index 2598f4bf..cea3da80 100644 --- a/src/core/requests/stop_message_live_location.rs +++ b/src/core/requests/stop_message_live_location.rs @@ -1,12 +1,13 @@ -use std::path::Path; - use crate::core::{ network, requests::{ - form_builder::FormBuilder, ChatId, Request, RequestContext, - RequestFuture, ResponseResult, + ChatId, + Request, + RequestFuture, + RequestContext, + ResponseResult, }, - types::{InlineKeyboardMarkup, Message, ParseMode}, + types::{InlineKeyboardMarkup, Message}, }; /// Use this method to stop updating a live location message before live_period diff --git a/src/core/requests/utils.rs b/src/core/requests/utils.rs index 44231ef2..193bad0c 100644 --- a/src/core/requests/utils.rs +++ b/src/core/requests/utils.rs @@ -1,9 +1,12 @@ +use std::path::PathBuf; + use bytes::{Bytes, BytesMut}; use reqwest::r#async::multipart::Part; -use std::fs::File; -use std::path::PathBuf; -use tokio::codec::FramedRead; -use tokio::prelude::*; +use tokio::{ + prelude::*, + codec::FramedRead, +}; + struct FileDecoder;