From ec4d23626ab1baaf5c6b660cbd05c2ead22aab23 Mon Sep 17 00:00:00 2001 From: Waffle Date: Sat, 21 Sep 2019 01:05:48 +0300 Subject: [PATCH] Fixes --- src/network/download.rs | 4 +++- src/network/mod.rs | 20 +++----------------- src/network/request.rs | 2 +- src/network/telegram_response.rs | 2 +- src/types/mod.rs | 2 +- src/types/sticker_set.rs | 2 +- 6 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/network/download.rs b/src/network/download.rs index 3f1de111..a57d3fff 100644 --- a/src/network/download.rs +++ b/src/network/download.rs @@ -1,8 +1,10 @@ +use futures::StreamExt; use reqwest::r#async::{Chunk, Client}; use tokio::{ io::{AsyncWrite, AsyncWriteExt}, stream::Stream, }; +use bytes::Buf; use crate::{ network::{file_url, TELEGRAM_API_URL}, @@ -27,7 +29,7 @@ where Ok(()) } -pub(crate) async fn download_file_stream( +pub async fn download_file_stream( client: &Client, token: &str, path: &str, diff --git a/src/network/mod.rs b/src/network/mod.rs index 516912f8..99c5341b 100644 --- a/src/network/mod.rs +++ b/src/network/mod.rs @@ -2,23 +2,9 @@ mod download; mod request; mod telegram_response; -use apply::Apply; -use bytes::Buf; -use futures::StreamExt; -use reqwest::{ - r#async::{multipart::Form, Chunk, Client, Response}, - StatusCode, -}; -use serde::{de::DeserializeOwned, Serialize}; -use tokio::{ - io::{AsyncWrite, AsyncWriteExt}, - stream::Stream, -}; - -use crate::{ - requests::ResponseResult, types::ResponseParameters, DownloadError, - RequestError, -}; +pub use download::{download_file, download_file_stream}; +pub use request::{request_json, request_multipart}; +pub use telegram_response::TelegramResponse; pub const TELEGRAM_API_URL: &str = "https://api.telegram.org"; diff --git a/src/network/request.rs b/src/network/request.rs index 8b648b01..0faf04c0 100644 --- a/src/network/request.rs +++ b/src/network/request.rs @@ -3,7 +3,7 @@ use reqwest::r#async::{multipart::Form, Client, Response}; use serde::{de::DeserializeOwned, Serialize}; use crate::{ - network::{method_url, TELEGRAM_API_URL}, + network::{method_url, TELEGRAM_API_URL, TelegramResponse}, requests::ResponseResult, RequestError, }; diff --git a/src/network/telegram_response.rs b/src/network/telegram_response.rs index b6ac81c8..05e7acb7 100644 --- a/src/network/telegram_response.rs +++ b/src/network/telegram_response.rs @@ -6,7 +6,7 @@ use crate::{ #[derive(Deserialize)] #[serde(untagged)] -enum TelegramResponse { +pub enum TelegramResponse { Ok { /// A dummy field. Used only for deserialization. #[allow(dead_code)] diff --git a/src/types/mod.rs b/src/types/mod.rs index 032ec138..1533e3bb 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -14,7 +14,7 @@ pub use self::{ file::File, force_reply::ForceReply, game::Game, - game_high_score, + game_high_score::GameHighScore, inline_keyboard_button::{InlineKeyboardButton, InlineKeyboardButtonKind}, inline_keyboard_markup::InlineKeyboardMarkup, inline_query::InlineQuery, diff --git a/src/types/sticker_set.rs b/src/types/sticker_set.rs index 771bc74d..69394655 100644 --- a/src/types/sticker_set.rs +++ b/src/types/sticker_set.rs @@ -1,6 +1,6 @@ use crate::types::Sticker; -#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] +#[derive(Debug, Deserialize, PartialEq, Clone)] pub struct StickerSet { pub name: String, pub title: String,