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