twilight_http/request/channel/thread/
get_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"]
21pub struct GetPrivateArchivedThreads<'a> {
22 before: Option<&'a str>,
23 channel_id: Id<ChannelMarker>,
24 http: &'a Client,
25 limit: Option<u64>,
26}
27
28impl<'a> GetPrivateArchivedThreads<'a> {
29 pub(crate) const fn new(http: &'a Client, channel_id: Id<ChannelMarker>) -> Self {
30 Self {
31 before: None,
32 channel_id,
33 http,
34 limit: None,
35 }
36 }
37
38 pub const fn before(mut self, before: &'a str) -> Self {
40 self.before = Some(before);
41
42 self
43 }
44
45 pub const fn limit(mut self, limit: u64) -> Self {
47 self.limit = Some(limit);
48
49 self
50 }
51}
52
53impl IntoFuture for GetPrivateArchivedThreads<'_> {
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 GetPrivateArchivedThreads<'_> {
69 fn try_into_request(self) -> Result<Request, Error> {
70 Ok(Request::from_route(&Route::GetPrivateArchivedThreads {
71 before: self.before,
72 channel_id: self.channel_id.get(),
73 limit: self.limit,
74 }))
75 }
76}