jacquard_api/net_anisota/feed/
draft.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: net.anisota.feed.draft
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 draft post that can be edited and later published as app.bsky.feed.post
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 Draft<'a> {
22    /// Client-declared timestamp when this draft was originally created.
23    pub created_at: jacquard_common::types::string::Datetime,
24    #[serde(skip_serializing_if = "std::option::Option::is_none")]
25    #[builder(into)]
26    #[serde(borrow)]
27    pub embed: Option<DraftEmbed<'a>>,
28    /// Annotations of text (mentions, URLs, hashtags, etc)
29    #[serde(skip_serializing_if = "std::option::Option::is_none")]
30    #[builder(into)]
31    #[serde(borrow)]
32    pub facets: Option<Vec<crate::app_bsky::richtext::facet::Facet<'a>>>,
33    /// Self-label values for this post. Effectively content warnings.
34    #[serde(skip_serializing_if = "std::option::Option::is_none")]
35    #[builder(into)]
36    #[serde(borrow)]
37    pub labels: Option<crate::com_atproto::label::SelfLabels<'a>>,
38    /// Indicates human language of post primary text content.
39    #[serde(skip_serializing_if = "std::option::Option::is_none")]
40    #[builder(into)]
41    pub langs: Option<Vec<jacquard_common::types::string::Language>>,
42    #[serde(skip_serializing_if = "std::option::Option::is_none")]
43    #[builder(into)]
44    #[serde(borrow)]
45    pub reply: Option<crate::net_anisota::feed::draft::ReplyRef<'a>>,
46    /// Additional hashtags, in addition to any included in post text and facets.
47    #[serde(skip_serializing_if = "std::option::Option::is_none")]
48    #[builder(into)]
49    #[serde(borrow)]
50    pub tags: Option<Vec<jacquard_common::CowStr<'a>>>,
51    /// The primary post content. May be an empty string, if there are embeds.
52    #[serde(borrow)]
53    #[builder(into)]
54    pub text: jacquard_common::CowStr<'a>,
55    /// Client-declared timestamp when this draft was last updated.
56    #[serde(skip_serializing_if = "std::option::Option::is_none")]
57    #[builder(into)]
58    pub updated_at: Option<jacquard_common::types::string::Datetime>,
59}
60
61impl<'a> Draft<'a> {
62    pub fn uri(
63        uri: impl Into<jacquard_common::CowStr<'a>>,
64    ) -> Result<
65        jacquard_common::types::uri::RecordUri<'a, DraftRecord>,
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#[jacquard_derive::open_union]
75#[derive(
76    serde::Serialize,
77    serde::Deserialize,
78    Debug,
79    Clone,
80    PartialEq,
81    Eq,
82    jacquard_derive::IntoStatic
83)]
84#[serde(tag = "$type")]
85#[serde(bound(deserialize = "'de: 'a"))]
86pub enum DraftEmbed<'a> {
87    #[serde(rename = "app.bsky.embed.images")]
88    Images(Box<crate::app_bsky::embed::images::Images<'a>>),
89    #[serde(rename = "app.bsky.embed.video")]
90    Video(Box<crate::app_bsky::embed::video::Video<'a>>),
91    #[serde(rename = "app.bsky.embed.external")]
92    External(Box<crate::app_bsky::embed::external::ExternalRecord<'a>>),
93    #[serde(rename = "app.bsky.embed.record")]
94    Record(Box<crate::app_bsky::embed::record::Record<'a>>),
95    #[serde(rename = "app.bsky.embed.recordWithMedia")]
96    RecordWithMedia(Box<crate::app_bsky::embed::record_with_media::RecordWithMedia<'a>>),
97}
98
99/// Typed wrapper for GetRecord response with this collection's record type.
100#[derive(
101    serde::Serialize,
102    serde::Deserialize,
103    Debug,
104    Clone,
105    PartialEq,
106    Eq,
107    jacquard_derive::IntoStatic
108)]
109#[serde(rename_all = "camelCase")]
110pub struct DraftGetRecordOutput<'a> {
111    #[serde(skip_serializing_if = "std::option::Option::is_none")]
112    #[serde(borrow)]
113    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
114    #[serde(borrow)]
115    pub uri: jacquard_common::types::string::AtUri<'a>,
116    #[serde(borrow)]
117    pub value: Draft<'a>,
118}
119
120impl From<DraftGetRecordOutput<'_>> for Draft<'_> {
121    fn from(output: DraftGetRecordOutput<'_>) -> Self {
122        use jacquard_common::IntoStatic;
123        output.value.into_static()
124    }
125}
126
127impl jacquard_common::types::collection::Collection for Draft<'_> {
128    const NSID: &'static str = "net.anisota.feed.draft";
129    type Record = DraftRecord;
130}
131
132/// Marker type for deserializing records from this collection.
133#[derive(Debug, serde::Serialize, serde::Deserialize)]
134pub struct DraftRecord;
135impl jacquard_common::xrpc::XrpcResp for DraftRecord {
136    const NSID: &'static str = "net.anisota.feed.draft";
137    const ENCODING: &'static str = "application/json";
138    type Output<'de> = DraftGetRecordOutput<'de>;
139    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
140}
141
142impl jacquard_common::types::collection::Collection for DraftRecord {
143    const NSID: &'static str = "net.anisota.feed.draft";
144    type Record = DraftRecord;
145}
146
147#[jacquard_derive::lexicon]
148#[derive(
149    serde::Serialize,
150    serde::Deserialize,
151    Debug,
152    Clone,
153    PartialEq,
154    Eq,
155    jacquard_derive::IntoStatic,
156    bon::Builder
157)]
158#[serde(rename_all = "camelCase")]
159pub struct ReplyRef<'a> {
160    #[serde(borrow)]
161    pub parent: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
162    #[serde(borrow)]
163    pub root: crate::com_atproto::repo::strong_ref::StrongRef<'a>,
164}