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