modio/request/files/multipart/
get_multipart_upload_parts.rs

1use std::future::IntoFuture;
2
3use crate::client::Client;
4use crate::request::{Output, RequestBuilder, Route};
5use crate::response::ResponseFuture;
6use crate::types::files::multipart::{UploadId, UploadPart};
7use crate::types::id::{GameId, ModId};
8use crate::types::List;
9use crate::util::{Paginate, Paginator};
10
11pub struct GetMultipartUploadParts<'a> {
12    http: &'a Client,
13    game_id: GameId,
14    mod_id: ModId,
15    upload_id: UploadId,
16}
17
18impl<'a> GetMultipartUploadParts<'a> {
19    pub(crate) const fn new(
20        http: &'a Client,
21        game_id: GameId,
22        mod_id: ModId,
23        upload_id: UploadId,
24    ) -> Self {
25        Self {
26            http,
27            game_id,
28            mod_id,
29            upload_id,
30        }
31    }
32}
33
34impl IntoFuture for GetMultipartUploadParts<'_> {
35    type Output = Output<List<UploadPart>>;
36    type IntoFuture = ResponseFuture<List<UploadPart>>;
37
38    fn into_future(self) -> Self::IntoFuture {
39        let route = Route::GetMultipartUploadParts {
40            game_id: self.game_id,
41            mod_id: self.mod_id,
42            upload_id: self.upload_id,
43        };
44        match RequestBuilder::from_route(&route).empty() {
45            Ok(req) => self.http.request(req),
46            Err(err) => ResponseFuture::failed(err),
47        }
48    }
49}
50
51impl<'a> Paginate<'a> for GetMultipartUploadParts<'a> {
52    type Output = UploadPart;
53
54    fn paged(&'a self) -> Paginator<'a, Self::Output> {
55        let route = Route::GetMultipartUploadParts {
56            game_id: self.game_id,
57            mod_id: self.mod_id,
58            upload_id: self.upload_id,
59        };
60        Paginator::new(self.http, route, None)
61    }
62}