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