jacquard_api/app_bsky/graph/
listblock.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::collection::{Collection, RecordError};
18use jacquard_common::types::string::{AtUri, Cid, Datetime};
19use jacquard_common::types::uri::{RecordUri, UriError};
20use jacquard_common::xrpc::XrpcResp;
21use jacquard_derive::{IntoStatic, lexicon};
22use jacquard_lexicon::lexicon::LexiconDoc;
23use jacquard_lexicon::schema::LexiconSchema;
24
25#[allow(unused_imports)]
26use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
27use serde::{Serialize, Deserialize};
28#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
32#[serde(rename_all = "camelCase", rename = "app.bsky.graph.listblock", tag = "$type")]
33pub struct Listblock<'a> {
34 pub created_at: Datetime,
35 #[serde(borrow)]
37 pub subject: AtUri<'a>,
38}
39
40#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
43#[serde(rename_all = "camelCase")]
44pub struct ListblockGetRecordOutput<'a> {
45 #[serde(skip_serializing_if = "Option::is_none")]
46 #[serde(borrow)]
47 pub cid: Option<Cid<'a>>,
48 #[serde(borrow)]
49 pub uri: AtUri<'a>,
50 #[serde(borrow)]
51 pub value: Listblock<'a>,
52}
53
54impl<'a> Listblock<'a> {
55 pub fn uri(
56 uri: impl Into<CowStr<'a>>,
57 ) -> Result<RecordUri<'a, ListblockRecord>, UriError> {
58 RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
59 }
60}
61
62#[derive(Debug, Serialize, Deserialize)]
65pub struct ListblockRecord;
66impl XrpcResp for ListblockRecord {
67 const NSID: &'static str = "app.bsky.graph.listblock";
68 const ENCODING: &'static str = "application/json";
69 type Output<'de> = ListblockGetRecordOutput<'de>;
70 type Err<'de> = RecordError<'de>;
71}
72
73impl From<ListblockGetRecordOutput<'_>> for Listblock<'_> {
74 fn from(output: ListblockGetRecordOutput<'_>) -> Self {
75 use jacquard_common::IntoStatic;
76 output.value.into_static()
77 }
78}
79
80impl Collection for Listblock<'_> {
81 const NSID: &'static str = "app.bsky.graph.listblock";
82 type Record = ListblockRecord;
83}
84
85impl Collection for ListblockRecord {
86 const NSID: &'static str = "app.bsky.graph.listblock";
87 type Record = ListblockRecord;
88}
89
90impl<'a> LexiconSchema for Listblock<'a> {
91 fn nsid() -> &'static str {
92 "app.bsky.graph.listblock"
93 }
94 fn def_name() -> &'static str {
95 "main"
96 }
97 fn lexicon_doc() -> LexiconDoc<'static> {
98 lexicon_doc_app_bsky_graph_listblock()
99 }
100 fn validate(&self) -> Result<(), ConstraintError> {
101 Ok(())
102 }
103}
104
105pub mod listblock_state {
106
107 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
108 #[allow(unused)]
109 use ::core::marker::PhantomData;
110 mod sealed {
111 pub trait Sealed {}
112 }
113 pub trait State: sealed::Sealed {
115 type CreatedAt;
116 type Subject;
117 }
118 pub struct Empty(());
120 impl sealed::Sealed for Empty {}
121 impl State for Empty {
122 type CreatedAt = Unset;
123 type Subject = Unset;
124 }
125 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
127 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
128 impl<S: State> State for SetCreatedAt<S> {
129 type CreatedAt = Set<members::created_at>;
130 type Subject = S::Subject;
131 }
132 pub struct SetSubject<S: State = Empty>(PhantomData<fn() -> S>);
134 impl<S: State> sealed::Sealed for SetSubject<S> {}
135 impl<S: State> State for SetSubject<S> {
136 type CreatedAt = S::CreatedAt;
137 type Subject = Set<members::subject>;
138 }
139 #[allow(non_camel_case_types)]
141 pub mod members {
142 pub struct created_at(());
144 pub struct subject(());
146 }
147}
148
149pub struct ListblockBuilder<'a, S: listblock_state::State> {
151 _state: PhantomData<fn() -> S>,
152 _fields: (Option<Datetime>, Option<AtUri<'a>>),
153 _lifetime: PhantomData<&'a ()>,
154}
155
156impl<'a> Listblock<'a> {
157 pub fn new() -> ListblockBuilder<'a, listblock_state::Empty> {
159 ListblockBuilder::new()
160 }
161}
162
163impl<'a> ListblockBuilder<'a, listblock_state::Empty> {
164 pub fn new() -> Self {
166 ListblockBuilder {
167 _state: PhantomData,
168 _fields: (None, None),
169 _lifetime: PhantomData,
170 }
171 }
172}
173
174impl<'a, S> ListblockBuilder<'a, S>
175where
176 S: listblock_state::State,
177 S::CreatedAt: listblock_state::IsUnset,
178{
179 pub fn created_at(
181 mut self,
182 value: impl Into<Datetime>,
183 ) -> ListblockBuilder<'a, listblock_state::SetCreatedAt<S>> {
184 self._fields.0 = Option::Some(value.into());
185 ListblockBuilder {
186 _state: PhantomData,
187 _fields: self._fields,
188 _lifetime: PhantomData,
189 }
190 }
191}
192
193impl<'a, S> ListblockBuilder<'a, S>
194where
195 S: listblock_state::State,
196 S::Subject: listblock_state::IsUnset,
197{
198 pub fn subject(
200 mut self,
201 value: impl Into<AtUri<'a>>,
202 ) -> ListblockBuilder<'a, listblock_state::SetSubject<S>> {
203 self._fields.1 = Option::Some(value.into());
204 ListblockBuilder {
205 _state: PhantomData,
206 _fields: self._fields,
207 _lifetime: PhantomData,
208 }
209 }
210}
211
212impl<'a, S> ListblockBuilder<'a, S>
213where
214 S: listblock_state::State,
215 S::CreatedAt: listblock_state::IsSet,
216 S::Subject: listblock_state::IsSet,
217{
218 pub fn build(self) -> Listblock<'a> {
220 Listblock {
221 created_at: self._fields.0.unwrap(),
222 subject: self._fields.1.unwrap(),
223 extra_data: Default::default(),
224 }
225 }
226 pub fn build_with_data(
228 self,
229 extra_data: BTreeMap<
230 jacquard_common::deps::smol_str::SmolStr,
231 jacquard_common::types::value::Data<'a>,
232 >,
233 ) -> Listblock<'a> {
234 Listblock {
235 created_at: self._fields.0.unwrap(),
236 subject: self._fields.1.unwrap(),
237 extra_data: Some(extra_data),
238 }
239 }
240}
241
242fn lexicon_doc_app_bsky_graph_listblock() -> LexiconDoc<'static> {
243 #[allow(unused_imports)]
244 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
245 use jacquard_lexicon::lexicon::*;
246 use alloc::collections::BTreeMap;
247 LexiconDoc {
248 lexicon: Lexicon::Lexicon1,
249 id: CowStr::new_static("app.bsky.graph.listblock"),
250 defs: {
251 let mut map = BTreeMap::new();
252 map.insert(
253 SmolStr::new_static("main"),
254 LexUserType::Record(LexRecord {
255 description: Some(
256 CowStr::new_static(
257 "Record representing a block relationship against an entire an entire list of accounts (actors).",
258 ),
259 ),
260 key: Some(CowStr::new_static("tid")),
261 record: LexRecordRecord::Object(LexObject {
262 required: Some(
263 vec![
264 SmolStr::new_static("subject"),
265 SmolStr::new_static("createdAt")
266 ],
267 ),
268 properties: {
269 #[allow(unused_mut)]
270 let mut map = BTreeMap::new();
271 map.insert(
272 SmolStr::new_static("createdAt"),
273 LexObjectProperty::String(LexString {
274 format: Some(LexStringFormat::Datetime),
275 ..Default::default()
276 }),
277 );
278 map.insert(
279 SmolStr::new_static("subject"),
280 LexObjectProperty::String(LexString {
281 description: Some(
282 CowStr::new_static(
283 "Reference (AT-URI) to the mod list record.",
284 ),
285 ),
286 format: Some(LexStringFormat::AtUri),
287 ..Default::default()
288 }),
289 );
290 map
291 },
292 ..Default::default()
293 }),
294 ..Default::default()
295 }),
296 );
297 map
298 },
299 ..Default::default()
300 }
301}