modio/request/mods/
get_mod.rs

1use 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::Mod;
8
9/// Get a mod.
10pub struct GetMod<'a> {
11    http: &'a Client,
12    game_id: GameId,
13    mod_id: ModId,
14}
15
16impl<'a> GetMod<'a> {
17    pub(crate) const fn new(http: &'a Client, game_id: GameId, mod_id: ModId) -> Self {
18        Self {
19            http,
20            game_id,
21            mod_id,
22        }
23    }
24}
25
26impl IntoFuture for GetMod<'_> {
27    type Output = Output<Mod>;
28    type IntoFuture = ResponseFuture<Mod>;
29
30    fn into_future(self) -> Self::IntoFuture {
31        let route = Route::GetMod {
32            game_id: self.game_id,
33            mod_id: self.mod_id,
34        };
35        match RequestBuilder::from_route(&route).empty() {
36            Ok(req) => self.http.request(req),
37            Err(err) => ResponseFuture::failed(err),
38        }
39    }
40}