twilight_http/request/channel/thread/
join_thread.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::{marker::ChannelMarker, Id};
10
11#[must_use = "requests must be configured and executed"]
13pub struct JoinThread<'a> {
14 channel_id: Id<ChannelMarker>,
15 http: &'a Client,
16}
17
18impl<'a> JoinThread<'a> {
19 pub(crate) const fn new(http: &'a Client, channel_id: Id<ChannelMarker>) -> Self {
20 Self { channel_id, http }
21 }
22}
23
24impl IntoFuture for JoinThread<'_> {
25 type Output = Result<Response<EmptyBody>, Error>;
26
27 type IntoFuture = ResponseFuture<EmptyBody>;
28
29 fn into_future(self) -> Self::IntoFuture {
30 let http = self.http;
31
32 match self.try_into_request() {
33 Ok(request) => http.request(request),
34 Err(source) => ResponseFuture::error(source),
35 }
36 }
37}
38
39impl TryIntoRequest for JoinThread<'_> {
40 fn try_into_request(self) -> Result<Request, Error> {
41 Ok(Request::from_route(&Route::JoinThread {
42 channel_id: self.channel_id.get(),
43 }))
44 }
45}