cargo fmt

This commit is contained in:
Waffle 2019-09-21 00:57:17 +03:00
parent f37552536e
commit f95ea5ee31
14 changed files with 48 additions and 49 deletions

View file

@ -1,17 +1,12 @@
use reqwest::r#async::Chunk; use reqwest::r#async::Chunk;
use tokio::{ use tokio::{io::AsyncWrite, stream::Stream};
io::AsyncWrite,
stream::Stream,
};
use crate::{ use crate::{
DownloadError,
bot::Bot, bot::Bot,
network::{download_file, download_file_stream}, network::{download_file, download_file_stream},
DownloadError,
}; };
impl Bot { impl Bot {
/// Download file from telegram into `destination`. /// Download file from telegram into `destination`.
/// `path` can be obtained from [`get_file`] method. /// `path` can be obtained from [`get_file`] method.

View file

@ -1,15 +1,14 @@
use reqwest::r#async::{Client, Chunk}; use reqwest::r#async::{Chunk, Client};
use tokio::{ use tokio::{
stream::Stream,
io::{AsyncWrite, AsyncWriteExt}, io::{AsyncWrite, AsyncWriteExt},
stream::Stream,
}; };
use crate::{ use crate::{
network::{file_url, TELEGRAM_API_URL},
DownloadError, DownloadError,
network::{TELEGRAM_API_URL, file_url},
}; };
pub async fn download_file<D>( pub async fn download_file<D>(
client: &Client, client: &Client,
token: &str, token: &str,

View file

@ -1,22 +1,22 @@
use serde::{de::DeserializeOwned, Serialize};
use reqwest::r#async::{
Client, multipart::Form, Response,
};
use apply::Apply; use apply::Apply;
use reqwest::r#async::{multipart::Form, Client, Response};
use serde::{de::DeserializeOwned, Serialize};
use crate::{ use crate::{
RequestError,
requests::ResponseResult,
network::{method_url, TELEGRAM_API_URL}, network::{method_url, TELEGRAM_API_URL},
requests::ResponseResult,
RequestError,
}; };
pub async fn request_multipart<T>( pub async fn request_multipart<T>(
client: &Client, client: &Client,
token: &str, token: &str,
method_name: &str, method_name: &str,
params: Option<Form>, params: Option<Form>,
) -> ResponseResult<T> where T: DeserializeOwned { ) -> ResponseResult<T>
where
T: DeserializeOwned,
{
process_response( process_response(
client client
.post(&method_url(TELEGRAM_API_URL, token, method_name)) .post(&method_url(TELEGRAM_API_URL, token, method_name))

View file

@ -1,6 +1,8 @@
use crate::{ use crate::{
network, network,
requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult}, requests::{
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
},
types::{Message, ReplyMarkup}, types::{Message, ReplyMarkup},
}; };

View file

@ -1,7 +1,9 @@
use crate::{ use crate::{
network, network,
requests::{
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
},
types::Chat, types::Chat,
requests::{ChatId, RequestContext, RequestFuture, ResponseResult, Request},
}; };
/// Use this method to get up to date information about the chat /// Use this method to get up to date information about the chat
@ -17,7 +19,6 @@ pub struct GetChat<'a> {
chat_id: ChatId, chat_id: ChatId,
} }
impl<'a> Request<'a> for GetChat<'a> { impl<'a> Request<'a> for GetChat<'a> {
type ReturnValue = Chat; type ReturnValue = Chat;
@ -28,12 +29,12 @@ impl<'a> Request<'a> for GetChat<'a> {
&self.ctx.token, &self.ctx.token,
"getChat", "getChat",
&self, &self,
).await )
.await
}) })
} }
} }
impl<'a> GetChat<'a> { impl<'a> GetChat<'a> {
pub fn chat_id<T>(mut self, chat_id: T) -> Self pub fn chat_id<T>(mut self, chat_id: T) -> Self
where where

View file

@ -4,7 +4,6 @@ use crate::{
types::File, types::File,
}; };
/// Use this method to get basic info about a file and prepare it for /// Use this method to get basic info about a file and prepare it for
/// downloading. For the moment, bots can download files of up to 20MB in size. /// downloading. For the moment, bots can download files of up to 20MB in size.
/// On success, a File object is returned. /// On success, a File object is returned.

View file

@ -1,7 +1,8 @@
use crate::{ use crate::{
network, network,
requests::{ requests::{
form_builder::FormBuilder, ChatId, Request, RequestContext, RequestFuture, ResponseResult, form_builder::FormBuilder, ChatId, Request, RequestContext,
RequestFuture, ResponseResult,
}, },
types::{InputFile, Message, ParseMode, ReplyMarkup}, types::{InputFile, Message, ParseMode, ReplyMarkup},
}; };

View file

@ -2,7 +2,7 @@ use crate::{
network, network,
requests::{ requests::{
ChatId, Request, RequestContext, RequestFuture, ResponseResult, ChatId, Request, RequestContext, RequestFuture, ResponseResult,
} },
}; };
///Use this method when you need to tell the user that something is happening ///Use this method when you need to tell the user that something is happening

View file

@ -1,10 +1,11 @@
use crate::{ use crate::{
network, network,
requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult}, requests::{
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
},
types::{Message, ReplyMarkup}, types::{Message, ReplyMarkup},
}; };
/// Use this method to send phone contacts. /// Use this method to send phone contacts.
/// returned. /// returned.
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]

View file

@ -9,7 +9,6 @@ use crate::{
types::{InputFile, InputMedia, Message}, types::{InputFile, InputMedia, Message},
}; };
/// Use this method to send a group of photos or videos as an album. /// Use this method to send a group of photos or videos as an album.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct SendMediaGroup<'a> { pub struct SendMediaGroup<'a> {

View file

@ -1,10 +1,11 @@
use crate::{ use crate::{
network, network,
requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult}, requests::{
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
},
types::{Message, ReplyMarkup}, types::{Message, ReplyMarkup},
}; };
/// Use this method to send a native poll. A native poll can't be sent to a /// Use this method to send a native poll. A native poll can't be sent to a
/// private chat. On success, the sent Message is returned. /// private chat. On success, the sent Message is returned.
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]

View file

@ -1,10 +1,11 @@
use crate::{ use crate::{
network, network,
requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult}, requests::{
ChatId, Request, RequestContext, RequestFuture, ResponseResult,
},
types::{Message, ReplyMarkup}, types::{Message, ReplyMarkup},
}; };
/// Use this method to send information about a venue. /// Use this method to send information about a venue.
/// Message is returned. /// Message is returned.
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]