jacquard_api/place_stream/chat/
message.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: place.stream.chat.message
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record containing a Streamplace chat message.
9#[jacquard_derive::lexicon]
10#[derive(
11    serde::Serialize,
12    serde::Deserialize,
13    Debug,
14    Clone,
15    PartialEq,
16    Eq,
17    jacquard_derive::IntoStatic,
18    bon::Builder
19)]
20#[serde(rename_all = "camelCase")]
21pub struct Message<'a> {
22    /// Client-declared timestamp when this message was originally created.
23    pub created_at: jacquard_common::types::string::Datetime,
24    /// Annotations of text (mentions, URLs, etc)
25    #[serde(skip_serializing_if = "std::option::Option::is_none")]
26    #[builder(into)]
27    #[serde(borrow)]
28    pub facets: Option<Vec<crate::place_stream::richtext::facet::Facet<'a>>>,
29    #[serde(skip_serializing_if = "std::option::Option::is_none")]
30    #[builder(into)]
31    #[serde(borrow)]
32    pub reply: Option<crate::place_stream::chat::message::ReplyRef<'a>>,
33    /// The DID of the streamer whose chat this is.
34    #[serde(borrow)]
35    pub streamer: jacquard_common::types::string::Did<'a>,
36    /// The primary message content. May be an empty string, if there are embeds.
37    #[serde(borrow)]
38    #[builder(into)]
39    pub text: jacquard_common::CowStr<'a>,
40}
41
42impl<'a> Message<'a> {
43    pub fn uri(
44        uri: impl Into<jacquard_common::CowStr<'a>>,
45    ) -> Result<
46        jacquard_common::types::uri::RecordUri<'a, MessageRecord>,
47        jacquard_common::types::uri::UriError,
48    > {
49        jacquard_common::types::uri::RecordUri::try_from_uri(
50            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
51        )
52    }
53}
54
55/// Typed wrapper for GetRecord response with this collection's record type.
56#[derive(
57    serde::Serialize,
58    serde::Deserialize,
59    Debug,
60    Clone,
61    PartialEq,
62    Eq,
63    jacquard_derive::IntoStatic
64)]
65#[serde(rename_all = "camelCase")]
66pub struct MessageGetRecordOutput<'a> {
67    #[serde(skip_serializing_if = "std::option::Option::is_none")]
68    #[serde(borrow)]
69    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
70    #[serde(borrow)]
71    pub uri: jacquard_common::types::string::AtUri<'a>,
72    #[serde(borrow)]
73    pub value: Message<'a>,
74}
75
76impl From<MessageGetRecordOutput<'_>> for Message<'_> {
77    fn from(output: MessageGetRecordOutput<'_>) -> Self {
78        use jacquard_common::IntoStatic;
79        output.value.into_static()
80    }
81}
82
83impl jacquard_common::types::collection::Collection for Message<'_> {
84    const NSID: &'static str = "place.stream.chat.message";
85    type Record = MessageRecord;
86}
87
88/// Marker type for deserializing records from this collection.
89#[derive(Debug, serde::Serialize, serde::Deserialize)]
90pub struct MessageRecord;
91impl jacquard_common::xrpc::XrpcResp for MessageRecord {
92    const NSID: &'static str = "place.stream.chat.message";
93    const ENCODING: &'static str = "application/json";
94    type Output<'de> = MessageGetRecordOutput<'de>;
95    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
96}
97
98impl jacquard_common::types::collection::Collection for MessageRecord {
99    const NSID: &'static str = "place.stream.chat.message";
100    type Record = MessageRecord;
101}
102
103#[jacquard_derive::lexicon]
104#[derive(
105    serde::Serialize,
106    serde::Deserialize,
107    Debug,
108    Clone,
109    PartialEq,
110    Eq,
111    jacquard_derive::IntoStatic,
112    bon::Builder
113)]
114#[serde(rename_all = "camelCase")]
115pub struct ReplyRef<'a> {
116    #[serde(borrow)]
117    pub parent: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
118    #[serde(borrow)]
119    pub root: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
120}