summaryrefslogtreecommitdiffstats
path: root/src/components/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/mod.rs')
-rw-r--r--src/components/mod.rs38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 793c54c..5c529ca 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -4,9 +4,9 @@ use std::borrow::{Borrow, Cow};
use std::collections::HashMap;
use crate::resp_types::{
- RespCommentInfo, RespMinimalAuthorInfo, RespMinimalCommentInfo, RespMinimalCommunityInfo,
- RespNotification, RespNotificationInfo, RespPostCommentInfo, RespPostInfo, RespPostListPost,
- RespThingComment, RespThingInfo,
+ RespCommentInfo, RespCommunityInfoMaybeYour, RespMinimalAuthorInfo, RespMinimalCommentInfo,
+ RespMinimalCommunityInfo, RespNotification, RespNotificationInfo, RespPostCommentInfo,
+ RespPostInfo, RespPostListPost, RespThingComment, RespThingInfo, RespUserInfo,
};
use crate::util::{abbreviate_link, author_is_me};
use crate::PageBaseData;
@@ -194,6 +194,38 @@ impl<'a> HavingContent for RespPostInfo<'a> {
}
}
+pub struct HavingContentRef<'a> {
+ content_html: Option<&'a str>,
+ content_text: Option<&'a str>,
+}
+
+impl<'a> HavingContent for HavingContentRef<'a> {
+ fn content_text(&self) -> Option<&str> {
+ self.content_text
+ }
+ fn content_html(&self) -> Option<&str> {
+ self.content_html
+ }
+}
+
+impl<'a> RespUserInfo<'a> {
+ pub fn description(&'a self) -> HavingContentRef<'a> {
+ HavingContentRef {
+ content_html: self.description_html.as_deref(),
+ content_text: self.description_text.as_deref(),
+ }
+ }
+}
+
+impl<'a> RespCommunityInfoMaybeYour<'a> {
+ pub fn description(&'a self) -> HavingContentRef<'a> {
+ HavingContentRef {
+ content_html: self.description_html.as_deref(),
+ content_text: self.description_text.as_deref(),
+ }
+ }
+}
+
pub struct Content<'a, T: HavingContent + 'a> {
pub src: &'a T,
}