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