diff options
author | Colin Reeder <colin@vpzom.click> | 2020-11-11 22:42:08 -0700 |
---|---|---|
committer | Colin Reeder <colin@vpzom.click> | 2020-11-11 22:43:48 -0700 |
commit | 19a16864e5a0a31de923d13050d4a5b43da69d45 (patch) | |
tree | 7bc13ca71a04626352b3231b855f062bfee69e05 /src/resp_types.rs | |
parent | 73d29fc3400c54f1a5d8cfe5d8a1ead7f2d60eda (diff) |
Show comment count in post lists
Diffstat (limited to 'src/resp_types.rs')
-rw-r--r-- | src/resp_types.rs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/resp_types.rs b/src/resp_types.rs index 0382cc9..e77d03d 100644 --- a/src/resp_types.rs +++ b/src/resp_types.rs @@ -17,7 +17,7 @@ pub struct RespMinimalPostInfo<'a> { } #[derive(Deserialize, Debug)] -pub struct RespPostListPost<'a> { +pub struct RespSomePostInfo<'a> { #[serde(flatten)] pub base: RespMinimalPostInfo<'a>, pub href: Option<Cow<'a, str>>, @@ -28,13 +28,26 @@ pub struct RespPostListPost<'a> { pub community: RespMinimalCommunityInfo<'a>, } -impl<'a> AsRef<RespMinimalPostInfo<'a>> for RespPostListPost<'a> { +impl<'a> AsRef<RespMinimalPostInfo<'a>> for RespSomePostInfo<'a> { fn as_ref(&self) -> &RespMinimalPostInfo<'a> { &self.base } } #[derive(Deserialize, Debug)] +pub struct RespPostListPost<'a> { + #[serde(flatten, borrow)] + pub base: RespSomePostInfo<'a>, + pub replies_count_total: i64, +} + +impl<'a> AsRef<RespSomePostInfo<'a>> for RespPostListPost<'a> { + fn as_ref(&self) -> &RespSomePostInfo<'a> { + &self.base + } +} + +#[derive(Deserialize, Debug)] #[serde(tag = "type")] pub enum RespThingInfo<'a> { #[serde(rename = "post")] @@ -114,7 +127,7 @@ impl<'a> AsRef<RespPostCommentInfo<'a>> for RespCommentInfo<'a> { #[derive(Deserialize, Debug)] pub struct RespPostInfo<'a> { #[serde(flatten, borrow)] - pub base: RespPostListPost<'a>, + pub base: RespSomePostInfo<'a>, pub content_text: Option<Cow<'a, str>>, pub content_html: Option<Cow<'a, str>>, @@ -126,8 +139,8 @@ pub struct RespPostInfo<'a> { pub your_vote: Option<Empty>, } -impl<'a> AsRef<RespPostListPost<'a>> for RespPostInfo<'a> { - fn as_ref(&self) -> &RespPostListPost<'a> { +impl<'a> AsRef<RespSomePostInfo<'a>> for RespPostInfo<'a> { + fn as_ref(&self) -> &RespSomePostInfo<'a> { &self.base } } |