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