twilight_http/request/channel/thread/
get_joined_private_archived_threads.rs1use crate::{
2 client::Client,
3 error::Error,
4 request::{Request, TryIntoRequest},
5 response::{Response, ResponseFuture},
6 routing::Route,
7};
8use std::future::IntoFuture;
9use twilight_model::{
10 channel::thread::ThreadsListing,
11 id::{marker::ChannelMarker, Id},
12};
13
14#[must_use = "requests must be configured and executed"]
19pub struct GetJoinedPrivateArchivedThreads<'a> {
20 before: Option<Id<ChannelMarker>>,
21 channel_id: Id<ChannelMarker>,
22 http: &'a Client,
23 limit: Option<u64>,
24}
25
26impl<'a> GetJoinedPrivateArchivedThreads<'a> {
27 pub(crate) const fn new(http: &'a Client, channel_id: Id<ChannelMarker>) -> Self {
28 Self {
29 before: None,
30 channel_id,
31 http,
32 limit: None,
33 }
34 }
35
36 pub const fn before(mut self, before: Id<ChannelMarker>) -> Self {
38 self.before = Some(before);
39
40 self
41 }
42
43 pub const fn limit(mut self, limit: u64) -> Self {
45 self.limit = Some(limit);
46
47 self
48 }
49}
50
51impl IntoFuture for GetJoinedPrivateArchivedThreads<'_> {
52 type Output = Result<Response<ThreadsListing>, Error>;
53
54 type IntoFuture = ResponseFuture<ThreadsListing>;
55
56 fn into_future(self) -> Self::IntoFuture {
57 let http = self.http;
58
59 match self.try_into_request() {
60 Ok(request) => http.request(request),
61 Err(source) => ResponseFuture::error(source),
62 }
63 }
64}
65
66impl TryIntoRequest for GetJoinedPrivateArchivedThreads<'_> {
67 fn try_into_request(self) -> Result<Request, Error> {
68 Ok(Request::from_route(
69 &Route::GetJoinedPrivateArchivedThreads {
70 before: self.before.map(Id::get),
71 channel_id: self.channel_id.get(),
72 limit: self.limit,
73 },
74 ))
75 }
76}