Skip to main content

nominal_api/conjure/objects/comments/api/
comment.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct Comment {
16    #[serde(rename = "rid")]
17    rid: super::CommentRid,
18    #[builder(custom(type = super::CommentParent, convert = Box::new))]
19    #[serde(rename = "parent")]
20    parent: Box<super::CommentParent>,
21    #[serde(rename = "authorRid")]
22    author_rid: conjure_object::ResourceIdentifier,
23    #[serde(rename = "createdAt")]
24    created_at: conjure_object::DateTime<conjure_object::Utc>,
25    #[builder(default, into)]
26    #[serde(rename = "editedAt", skip_serializing_if = "Option::is_none", default)]
27    edited_at: Option<conjure_object::DateTime<conjure_object::Utc>>,
28    #[builder(default, into)]
29    #[serde(rename = "deletedAt", skip_serializing_if = "Option::is_none", default)]
30    deleted_at: Option<conjure_object::DateTime<conjure_object::Utc>>,
31    #[builder(into)]
32    #[serde(rename = "content")]
33    content: String,
34    #[builder(default, into)]
35    #[serde(rename = "pinnedBy", skip_serializing_if = "Option::is_none", default)]
36    pinned_by: Option<conjure_object::ResourceIdentifier>,
37    #[builder(default, into)]
38    #[serde(rename = "pinnedAt", skip_serializing_if = "Option::is_none", default)]
39    pinned_at: Option<conjure_object::DateTime<conjure_object::Utc>>,
40    #[builder(default, list(item(type = super::Reaction)))]
41    #[serde(rename = "reactions", skip_serializing_if = "Vec::is_empty", default)]
42    reactions: Vec<super::Reaction>,
43    #[builder(default, set(item(type = super::super::super::api::rids::AttachmentRid)))]
44    #[serde(
45        rename = "attachments",
46        skip_serializing_if = "std::collections::BTreeSet::is_empty",
47        default
48    )]
49    attachments: std::collections::BTreeSet<
50        super::super::super::api::rids::AttachmentRid,
51    >,
52}
53impl Comment {
54    /// Unique resource identifier for the comment
55    #[inline]
56    pub fn rid(&self) -> &super::CommentRid {
57        &self.rid
58    }
59    /// The parent of the comment. It can be a resource or another comment.
60    #[inline]
61    pub fn parent(&self) -> &super::CommentParent {
62        &*self.parent
63    }
64    /// The user who authored the comment
65    #[inline]
66    pub fn author_rid(&self) -> &conjure_object::ResourceIdentifier {
67        &self.author_rid
68    }
69    /// The time the comment was created
70    #[inline]
71    pub fn created_at(&self) -> conjure_object::DateTime<conjure_object::Utc> {
72        self.created_at
73    }
74    /// The time the comment was edited. Empty if the comment has not been edited.
75    #[inline]
76    pub fn edited_at(&self) -> Option<conjure_object::DateTime<conjure_object::Utc>> {
77        self.edited_at.as_ref().map(|o| *o)
78    }
79    /// The time the comment was deleted. Empty if the comment has not been deleted.
80    #[inline]
81    pub fn deleted_at(&self) -> Option<conjure_object::DateTime<conjure_object::Utc>> {
82        self.deleted_at.as_ref().map(|o| *o)
83    }
84    /// The markdown content of the comment.
85    #[inline]
86    pub fn content(&self) -> &str {
87        &*self.content
88    }
89    /// The user who pinned the comment. Empty if the comment is not pinned.
90    #[inline]
91    pub fn pinned_by(&self) -> Option<&conjure_object::ResourceIdentifier> {
92        self.pinned_by.as_ref().map(|o| &*o)
93    }
94    /// The time the comment was pinned. Empty if the comment is not pinned.
95    #[inline]
96    pub fn pinned_at(&self) -> Option<conjure_object::DateTime<conjure_object::Utc>> {
97        self.pinned_at.as_ref().map(|o| *o)
98    }
99    /// The reactions on the comment
100    #[inline]
101    pub fn reactions(&self) -> &[super::Reaction] {
102        &*self.reactions
103    }
104    /// The comment's attachments
105    #[inline]
106    pub fn attachments(
107        &self,
108    ) -> &std::collections::BTreeSet<super::super::super::api::rids::AttachmentRid> {
109        &self.attachments
110    }
111}