modio/request/files/
manage_platform_status.rs1use std::future::IntoFuture;
2
3use serde_derive::Serialize;
4
5use crate::client::Client;
6use crate::request::{Output, RequestBuilder, Route};
7use crate::response::ResponseFuture;
8use crate::types::files::File;
9use crate::types::id::{FileId, GameId, ModId};
10use crate::types::TargetPlatform;
11
12pub struct ManagePlatformStatus<'a> {
14 http: &'a Client,
15 game_id: GameId,
16 mod_id: ModId,
17 file_id: FileId,
18 fields: ManagePlatformStatusFields<'a>,
19}
20
21#[derive(Serialize)]
22struct ManagePlatformStatusFields<'a> {
23 #[serde(skip_serializing_if = "Option::is_none")]
24 approved: Option<&'a [TargetPlatform]>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 denied: Option<&'a [TargetPlatform]>,
27}
28
29impl<'a> ManagePlatformStatus<'a> {
30 pub(crate) const fn new(
31 http: &'a Client,
32 game_id: GameId,
33 mod_id: ModId,
34 file_id: FileId,
35 ) -> Self {
36 Self {
37 http,
38 game_id,
39 mod_id,
40 file_id,
41 fields: ManagePlatformStatusFields {
42 approved: None,
43 denied: None,
44 },
45 }
46 }
47}
48
49impl IntoFuture for ManagePlatformStatus<'_> {
50 type Output = Output<File>;
51 type IntoFuture = ResponseFuture<File>;
52
53 fn into_future(self) -> Self::IntoFuture {
54 let route = Route::ManagePlatformStatus {
55 game_id: self.game_id,
56 mod_id: self.mod_id,
57 file_id: self.file_id,
58 };
59 match RequestBuilder::from_route(&route).form(&self.fields) {
60 Ok(req) => self.http.request(req),
61 Err(err) => ResponseFuture::failed(err),
62 }
63 }
64}