Reformat imports

This commit is contained in:
Waffle 2019-09-21 00:44:29 +03:00
parent cf3e0182c9
commit 5284d5e884
19 changed files with 107 additions and 80 deletions

View file

@ -1,16 +1,15 @@
use crate::bot::Bot; use crate::{
use crate::requests::edit_message_live_location::EditMessageLiveLocation; bot::Bot,
use crate::requests::forward_message::ForwardMessage; requests::{
use crate::requests::get_file::GetFile; edit_message_live_location::EditMessageLiveLocation,
use crate::requests::get_me::GetMe; forward_message::ForwardMessage, get_file::GetFile, get_me::GetMe,
use crate::requests::send_audio::SendAudio; send_audio::SendAudio, send_location::SendLocation,
use crate::requests::send_location::SendLocation; send_media_group::SendMediaGroup, send_message::SendMessage,
use crate::requests::send_media_group::SendMediaGroup; send_photo::SendPhoto,
use crate::requests::send_message::SendMessage; stop_message_live_location::StopMessageLiveLocation, ChatId,
use crate::requests::send_photo::SendPhoto; },
use crate::requests::stop_message_live_location::StopMessageLiveLocation; types::{InputFile, InputMedia},
use crate::requests::ChatId; };
use crate::types::{InputFile, InputMedia};
/// Telegram functions /// Telegram functions
impl Bot { impl Bot {

View file

@ -1,9 +1,16 @@
use super::Bot;
use crate::network::{download_file, download_file_stream};
use crate::DownloadError;
use reqwest::r#async::Chunk; use reqwest::r#async::Chunk;
use tokio::prelude::AsyncWrite; use tokio::{
use tokio::stream::Stream; io::AsyncWrite,
stream::Stream,
};
use crate::{
DownloadError,
bot::Bot,
network::{download_file, download_file_stream},
};
impl Bot { impl Bot {
/// Download file from telegram into `destination`. /// Download file from telegram into `destination`.

View file

@ -1,20 +1,21 @@
use futures::StreamExt;
use serde::{de::DeserializeOwned, Serialize};
use tokio::{
stream::Stream,
io::{AsyncWrite, AsyncWriteExt},
};
use reqwest::{
StatusCode,
r#async::{multipart::Form, Client, Response, Chunk},
};
use bytes::Buf;
use apply::Apply;
use crate::{ use crate::{
requests::ResponseResult, types::ResponseParameters, RequestError, DownloadError, RequestError,
requests::ResponseResult, types::ResponseParameters,
}; };
use crate::DownloadError;
use apply::Apply;
use bytes::Buf;
use futures::StreamExt;
use reqwest::r#async::Chunk;
use reqwest::{
r#async::{multipart::Form, Client, Response},
StatusCode,
};
use serde::{de::DeserializeOwned, Serialize};
use tokio::io::AsyncWriteExt;
use tokio::prelude::AsyncWrite;
use tokio::stream::Stream;
const TELEGRAM_API_URL: &str = "https://api.telegram.org"; const TELEGRAM_API_URL: &str = "https://api.telegram.org";

View file

@ -1,6 +1,8 @@
use crate::network; use crate::{
use crate::requests::{Request, RequestContext, RequestFuture, ResponseResult}; network,
use crate::types::ShippingOption; requests::{Request, RequestContext, RequestFuture, ResponseResult},
types::ShippingOption,
};
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
/// If you sent an invoice requesting a shipping address and the parameter /// If you sent an invoice requesting a shipping address and the parameter

View file

@ -1,9 +1,8 @@
use crate::network; use crate::{
use crate::requests::{ network,
ChatId, Request, RequestContext, RequestFuture, ResponseResult, requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult},
types::{Message, ReplyMarkup},
}; };
use crate::types::{Message, ReplyMarkup};
use serde::Serialize;
#[derive(Debug, Clone, Serialize)] #[derive(Debug, Clone, Serialize)]
/// Use this method to edit live location messages. A location can be edited /// Use this method to edit live location messages. A location can be edited

View file

@ -1,12 +1,12 @@
use std::path::PathBuf; use std::path::PathBuf;
use reqwest::r#async::multipart::Form;
use crate::{ use crate::{
requests::{utils, ChatId}, requests::{utils, ChatId},
types::{InputMedia, ParseMode}, types::{InputMedia, ParseMode},
}; };
use reqwest::r#async::multipart::Form;
/// This is a convenient struct that builds `reqwest::r#async::multipart::Form` /// This is a convenient struct that builds `reqwest::r#async::multipart::Form`
/// from scratch. /// from scratch.
pub struct FormBuilder { pub struct FormBuilder {

View file

@ -1,6 +1,8 @@
use crate::requests::{ChatId, RequestContext, RequestFuture, ResponseResult, Request}; use crate::{
use crate::types::Chat; network,
use crate::network; 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
/// (current name of the user for one-on-one conversations, /// (current name of the user for one-on-one conversations,

View file

@ -1,6 +1,9 @@
use crate::network; use crate::{
use crate::requests::{Request, RequestContext, RequestFuture, ResponseResult}; network,
use crate::types::File; requests::{Request, RequestContext, RequestFuture, ResponseResult},
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.

View file

@ -1,13 +1,12 @@
use std::future::Future;
use std::pin::Pin;
use crate::errors::RequestError;
use reqwest::r#async::Client;
use serde::de::DeserializeOwned;
mod form_builder; mod form_builder;
mod utils; mod utils;
use reqwest::r#async::Client;
use serde::de::DeserializeOwned;
use std::{future::Future, pin::Pin};
use crate::RequestError;
pub type ResponseResult<T> = Result<T, RequestError>; pub type ResponseResult<T> = Result<T, RequestError>;
/// Request that can be sent to telegram. /// Request that can be sent to telegram.
@ -68,6 +67,7 @@ pub mod answer_pre_checkout_query;
pub mod answer_shipping_query; pub mod answer_shipping_query;
pub mod edit_message_live_location; pub mod edit_message_live_location;
pub mod forward_message; pub mod forward_message;
pub mod get_chat;
pub mod get_file; pub mod get_file;
pub mod get_me; pub mod get_me;
pub mod get_user_profile_photos; pub mod get_user_profile_photos;

View file

@ -1,8 +1,7 @@
use crate::{ use crate::{
network, network,
requests::form_builder::FormBuilder,
requests::{ requests::{
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

@ -1,6 +1,8 @@
use crate::network; use crate::{
use crate::requests::{ network,
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,8 +1,9 @@
use crate::network; use crate::{
use crate::requests::{ network,
ChatId, Request, RequestContext, RequestFuture, ResponseResult, requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult},
types::{Message, ReplyMarkup},
}; };
use crate::types::{Message, ReplyMarkup};
/// Use this method to send phone contacts. /// Use this method to send phone contacts.
/// returned. /// returned.

View file

@ -1,3 +1,5 @@
use apply::Apply;
use crate::{ use crate::{
network::request_multipart, network::request_multipart,
requests::{ requests::{
@ -6,7 +8,7 @@ use crate::{
}, },
types::{InputFile, InputMedia, Message}, types::{InputFile, InputMedia, Message},
}; };
use apply::Apply;
/// 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)]

View file

@ -1,8 +1,9 @@
use crate::network; use crate::{
use crate::requests::{ network,
ChatId, Request, RequestContext, RequestFuture, ResponseResult, requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult},
types::{Message, ReplyMarkup},
}; };
use crate::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.

View file

@ -1,8 +1,9 @@
use crate::network; use crate::{
use crate::requests::{ network,
ChatId, Request, RequestContext, RequestFuture, ResponseResult, requests::{ChatId, Request, RequestContext, RequestFuture, ResponseResult},
types::{Message, ReplyMarkup},
}; };
use crate::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.

View file

@ -2,6 +2,7 @@ use self::not_implemented_types::*;
pub use self::{ pub use self::{
animation::Animation, animation::Animation,
audio::Audio, audio::Audio,
callback_game::CallbackGame,
callback_query::CallbackQuery, callback_query::CallbackQuery,
chat::{Chat, ChatKind, NonPrivateChatKind}, chat::{Chat, ChatKind, NonPrivateChatKind},
chat_member::{ChatMember, ChatMemberStatus}, chat_member::{ChatMember, ChatMemberStatus},
@ -13,6 +14,7 @@ pub use self::{
file::File, file::File,
force_reply::ForceReply, force_reply::ForceReply,
game::Game, game::Game,
game_high_score,
inline_keyboard_button::{InlineKeyboardButton, InlineKeyboardButtonKind}, inline_keyboard_button::{InlineKeyboardButton, InlineKeyboardButtonKind},
inline_keyboard_markup::InlineKeyboardMarkup, inline_keyboard_markup::InlineKeyboardMarkup,
inline_query::InlineQuery, inline_query::InlineQuery,
@ -44,6 +46,7 @@ pub use self::{
keyboard_button::KeyboardButton, keyboard_button::KeyboardButton,
label_price::LabeledPrice, label_price::LabeledPrice,
location::Location, location::Location,
login_url::LoginUrl,
mask_position::MaskPosition, mask_position::MaskPosition,
message::{ message::{
ForwardKind, ForwardedFrom, MediaKind, Message, MessageKind, Sender, ForwardKind, ForwardedFrom, MediaKind, Message, MessageKind, Sender,
@ -63,17 +66,21 @@ pub use self::{
shipping_option::ShippingOption, shipping_option::ShippingOption,
shipping_query::ShippingQuery, shipping_query::ShippingQuery,
sticker::Sticker, sticker::Sticker,
sticker_set::StickerSet,
successful_payment::SuccessfulPayment, successful_payment::SuccessfulPayment,
update::{Update, UpdateKind}, update::{Update, UpdateKind},
user::User, user::User,
user_profile_photos::UserProfilePhotos,
venue::Venue, venue::Venue,
video::Video, video::Video,
video_note::VideoNote, video_note::VideoNote,
voice::Voice, voice::Voice,
webhook_info::WebhookInfo,
}; };
mod animation; mod animation;
mod audio; mod audio;
mod callback_game;
mod callback_query; mod callback_query;
mod chat; mod chat;
mod chat_member; mod chat_member;
@ -85,6 +92,7 @@ mod document;
mod file; mod file;
mod force_reply; mod force_reply;
mod game; mod game;
mod game_high_score;
mod inline_keyboard_button; mod inline_keyboard_button;
mod inline_keyboard_markup; mod inline_keyboard_markup;
mod input_file; mod input_file;
@ -94,6 +102,7 @@ mod invoice;
mod keyboard_button; mod keyboard_button;
mod label_price; mod label_price;
mod location; mod location;
mod login_url;
mod mask_position; mod mask_position;
mod message; mod message;
mod message_entity; mod message_entity;
@ -112,13 +121,16 @@ mod shipping_address;
mod shipping_option; mod shipping_option;
mod shipping_query; mod shipping_query;
mod sticker; mod sticker;
mod sticker_set;
mod successful_payment; mod successful_payment;
mod update; mod update;
mod user; mod user;
mod user_profile_photos;
mod venue; mod venue;
mod video; mod video;
mod video_note; mod video_note;
mod voice; mod voice;
mod webhook_info;
mod inline_query; mod inline_query;
mod inline_query_result; mod inline_query_result;

View file

@ -1,5 +1,4 @@
use crate::types::PhotoSize; use crate::types::PhotoSize;
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)]
/// This object represents a [video message](https://telegram.org/blog/video-messages-and-telescope) /// This object represents a [video message](https://telegram.org/blog/video-messages-and-telescope)

View file

@ -1,5 +1,3 @@
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)] #[derive(Debug, Deserialize, Clone, PartialEq, Eq, Hash)]
/// This object represents a voice note. /// This object represents a voice note.
pub struct Voice { pub struct Voice {

View file

@ -1,11 +1,10 @@
use serde::Deserialize;
/// Contains information about the current status of a webhook. /// Contains information about the current status of a webhook.
#[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)] #[derive(Debug, Deserialize, Hash, PartialEq, Eq, Clone)]
pub struct WebhookInfo { pub struct WebhookInfo {
/// Webhook URL, may be empty if webhook is not set up /// Webhook URL, may be empty if webhook is not set up
pub url: String, pub url: String,
/// True, if a custom certificate was provided for webhook certificate checks /// True, if a custom certificate was provided for webhook certificate
/// checks
pub has_custom_certificate: bool, pub has_custom_certificate: bool,
/// Number of updates awaiting delivery /// Number of updates awaiting delivery
pub pending_update_count: u32, pub pending_update_count: u32,