modio/request/files/
get_file.rs1use std::future::IntoFuture;
2
3use crate::client::Client;
4use crate::request::{Output, RequestBuilder, Route};
5use crate::response::ResponseFuture;
6use crate::types::files::File;
7use crate::types::id::{FileId, GameId, ModId};
8
9pub struct GetFile<'a> {
11 http: &'a Client,
12 game_id: GameId,
13 mod_id: ModId,
14 file_id: FileId,
15}
16
17impl<'a> GetFile<'a> {
18 pub(crate) const fn new(
19 http: &'a Client,
20 game_id: GameId,
21 mod_id: ModId,
22 file_id: FileId,
23 ) -> Self {
24 Self {
25 http,
26 game_id,
27 mod_id,
28 file_id,
29 }
30 }
31}
32
33impl IntoFuture for GetFile<'_> {
34 type Output = Output<File>;
35 type IntoFuture = ResponseFuture<File>;
36
37 fn into_future(self) -> Self::IntoFuture {
38 let route = Route::GetFile {
39 game_id: self.game_id,
40 mod_id: self.mod_id,
41 file_id: self.file_id,
42 };
43 match RequestBuilder::from_route(&route).empty() {
44 Ok(req) => self.http.request(req),
45 Err(err) => ResponseFuture::failed(err),
46 }
47 }
48}