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