1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
use serde_derive::Deserialize;
use std::borrow::Cow;
#[derive(Deserialize, Debug)]
pub struct RespMinimalAuthorInfo<'a> {
pub id: i64,
pub username: Cow<'a, str>,
pub local: bool,
pub host: Cow<'a, str>,
}
#[derive(Deserialize, Debug)]
pub struct RespPostListPost<'a> {
pub id: i64,
pub title: Cow<'a, str>,
pub href: Option<Cow<'a, str>>,
pub content_text: Option<Cow<'a, str>>,
pub content_html: Option<Cow<'a, str>>,
#[serde(borrow)]
pub author: Option<RespMinimalAuthorInfo<'a>>,
pub created: Cow<'a, str>,
#[serde(borrow)]
pub community: RespMinimalCommunityInfo<'a>,
}
#[derive(Deserialize, Debug)]
pub struct RespPostCommentInfo<'a> {
pub id: i64,
#[serde(borrow)]
pub author: Option<RespMinimalAuthorInfo<'a>>,
pub created: Cow<'a, str>,
pub content_text: Option<Cow<'a, str>>,
pub content_html: Option<Cow<'a, str>>,
pub your_vote: Option<Empty>,
#[serde(borrow)]
pub replies: Option<Vec<RespPostCommentInfo<'a>>>,
}
#[derive(Deserialize, Debug)]
pub struct RespPostInfo<'a> {
#[serde(flatten, borrow)]
pub base: RespPostListPost<'a>,
pub score: i64,
#[serde(borrow)]
pub comments: Vec<RespPostCommentInfo<'a>>,
pub your_vote: Option<Empty>,
}
impl<'a> AsRef<RespPostListPost<'a>> for RespPostInfo<'a> {
fn as_ref(&self) -> &RespPostListPost<'a> {
&self.base
}
}
#[derive(Deserialize, Debug)]
pub struct RespMinimalCommunityInfo<'a> {
pub id: i64,
pub name: Cow<'a, str>,
pub local: bool,
pub host: Cow<'a, str>,
}
#[derive(Deserialize, Debug)]
pub struct RespLoginInfoUser {
pub id: i64,
}
#[derive(Deserialize, Debug)]
pub struct RespLoginInfo {
pub user: RespLoginInfoUser,
}
#[derive(Deserialize, Debug)]
pub struct Empty {}
#[derive(Deserialize, Debug)]
pub struct RespYourFollow {
pub accepted: bool,
}
#[derive(Deserialize)]
pub struct RespCommunityInfoMaybeYour<'a> {
#[serde(flatten)]
pub base: RespMinimalCommunityInfo<'a>,
pub your_follow: Option<RespYourFollow>,
}
impl<'a> AsRef<RespMinimalCommunityInfo<'a>> for RespCommunityInfoMaybeYour<'a> {
fn as_ref(&self) -> &RespMinimalCommunityInfo<'a> {
&self.base
}
}
|