twilight_http/request/channel/invite/
get_channel_invites.rs1#[cfg(not(target_os = "wasi"))]
2use crate::response::{Response, ResponseFuture, marker::ListBody};
3use crate::{
4 client::Client,
5 error::Error,
6 request::{Request, TryIntoRequest},
7 routing::Route,
8};
9use std::future::IntoFuture;
10use twilight_model::{
11 guild::invite::Invite,
12 id::{Id, marker::ChannelMarker},
13};
14
15#[must_use = "requests must be configured and executed"]
22pub struct GetChannelInvites<'a> {
23 channel_id: Id<ChannelMarker>,
24 http: &'a Client,
25}
26
27impl<'a> GetChannelInvites<'a> {
28 pub(crate) const fn new(http: &'a Client, channel_id: Id<ChannelMarker>) -> Self {
29 Self { channel_id, http }
30 }
31}
32
33#[cfg(not(target_os = "wasi"))]
34impl IntoFuture for GetChannelInvites<'_> {
35 type Output = Result<Response<ListBody<Invite>>, Error>;
36
37 type IntoFuture = ResponseFuture<ListBody<Invite>>;
38
39 fn into_future(self) -> Self::IntoFuture {
40 let http = self.http;
41
42 match self.try_into_request() {
43 Ok(request) => http.request(request),
44 Err(source) => ResponseFuture::error(source),
45 }
46 }
47}
48
49impl TryIntoRequest for GetChannelInvites<'_> {
50 fn try_into_request(self) -> Result<Request, Error> {
51 Ok(Request::from_route(&Route::GetChannelInvites {
52 channel_id: self.channel_id.get(),
53 }))
54 }
55}