mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-18 15:20:15 +01:00
Add simple::{Payload, Request}
This commit is contained in:
parent
b02f10e73c
commit
7868d9c832
1 changed files with 27 additions and 0 deletions
|
@ -175,3 +175,30 @@ pub mod multipart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod simple {
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
|
use reqwest::multipart;
|
||||||
|
|
||||||
|
use crate::{Bot, network};
|
||||||
|
use super::{ResponseResult, Method};
|
||||||
|
|
||||||
|
pub struct Request<'b, M> {
|
||||||
|
pub(crate) bot: &'b Bot,
|
||||||
|
marker: std::marker::PhantomData<M>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<M> Request<'_, M>
|
||||||
|
where
|
||||||
|
M: Method,
|
||||||
|
M::Output: DeserializeOwned,
|
||||||
|
{
|
||||||
|
pub async fn send(&self) -> ResponseResult<M::Output> {
|
||||||
|
network::request_simple(
|
||||||
|
self.bot.client(),
|
||||||
|
self.bot.token(),
|
||||||
|
M::METHOD,
|
||||||
|
).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue