jacquard_api/app_bsky/feed/
threadgate.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.feed.threadgate
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Allow replies from actors who follow you.
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    Default
19)]
20#[serde(rename_all = "camelCase")]
21pub struct FollowerRule<'a> {}
22/// Allow replies from actors you follow.
23#[jacquard_derive::lexicon]
24#[derive(
25    serde::Serialize,
26    serde::Deserialize,
27    Debug,
28    Clone,
29    PartialEq,
30    Eq,
31    jacquard_derive::IntoStatic,
32    Default
33)]
34#[serde(rename_all = "camelCase")]
35pub struct FollowingRule<'a> {}
36/// Allow replies from actors on a list.
37#[jacquard_derive::lexicon]
38#[derive(
39    serde::Serialize,
40    serde::Deserialize,
41    Debug,
42    Clone,
43    PartialEq,
44    Eq,
45    jacquard_derive::IntoStatic,
46    bon::Builder
47)]
48#[serde(rename_all = "camelCase")]
49pub struct ListRule<'a> {
50    #[serde(borrow)]
51    pub list: jacquard_common::types::string::AtUri<'a>,
52}
53
54/// Record defining interaction gating rules for a thread (aka, reply controls). The record key (rkey) of the threadgate record must match the record key of the thread's root post, and that record must be in the same repository.
55#[jacquard_derive::lexicon]
56#[derive(
57    serde::Serialize,
58    serde::Deserialize,
59    Debug,
60    Clone,
61    PartialEq,
62    Eq,
63    jacquard_derive::IntoStatic,
64    bon::Builder
65)]
66#[serde(rename_all = "camelCase")]
67pub struct Threadgate<'a> {
68    /// List of rules defining who can reply to this post. If value is an empty array, no one can reply. If value is undefined, anyone can reply.
69    #[serde(skip_serializing_if = "std::option::Option::is_none")]
70    #[builder(into)]
71    #[serde(borrow)]
72    pub allow: Option<Vec<ThreadgateAllowItem<'a>>>,
73    pub created_at: jacquard_common::types::string::Datetime,
74    /// List of hidden reply URIs.
75    #[serde(skip_serializing_if = "std::option::Option::is_none")]
76    #[builder(into)]
77    #[serde(borrow)]
78    pub hidden_replies: Option<Vec<jacquard_common::types::string::AtUri<'a>>>,
79    /// Reference (AT-URI) to the post record.
80    #[serde(borrow)]
81    pub post: jacquard_common::types::string::AtUri<'a>,
82}
83
84impl<'a> Threadgate<'a> {
85    pub fn uri(
86        uri: impl Into<jacquard_common::CowStr<'a>>,
87    ) -> Result<
88        jacquard_common::types::uri::RecordUri<'a, ThreadgateRecord>,
89        jacquard_common::types::uri::UriError,
90    > {
91        jacquard_common::types::uri::RecordUri::try_from_uri(
92            jacquard_common::types::string::AtUri::new_cow(uri.into())?,
93        )
94    }
95}
96
97#[jacquard_derive::open_union]
98#[derive(
99    serde::Serialize,
100    serde::Deserialize,
101    Debug,
102    Clone,
103    PartialEq,
104    Eq,
105    jacquard_derive::IntoStatic
106)]
107#[serde(tag = "$type")]
108#[serde(bound(deserialize = "'de: 'a"))]
109pub enum ThreadgateAllowItem<'a> {
110    #[serde(rename = "app.bsky.feed.threadgate#mentionRule")]
111    MentionRule(Box<crate::app_bsky::feed::threadgate::MentionRule<'a>>),
112    #[serde(rename = "app.bsky.feed.threadgate#followerRule")]
113    FollowerRule(Box<crate::app_bsky::feed::threadgate::FollowerRule<'a>>),
114    #[serde(rename = "app.bsky.feed.threadgate#followingRule")]
115    FollowingRule(Box<crate::app_bsky::feed::threadgate::FollowingRule<'a>>),
116    #[serde(rename = "app.bsky.feed.threadgate#listRule")]
117    ListRule(Box<crate::app_bsky::feed::threadgate::ListRule<'a>>),
118}
119
120/// Typed wrapper for GetRecord response with this collection's record type.
121#[derive(
122    serde::Serialize,
123    serde::Deserialize,
124    Debug,
125    Clone,
126    PartialEq,
127    Eq,
128    jacquard_derive::IntoStatic
129)]
130#[serde(rename_all = "camelCase")]
131pub struct ThreadgateGetRecordOutput<'a> {
132    #[serde(skip_serializing_if = "std::option::Option::is_none")]
133    #[serde(borrow)]
134    pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
135    #[serde(borrow)]
136    pub uri: jacquard_common::types::string::AtUri<'a>,
137    #[serde(borrow)]
138    pub value: Threadgate<'a>,
139}
140
141impl From<ThreadgateGetRecordOutput<'_>> for Threadgate<'_> {
142    fn from(output: ThreadgateGetRecordOutput<'_>) -> Self {
143        use jacquard_common::IntoStatic;
144        output.value.into_static()
145    }
146}
147
148impl jacquard_common::types::collection::Collection for Threadgate<'_> {
149    const NSID: &'static str = "app.bsky.feed.threadgate";
150    type Record = ThreadgateRecord;
151}
152
153/// Marker type for deserializing records from this collection.
154#[derive(Debug, serde::Serialize, serde::Deserialize)]
155pub struct ThreadgateRecord;
156impl jacquard_common::xrpc::XrpcResp for ThreadgateRecord {
157    const NSID: &'static str = "app.bsky.feed.threadgate";
158    const ENCODING: &'static str = "application/json";
159    type Output<'de> = ThreadgateGetRecordOutput<'de>;
160    type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
161}
162
163impl jacquard_common::types::collection::Collection for ThreadgateRecord {
164    const NSID: &'static str = "app.bsky.feed.threadgate";
165    type Record = ThreadgateRecord;
166}
167
168/// Allow replies from actors mentioned in your post.
169#[jacquard_derive::lexicon]
170#[derive(
171    serde::Serialize,
172    serde::Deserialize,
173    Debug,
174    Clone,
175    PartialEq,
176    Eq,
177    jacquard_derive::IntoStatic,
178    Default
179)]
180#[serde(rename_all = "camelCase")]
181pub struct MentionRule<'a> {}