mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-22 06:45:37 +01:00
Make dynamic::Request
_really_ dynamic (ooops)
This commit is contained in:
parent
e2922199d4
commit
be11633d6e
1 changed files with 6 additions and 7 deletions
|
@ -30,22 +30,21 @@ pub trait Payload {
|
||||||
/// [multipart]: crate::requests::multipart::Request
|
/// [multipart]: crate::requests::multipart::Request
|
||||||
/// [simple]: crate::requests::simple::Request
|
/// [simple]: crate::requests::simple::Request
|
||||||
#[must_use = "requests do nothing until sent"]
|
#[must_use = "requests do nothing until sent"]
|
||||||
pub struct Request<'b, P> {
|
pub struct Request<'b, O> {
|
||||||
bot: &'b Bot,
|
bot: &'b Bot,
|
||||||
pub(crate) payload: P,
|
pub(crate) payload: &'b dyn Payload<Output = O>, // TODO: Box?
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'b, P> Request<'b, P>
|
impl<'b, O> Request<'b, O>
|
||||||
where
|
where
|
||||||
P: Payload,
|
O: DeserializeOwned,
|
||||||
P::Output: DeserializeOwned,
|
|
||||||
{
|
{
|
||||||
pub fn new(bot: &'b Bot, payload: P) -> Self {
|
pub fn new(bot: &'b Bot, payload: &'b dyn Payload<Output = O>) -> Self {
|
||||||
Self { bot, payload }
|
Self { bot, payload }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send request to telegram
|
/// Send request to telegram
|
||||||
pub async fn send(&self) -> ResponseResult<P::Output> {
|
pub async fn send(&self) -> ResponseResult<O> {
|
||||||
network::request_dynamic(
|
network::request_dynamic(
|
||||||
self.bot.client(),
|
self.bot.client(),
|
||||||
self.bot.token(),
|
self.bot.token(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue