twilight_http/request/channel/thread/
get_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"]
22pub struct GetPrivateArchivedThreads<'a> {
23 before: Option<&'a str>,
24 channel_id: Id<ChannelMarker>,
25 http: &'a Client,
26 limit: Option<u64>,
27}
28
29impl<'a> GetPrivateArchivedThreads<'a> {
30 pub(crate) const fn new(http: &'a Client, channel_id: Id<ChannelMarker>) -> Self {
31 Self {
32 before: None,
33 channel_id,
34 http,
35 limit: None,
36 }
37 }
38
39 pub const fn before(mut self, before: &'a str) -> Self {
41 self.before = Some(before);
42
43 self
44 }
45
46 pub const fn limit(mut self, limit: u64) -> Self {
48 self.limit = Some(limit);
49
50 self
51 }
52}
53
54#[cfg(not(target_os = "wasi"))]
55impl IntoFuture for GetPrivateArchivedThreads<'_> {
56 type Output = Result<Response<ThreadsListing>, Error>;
57
58 type IntoFuture = ResponseFuture<ThreadsListing>;
59
60 fn into_future(self) -> Self::IntoFuture {
61 let http = self.http;
62
63 match self.try_into_request() {
64 Ok(request) => http.request(request),
65 Err(source) => ResponseFuture::error(source),
66 }
67 }
68}
69
70impl TryIntoRequest for GetPrivateArchivedThreads<'_> {
71 fn try_into_request(self) -> Result<Request, Error> {
72 Ok(Request::from_route(&Route::GetPrivateArchivedThreads {
73 before: self.before,
74 channel_id: self.channel_id.get(),
75 limit: self.limit,
76 }))
77 }
78}