jacquard_api/pub_leaflet/
comment.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: pub.leaflet.comment
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    jacquard_derive::IntoStatic,
17    bon::Builder
18)]
19#[serde(rename_all = "camelCase")]
20pub struct LinearDocumentQuote<'a> {
21    #[serde(borrow)]
22    pub document: jacquard_common::types::string::AtUri<'a>,
23    #[serde(borrow)]
24    pub quote: crate::pub_leaflet::pages::linear_document::Quote<'a>,
25}
26
27/// Record containing a comment
28#[jacquard_derive::lexicon]
29#[derive(
30    serde::Serialize,
31    serde::Deserialize,
32    Debug,
33    Clone,
34    PartialEq,
35    Eq,
36    jacquard_derive::IntoStatic,
37    bon::Builder
38)]
39#[serde(rename_all = "camelCase")]
40pub struct Comment<'a> {
41    #[serde(skip_serializing_if = "std::option::Option::is_none")]
42    #[builder(into)]
43    #[serde(borrow)]
44    pub attachment: Option<crate::pub_leaflet::comment::LinearDocumentQuote<'a>>,
45    pub created_at: jacquard_common::types::string::Datetime,
46    #[serde(skip_serializing_if = "std::option::Option::is_none")]
47    #[builder(into)]
48    #[serde(borrow)]
49    pub facets: Option<Vec<crate::pub_leaflet::richtext::facet::Facet<'a>>>,
50    #[serde(borrow)]
51    #[builder(into)]
52    pub plaintext: jacquard_common::CowStr<'a>,
53    #[serde(skip_serializing_if = "std::option::Option::is_none")]
54    #[builder(into)]
55    #[serde(borrow)]
56    pub reply: Option<crate::pub_leaflet::comment::ReplyRef<'a>>,
57    #[serde(borrow)]
58    pub subject: jacquard_common::types::string::AtUri<'a>,
59}
60
61impl<'a> Comment<'a> {
62    pub fn uri(
63        uri: impl Into<jacquard_common::CowStr<'a>>,
64    ) -> Result<
65        jacquard_common::types::uri::RecordUri<'a, CommentRecord>,
66        jacquard_common::types::uri::UriError,
67    > {
68        jacquard_common::types::uri::RecordUri::try_from_uri(
69            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
70        )
71    }
72}
73
74/// Typed wrapper for GetRecord response with this collection's record type.
75#[derive(
76    serde::Serialize,
77    serde::Deserialize,
78    Debug,
79    Clone,
80    PartialEq,
81    Eq,
82    jacquard_derive::IntoStatic
83)]
84#[serde(rename_all = "camelCase")]
85pub struct CommentGetRecordOutput<'a> {
86    #[serde(skip_serializing_if = "std::option::Option::is_none")]
87    #[serde(borrow)]
88    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
89    #[serde(borrow)]
90    pub uri: jacquard_common::types::string::AtUri<'a>,
91    #[serde(borrow)]
92    pub value: Comment<'a>,
93}
94
95impl From<CommentGetRecordOutput<'_>> for Comment<'_> {
96    fn from(output: CommentGetRecordOutput<'_>) -> Self {
97        use jacquard_common::IntoStatic;
98        output.value.into_static()
99    }
100}
101
102impl jacquard_common::types::collection::Collection for Comment<'_> {
103    const NSID: &'static str = "pub.leaflet.comment";
104    type Record = CommentRecord;
105}
106
107/// Marker type for deserializing records from this collection.
108#[derive(Debug, serde::Serialize, serde::Deserialize)]
109pub struct CommentRecord;
110impl jacquard_common::xrpc::XrpcResp for CommentRecord {
111    const NSID: &'static str = "pub.leaflet.comment";
112    const ENCODING: &'static str = "application/json";
113    type Output<'de> = CommentGetRecordOutput<'de>;
114    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
115}
116
117impl jacquard_common::types::collection::Collection for CommentRecord {
118    const NSID: &'static str = "pub.leaflet.comment";
119    type Record = CommentRecord;
120}
121
122#[jacquard_derive::lexicon]
123#[derive(
124    serde::Serialize,
125    serde::Deserialize,
126    Debug,
127    Clone,
128    PartialEq,
129    Eq,
130    jacquard_derive::IntoStatic,
131    bon::Builder
132)]
133#[serde(rename_all = "camelCase")]
134pub struct ReplyRef<'a> {
135    #[serde(borrow)]
136    pub parent: jacquard_common::types::string::AtUri<'a>,
137}