Rename RequestInfo to RequestContext (requests/mod.rs)

This commit is contained in:
Temirkhan Myrzamadi 2019-09-04 23:24:16 +06:00
parent 1ab1ae0224
commit 2c1ae116e1
4 changed files with 10 additions and 11 deletions

View file

@ -1,7 +1,7 @@
use reqwest::r#async::Client;
use crate::core::requests::{
get_me::GetMe, send_message::SendMessage, ChatId, RequestInfo,
get_me::GetMe, send_message::SendMessage, ChatId, RequestContext,
};
pub struct Bot {
@ -28,7 +28,7 @@ impl Bot {
/// Telegram functions
impl Bot {
pub fn get_me(&self) -> GetMe {
GetMe::new(RequestInfo {
GetMe::new(RequestContext {
token: &self.token,
client: &self.client,
})
@ -40,7 +40,7 @@ impl Bot {
T: Into<String>,
{
SendMessage::new(
RequestInfo {
RequestContext {
token: &self.token,
client: &self.client,
},

View file

@ -1,12 +1,12 @@
use crate::core::network;
use crate::core::requests::{
Request, RequestFuture, RequestInfo, ResponseResult,
Request, RequestFuture, RequestContext, ResponseResult,
};
use crate::core::types::User;
#[derive(Debug)]
pub struct GetMe<'a> {
info: RequestInfo<'a>,
info: RequestContext<'a>,
}
impl<'a> Request<'a> for GetMe<'a> {
@ -21,7 +21,7 @@ impl<'a> Request<'a> for GetMe<'a> {
}
impl<'a> GetMe<'a> {
pub(crate) fn new(info: RequestInfo<'a>) -> Self {
pub(crate) fn new(info: RequestContext<'a>) -> Self {
GetMe { info }
}
}

View file

@ -45,9 +45,8 @@ pub trait Request<'a> {
pub type RequestFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
// todo: better name?
#[derive(Debug)]
pub struct RequestInfo<'a> {
pub struct RequestContext<'a> {
pub client: &'a Client,
pub token: &'a str,
}

View file

@ -1,12 +1,12 @@
use crate::core::requests::form_builder::FormBuilder;
use crate::core::requests::{
ChatId, Request, RequestFuture, RequestInfo, ResponseResult,
ChatId, Request, RequestFuture, RequestContext, ResponseResult,
};
use crate::core::{network, types::Message};
#[derive(Debug)]
pub struct SendMessage<'a> {
info: RequestInfo<'a>,
info: RequestContext<'a>,
pub chat_id: ChatId,
pub text: String,
@ -55,7 +55,7 @@ impl<'a> Request<'a> for SendMessage<'a> {
impl<'a> SendMessage<'a> {
pub(crate) fn new(
info: RequestInfo<'a>,
info: RequestContext<'a>,
chat_id: ChatId,
text: String,
) -> Self {