jacquard_api/app_bsky/feed/
post.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.feed.post
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Deprecated: use facets instead.
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 Entity<'a> {
22    #[serde(borrow)]
23    pub index: crate::app_bsky::feed::post::TextSlice<'a>,
24    /// Expected values are 'mention' and 'link'.
25    #[serde(borrow)]
26    #[builder(into)]
27    pub r#type: jacquard_common::CowStr<'a>,
28    #[serde(borrow)]
29    #[builder(into)]
30    pub value: jacquard_common::CowStr<'a>,
31}
32
33/// Record containing a Bluesky post.
34#[jacquard_derive::lexicon]
35#[derive(
36    serde::Serialize,
37    serde::Deserialize,
38    Debug,
39    Clone,
40    PartialEq,
41    Eq,
42    jacquard_derive::IntoStatic,
43    bon::Builder
44)]
45#[serde(rename_all = "camelCase")]
46pub struct Post<'a> {
47    /// Client-declared timestamp when this post was originally created.
48    pub created_at: jacquard_common::types::string::Datetime,
49    #[serde(skip_serializing_if = "std::option::Option::is_none")]
50    #[builder(into)]
51    #[serde(borrow)]
52    pub embed: Option<PostEmbed<'a>>,
53    /// DEPRECATED: replaced by app.bsky.richtext.facet.
54    #[serde(skip_serializing_if = "std::option::Option::is_none")]
55    #[builder(into)]
56    #[serde(borrow)]
57    pub entities: Option<Vec<crate::app_bsky::feed::post::Entity<'a>>>,
58    /// Annotations of text (mentions, URLs, hashtags, etc)
59    #[serde(skip_serializing_if = "std::option::Option::is_none")]
60    #[builder(into)]
61    #[serde(borrow)]
62    pub facets: Option<Vec<crate::app_bsky::richtext::facet::Facet<'a>>>,
63    /// Self-label values for this post. Effectively content warnings.
64    #[serde(skip_serializing_if = "std::option::Option::is_none")]
65    #[builder(into)]
66    #[serde(borrow)]
67    pub labels: Option<crate::com_atproto::label::SelfLabels<'a>>,
68    /// Indicates human language of post primary text content.
69    #[serde(skip_serializing_if = "std::option::Option::is_none")]
70    #[builder(into)]
71    pub langs: Option<Vec<jacquard_common::types::string::Language>>,
72    #[serde(skip_serializing_if = "std::option::Option::is_none")]
73    #[builder(into)]
74    #[serde(borrow)]
75    pub reply: Option<crate::app_bsky::feed::post::ReplyRef<'a>>,
76    /// Additional hashtags, in addition to any included in post text and facets.
77    #[serde(skip_serializing_if = "std::option::Option::is_none")]
78    #[builder(into)]
79    #[serde(borrow)]
80    pub tags: Option<Vec<jacquard_common::CowStr<'a>>>,
81    /// The primary post content. May be an empty string, if there are embeds.
82    #[serde(borrow)]
83    #[builder(into)]
84    pub text: jacquard_common::CowStr<'a>,
85}
86
87impl<'a> Post<'a> {
88    pub fn uri(
89        uri: impl Into<jacquard_common::CowStr<'a>>,
90    ) -> Result<
91        jacquard_common::types::uri::RecordUri<'a, PostRecord>,
92        jacquard_common::types::uri::UriError,
93    > {
94        jacquard_common::types::uri::RecordUri::try_from_uri(
95            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
96        )
97    }
98}
99
100#[jacquard_derive::open_union]
101#[derive(
102    serde::Serialize,
103    serde::Deserialize,
104    Debug,
105    Clone,
106    PartialEq,
107    Eq,
108    jacquard_derive::IntoStatic
109)]
110#[serde(tag = "$type")]
111#[serde(bound(deserialize = "'de: 'a"))]
112pub enum PostEmbed<'a> {
113    #[serde(rename = "app.bsky.embed.images")]
114    Images(Box<crate::app_bsky::embed::images::Images<'a>>),
115    #[serde(rename = "app.bsky.embed.video")]
116    Video(Box<crate::app_bsky::embed::video::Video<'a>>),
117    #[serde(rename = "app.bsky.embed.external")]
118    External(Box<crate::app_bsky::embed::external::ExternalRecord<'a>>),
119    #[serde(rename = "app.bsky.embed.record")]
120    Record(Box<crate::app_bsky::embed::record::Record<'a>>),
121    #[serde(rename = "app.bsky.embed.recordWithMedia")]
122    RecordWithMedia(Box<crate::app_bsky::embed::record_with_media::RecordWithMedia<'a>>),
123}
124
125/// Typed wrapper for GetRecord response with this collection's record type.
126#[derive(
127    serde::Serialize,
128    serde::Deserialize,
129    Debug,
130    Clone,
131    PartialEq,
132    Eq,
133    jacquard_derive::IntoStatic
134)]
135#[serde(rename_all = "camelCase")]
136pub struct PostGetRecordOutput<'a> {
137    #[serde(skip_serializing_if = "std::option::Option::is_none")]
138    #[serde(borrow)]
139    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
140    #[serde(borrow)]
141    pub uri: jacquard_common::types::string::AtUri<'a>,
142    #[serde(borrow)]
143    pub value: Post<'a>,
144}
145
146impl From<PostGetRecordOutput<'_>> for Post<'_> {
147    fn from(output: PostGetRecordOutput<'_>) -> Self {
148        use jacquard_common::IntoStatic;
149        output.value.into_static()
150    }
151}
152
153impl jacquard_common::types::collection::Collection for Post<'_> {
154    const NSID: &'static str = "app.bsky.feed.post";
155    type Record = PostRecord;
156}
157
158/// Marker type for deserializing records from this collection.
159#[derive(Debug, serde::Serialize, serde::Deserialize)]
160pub struct PostRecord;
161impl jacquard_common::xrpc::XrpcResp for PostRecord {
162    const NSID: &'static str = "app.bsky.feed.post";
163    const ENCODING: &'static str = "application/json";
164    type Output<'de> = PostGetRecordOutput<'de>;
165    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
166}
167
168impl jacquard_common::types::collection::Collection for PostRecord {
169    const NSID: &'static str = "app.bsky.feed.post";
170    type Record = PostRecord;
171}
172
173#[jacquard_derive::lexicon]
174#[derive(
175    serde::Serialize,
176    serde::Deserialize,
177    Debug,
178    Clone,
179    PartialEq,
180    Eq,
181    jacquard_derive::IntoStatic,
182    bon::Builder
183)]
184#[serde(rename_all = "camelCase")]
185pub struct ReplyRef<'a> {
186    #[serde(borrow)]
187    pub parent: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
188    #[serde(borrow)]
189    pub root: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
190}
191
192/// Deprecated. Use app.bsky.richtext instead -- A text segment. Start is inclusive, end is exclusive. Indices are for utf16-encoded strings.
193#[jacquard_derive::lexicon]
194#[derive(
195    serde::Serialize,
196    serde::Deserialize,
197    Debug,
198    Clone,
199    PartialEq,
200    Eq,
201    jacquard_derive::IntoStatic,
202    bon::Builder
203)]
204#[serde(rename_all = "camelCase")]
205pub struct TextSlice<'a> {
206    pub end: i64,
207    pub start: i64,
208}