modio/request/mods/comments/
edit_mod_comment.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::id::{CommentId, GameId, ModId};
9use crate::types::mods::Comment;
10
11pub struct EditModComment<'a> {
13 http: &'a Client,
14 game_id: GameId,
15 mod_id: ModId,
16 comment_id: CommentId,
17 fields: EditModCommentFields<'a>,
18}
19
20#[derive(Serialize)]
21struct EditModCommentFields<'a> {
22 content: &'a str,
23}
24
25impl<'a> EditModComment<'a> {
26 pub(crate) const fn new(
27 http: &'a Client,
28 game_id: GameId,
29 mod_id: ModId,
30 comment_id: CommentId,
31 content: &'a str,
32 ) -> Self {
33 Self {
34 http,
35 game_id,
36 mod_id,
37 comment_id,
38 fields: EditModCommentFields { content },
39 }
40 }
41}
42
43impl IntoFuture for EditModComment<'_> {
44 type Output = Output<Comment>;
45 type IntoFuture = ResponseFuture<Comment>;
46
47 fn into_future(self) -> Self::IntoFuture {
48 let route = Route::EditModComment {
49 game_id: self.game_id,
50 mod_id: self.mod_id,
51 comment_id: self.comment_id,
52 };
53
54 match RequestBuilder::from_route(&route).form(&self.fields) {
55 Ok(req) => self.http.request(req),
56 Err(err) => ResponseFuture::failed(err),
57 }
58 }
59}