twilight_http/request/channel/webhook/
execute_webhook_and_wait.rs1use super::ExecuteWebhook;
2#[cfg(not(target_os = "wasi"))]
3use crate::response::{Response, ResponseFuture};
4use crate::{
5 client::Client,
6 error::Error,
7 request::{Request, TryIntoRequest},
8};
9use std::future::IntoFuture;
10use twilight_model::channel::Message;
11
12#[must_use = "requests must be configured and executed"]
38pub struct ExecuteWebhookAndWait<'a> {
39 http: &'a Client,
40 inner: ExecuteWebhook<'a>,
41}
42
43impl<'a> ExecuteWebhookAndWait<'a> {
44 pub(crate) const fn new(http: &'a Client, inner: ExecuteWebhook<'a>) -> Self {
45 Self { http, inner }
46 }
47}
48
49#[cfg(not(target_os = "wasi"))]
50impl IntoFuture for ExecuteWebhookAndWait<'_> {
51 type Output = Result<Response<Message>, Error>;
52
53 type IntoFuture = ResponseFuture<Message>;
54
55 fn into_future(self) -> Self::IntoFuture {
56 let http = self.http;
57
58 match self.try_into_request() {
59 Ok(request) => http.request(request),
60 Err(source) => ResponseFuture::error(source),
61 }
62 }
63}
64
65impl TryIntoRequest for ExecuteWebhookAndWait<'_> {
66 fn try_into_request(self) -> Result<Request, Error> {
67 self.inner.try_into_request()
68 }
69}