From 7868d9c8322d8eb4409314d08beb28a21adb9da4 Mon Sep 17 00:00:00 2001 From: Waffle Date: Tue, 5 Nov 2019 00:00:26 +0300 Subject: [PATCH] Add `simple::{Payload, Request}` --- src/requests/mod.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/requests/mod.rs b/src/requests/mod.rs index 6bcef0dd..e53e41c1 100644 --- a/src/requests/mod.rs +++ b/src/requests/mod.rs @@ -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, + } + + impl Request<'_, M> + where + M: Method, + M::Output: DeserializeOwned, + { + pub async fn send(&self) -> ResponseResult { + network::request_simple( + self.bot.client(), + self.bot.token(), + M::METHOD, + ).await + } + } +}