atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.graph.list
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8/// Record representing a list of accounts (actors). Scope includes both moderation-oriented lists and curration-oriented lists.
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)]
19#[serde(rename_all = "camelCase")]
20pub struct List<'a> {
21 #[serde(skip_serializing_if = "std::option::Option::is_none")]
22 #[serde(borrow)]
23 pub avatar: std::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
24 pub created_at: jacquard_common::types::string::Datetime,
25 #[serde(skip_serializing_if = "std::option::Option::is_none")]
26 #[serde(borrow)]
27 pub description: std::option::Option<jacquard_common::CowStr<'a>>,
28 #[serde(skip_serializing_if = "std::option::Option::is_none")]
29 #[serde(borrow)]
30 pub description_facets: std::option::Option<
31 Vec<crate::app_bsky::richtext::facet::Facet<'a>>,
32 >,
33 #[serde(skip_serializing_if = "std::option::Option::is_none")]
34 #[serde(borrow)]
35 pub labels: std::option::Option<crate::com_atproto::label::SelfLabels<'a>>,
36 /// Display name for list; can not be empty.
37 #[serde(borrow)]
38 pub name: jacquard_common::CowStr<'a>,
39 /// Defines the purpose of the list (aka, moderation-oriented or curration-oriented)
40 #[serde(borrow)]
41 pub purpose: crate::app_bsky::graph::ListPurpose<'a>,
42}
43
44pub mod list_state {
45
46 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
47 #[allow(unused)]
48 use ::core::marker::PhantomData;
49 mod sealed {
50 pub trait Sealed {}
51 }
52 /// State trait tracking which required fields have been set
53 pub trait State: sealed::Sealed {
54 type CreatedAt;
55 type Name;
56 type Purpose;
57 }
58 /// Empty state - all required fields are unset
59 pub struct Empty(());
60 impl sealed::Sealed for Empty {}
61 impl State for Empty {
62 type CreatedAt = Unset;
63 type Name = Unset;
64 type Purpose = Unset;
65 }
66 ///State transition - sets the `created_at` field to Set
67 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
68 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
69 impl<S: State> State for SetCreatedAt<S> {
70 type CreatedAt = Set<members::created_at>;
71 type Name = S::Name;
72 type Purpose = S::Purpose;
73 }
74 ///State transition - sets the `name` field to Set
75 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
76 impl<S: State> sealed::Sealed for SetName<S> {}
77 impl<S: State> State for SetName<S> {
78 type CreatedAt = S::CreatedAt;
79 type Name = Set<members::name>;
80 type Purpose = S::Purpose;
81 }
82 ///State transition - sets the `purpose` field to Set
83 pub struct SetPurpose<S: State = Empty>(PhantomData<fn() -> S>);
84 impl<S: State> sealed::Sealed for SetPurpose<S> {}
85 impl<S: State> State for SetPurpose<S> {
86 type CreatedAt = S::CreatedAt;
87 type Name = S::Name;
88 type Purpose = Set<members::purpose>;
89 }
90 /// Marker types for field names
91 #[allow(non_camel_case_types)]
92 pub mod members {
93 ///Marker type for the `created_at` field
94 pub struct created_at(());
95 ///Marker type for the `name` field
96 pub struct name(());
97 ///Marker type for the `purpose` field
98 pub struct purpose(());
99 }
100}
101
102/// Builder for constructing an instance of this type
103pub struct ListBuilder<'a, S: list_state::State> {
104 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
105 __unsafe_private_named: (
106 ::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
107 ::core::option::Option<jacquard_common::types::string::Datetime>,
108 ::core::option::Option<jacquard_common::CowStr<'a>>,
109 ::core::option::Option<Vec<crate::app_bsky::richtext::facet::Facet<'a>>>,
110 ::core::option::Option<crate::com_atproto::label::SelfLabels<'a>>,
111 ::core::option::Option<jacquard_common::CowStr<'a>>,
112 ::core::option::Option<crate::app_bsky::graph::ListPurpose<'a>>,
113 ),
114 _phantom: ::core::marker::PhantomData<&'a ()>,
115}
116
117impl<'a> List<'a> {
118 /// Create a new builder for this type
119 pub fn new() -> ListBuilder<'a, list_state::Empty> {
120 ListBuilder::new()
121 }
122}
123
124impl<'a> ListBuilder<'a, list_state::Empty> {
125 /// Create a new builder with all fields unset
126 pub fn new() -> Self {
127 ListBuilder {
128 _phantom_state: ::core::marker::PhantomData,
129 __unsafe_private_named: (None, None, None, None, None, None, None),
130 _phantom: ::core::marker::PhantomData,
131 }
132 }
133}
134
135impl<'a, S: list_state::State> ListBuilder<'a, S> {
136 /// Set the `avatar` field (optional)
137 pub fn avatar(
138 mut self,
139 value: impl Into<Option<jacquard_common::types::blob::BlobRef<'a>>>,
140 ) -> Self {
141 self.__unsafe_private_named.0 = value.into();
142 self
143 }
144 /// Set the `avatar` field to an Option value (optional)
145 pub fn maybe_avatar(
146 mut self,
147 value: Option<jacquard_common::types::blob::BlobRef<'a>>,
148 ) -> Self {
149 self.__unsafe_private_named.0 = value;
150 self
151 }
152}
153
154impl<'a, S> ListBuilder<'a, S>
155where
156 S: list_state::State,
157 S::CreatedAt: list_state::IsUnset,
158{
159 /// Set the `createdAt` field (required)
160 pub fn created_at(
161 mut self,
162 value: impl Into<jacquard_common::types::string::Datetime>,
163 ) -> ListBuilder<'a, list_state::SetCreatedAt<S>> {
164 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
165 ListBuilder {
166 _phantom_state: ::core::marker::PhantomData,
167 __unsafe_private_named: self.__unsafe_private_named,
168 _phantom: ::core::marker::PhantomData,
169 }
170 }
171}
172
173impl<'a, S: list_state::State> ListBuilder<'a, S> {
174 /// Set the `description` field (optional)
175 pub fn description(
176 mut self,
177 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
178 ) -> Self {
179 self.__unsafe_private_named.2 = value.into();
180 self
181 }
182 /// Set the `description` field to an Option value (optional)
183 pub fn maybe_description(
184 mut self,
185 value: Option<jacquard_common::CowStr<'a>>,
186 ) -> Self {
187 self.__unsafe_private_named.2 = value;
188 self
189 }
190}
191
192impl<'a, S: list_state::State> ListBuilder<'a, S> {
193 /// Set the `descriptionFacets` field (optional)
194 pub fn description_facets(
195 mut self,
196 value: impl Into<Option<Vec<crate::app_bsky::richtext::facet::Facet<'a>>>>,
197 ) -> Self {
198 self.__unsafe_private_named.3 = value.into();
199 self
200 }
201 /// Set the `descriptionFacets` field to an Option value (optional)
202 pub fn maybe_description_facets(
203 mut self,
204 value: Option<Vec<crate::app_bsky::richtext::facet::Facet<'a>>>,
205 ) -> Self {
206 self.__unsafe_private_named.3 = value;
207 self
208 }
209}
210
211impl<'a, S: list_state::State> ListBuilder<'a, S> {
212 /// Set the `labels` field (optional)
213 pub fn labels(
214 mut self,
215 value: impl Into<Option<crate::com_atproto::label::SelfLabels<'a>>>,
216 ) -> Self {
217 self.__unsafe_private_named.4 = value.into();
218 self
219 }
220 /// Set the `labels` field to an Option value (optional)
221 pub fn maybe_labels(
222 mut self,
223 value: Option<crate::com_atproto::label::SelfLabels<'a>>,
224 ) -> Self {
225 self.__unsafe_private_named.4 = value;
226 self
227 }
228}
229
230impl<'a, S> ListBuilder<'a, S>
231where
232 S: list_state::State,
233 S::Name: list_state::IsUnset,
234{
235 /// Set the `name` field (required)
236 pub fn name(
237 mut self,
238 value: impl Into<jacquard_common::CowStr<'a>>,
239 ) -> ListBuilder<'a, list_state::SetName<S>> {
240 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
241 ListBuilder {
242 _phantom_state: ::core::marker::PhantomData,
243 __unsafe_private_named: self.__unsafe_private_named,
244 _phantom: ::core::marker::PhantomData,
245 }
246 }
247}
248
249impl<'a, S> ListBuilder<'a, S>
250where
251 S: list_state::State,
252 S::Purpose: list_state::IsUnset,
253{
254 /// Set the `purpose` field (required)
255 pub fn purpose(
256 mut self,
257 value: impl Into<crate::app_bsky::graph::ListPurpose<'a>>,
258 ) -> ListBuilder<'a, list_state::SetPurpose<S>> {
259 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
260 ListBuilder {
261 _phantom_state: ::core::marker::PhantomData,
262 __unsafe_private_named: self.__unsafe_private_named,
263 _phantom: ::core::marker::PhantomData,
264 }
265 }
266}
267
268impl<'a, S> ListBuilder<'a, S>
269where
270 S: list_state::State,
271 S::CreatedAt: list_state::IsSet,
272 S::Name: list_state::IsSet,
273 S::Purpose: list_state::IsSet,
274{
275 /// Build the final struct
276 pub fn build(self) -> List<'a> {
277 List {
278 avatar: self.__unsafe_private_named.0,
279 created_at: self.__unsafe_private_named.1.unwrap(),
280 description: self.__unsafe_private_named.2,
281 description_facets: self.__unsafe_private_named.3,
282 labels: self.__unsafe_private_named.4,
283 name: self.__unsafe_private_named.5.unwrap(),
284 purpose: self.__unsafe_private_named.6.unwrap(),
285 extra_data: Default::default(),
286 }
287 }
288 /// Build the final struct with custom extra_data
289 pub fn build_with_data(
290 self,
291 extra_data: std::collections::BTreeMap<
292 jacquard_common::smol_str::SmolStr,
293 jacquard_common::types::value::Data<'a>,
294 >,
295 ) -> List<'a> {
296 List {
297 avatar: self.__unsafe_private_named.0,
298 created_at: self.__unsafe_private_named.1.unwrap(),
299 description: self.__unsafe_private_named.2,
300 description_facets: self.__unsafe_private_named.3,
301 labels: self.__unsafe_private_named.4,
302 name: self.__unsafe_private_named.5.unwrap(),
303 purpose: self.__unsafe_private_named.6.unwrap(),
304 extra_data: Some(extra_data),
305 }
306 }
307}
308
309impl<'a> List<'a> {
310 pub fn uri(
311 uri: impl Into<jacquard_common::CowStr<'a>>,
312 ) -> Result<
313 jacquard_common::types::uri::RecordUri<'a, ListRecord>,
314 jacquard_common::types::uri::UriError,
315 > {
316 jacquard_common::types::uri::RecordUri::try_from_uri(
317 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
318 )
319 }
320}
321
322/// Typed wrapper for GetRecord response with this collection's record type.
323#[derive(
324 serde::Serialize,
325 serde::Deserialize,
326 Debug,
327 Clone,
328 PartialEq,
329 Eq,
330 jacquard_derive::IntoStatic
331)]
332#[serde(rename_all = "camelCase")]
333pub struct ListGetRecordOutput<'a> {
334 #[serde(skip_serializing_if = "std::option::Option::is_none")]
335 #[serde(borrow)]
336 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
337 #[serde(borrow)]
338 pub uri: jacquard_common::types::string::AtUri<'a>,
339 #[serde(borrow)]
340 pub value: List<'a>,
341}
342
343impl From<ListGetRecordOutput<'_>> for List<'_> {
344 fn from(output: ListGetRecordOutput<'_>) -> Self {
345 use jacquard_common::IntoStatic;
346 output.value.into_static()
347 }
348}
349
350impl jacquard_common::types::collection::Collection for List<'_> {
351 const NSID: &'static str = "app.bsky.graph.list";
352 type Record = ListRecord;
353}
354
355/// Marker type for deserializing records from this collection.
356#[derive(Debug, serde::Serialize, serde::Deserialize)]
357pub struct ListRecord;
358impl jacquard_common::xrpc::XrpcResp for ListRecord {
359 const NSID: &'static str = "app.bsky.graph.list";
360 const ENCODING: &'static str = "application/json";
361 type Output<'de> = ListGetRecordOutput<'de>;
362 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
363}
364
365impl jacquard_common::types::collection::Collection for ListRecord {
366 const NSID: &'static str = "app.bsky.graph.list";
367 type Record = ListRecord;
368}
369
370impl<'a> ::jacquard_lexicon::schema::LexiconSchema for List<'a> {
371 fn nsid() -> &'static str {
372 "app.bsky.graph.list"
373 }
374 fn def_name() -> &'static str {
375 "main"
376 }
377 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
378 lexicon_doc_app_bsky_graph_list()
379 }
380 fn validate(
381 &self,
382 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
383 if let Some(ref value) = self.description {
384 #[allow(unused_comparisons)]
385 if <str>::len(value.as_ref()) > 3000usize {
386 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
387 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
388 "description",
389 ),
390 max: 3000usize,
391 actual: <str>::len(value.as_ref()),
392 });
393 }
394 }
395 if let Some(ref value) = self.description {
396 {
397 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
398 value.as_ref(),
399 true,
400 )
401 .count();
402 if count > 300usize {
403 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
404 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
405 "description",
406 ),
407 max: 300usize,
408 actual: count,
409 });
410 }
411 }
412 }
413 {
414 let value = &self.name;
415 #[allow(unused_comparisons)]
416 if <str>::len(value.as_ref()) > 64usize {
417 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
418 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
419 "name",
420 ),
421 max: 64usize,
422 actual: <str>::len(value.as_ref()),
423 });
424 }
425 }
426 {
427 let value = &self.name;
428 #[allow(unused_comparisons)]
429 if <str>::len(value.as_ref()) < 1usize {
430 return Err(::jacquard_lexicon::validation::ConstraintError::MinLength {
431 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
432 "name",
433 ),
434 min: 1usize,
435 actual: <str>::len(value.as_ref()),
436 });
437 }
438 }
439 Ok(())
440 }
441}
442
443fn lexicon_doc_app_bsky_graph_list() -> ::jacquard_lexicon::lexicon::LexiconDoc<
444 'static,
445> {
446 ::jacquard_lexicon::lexicon::LexiconDoc {
447 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
448 id: ::jacquard_common::CowStr::new_static("app.bsky.graph.list"),
449 revision: None,
450 description: None,
451 defs: {
452 let mut map = ::alloc::collections::BTreeMap::new();
453 map.insert(
454 ::jacquard_common::smol_str::SmolStr::new_static("main"),
455 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
456 description: Some(
457 ::jacquard_common::CowStr::new_static(
458 "Record representing a list of accounts (actors). Scope includes both moderation-oriented lists and curration-oriented lists.",
459 ),
460 ),
461 key: Some(::jacquard_common::CowStr::new_static("tid")),
462 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
463 description: None,
464 required: Some(
465 vec![
466 ::jacquard_common::smol_str::SmolStr::new_static("name"),
467 ::jacquard_common::smol_str::SmolStr::new_static("purpose"),
468 ::jacquard_common::smol_str::SmolStr::new_static("createdAt")
469 ],
470 ),
471 nullable: None,
472 properties: {
473 #[allow(unused_mut)]
474 let mut map = ::alloc::collections::BTreeMap::new();
475 map.insert(
476 ::jacquard_common::smol_str::SmolStr::new_static("avatar"),
477 ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob {
478 description: None,
479 accept: None,
480 max_size: None,
481 }),
482 );
483 map.insert(
484 ::jacquard_common::smol_str::SmolStr::new_static(
485 "createdAt",
486 ),
487 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
488 description: None,
489 format: Some(
490 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
491 ),
492 default: None,
493 min_length: None,
494 max_length: None,
495 min_graphemes: None,
496 max_graphemes: None,
497 r#enum: None,
498 r#const: None,
499 known_values: None,
500 }),
501 );
502 map.insert(
503 ::jacquard_common::smol_str::SmolStr::new_static(
504 "description",
505 ),
506 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
507 description: None,
508 format: None,
509 default: None,
510 min_length: None,
511 max_length: Some(3000usize),
512 min_graphemes: None,
513 max_graphemes: Some(300usize),
514 r#enum: None,
515 r#const: None,
516 known_values: None,
517 }),
518 );
519 map.insert(
520 ::jacquard_common::smol_str::SmolStr::new_static(
521 "descriptionFacets",
522 ),
523 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
524 description: None,
525 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
526 description: None,
527 r#ref: ::jacquard_common::CowStr::new_static(
528 "app.bsky.richtext.facet",
529 ),
530 }),
531 min_length: None,
532 max_length: None,
533 }),
534 );
535 map.insert(
536 ::jacquard_common::smol_str::SmolStr::new_static("labels"),
537 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion {
538 description: None,
539 refs: vec![
540 ::jacquard_common::CowStr::new_static("com.atproto.label.defs#selfLabels")
541 ],
542 closed: None,
543 }),
544 );
545 map.insert(
546 ::jacquard_common::smol_str::SmolStr::new_static("name"),
547 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
548 description: Some(
549 ::jacquard_common::CowStr::new_static(
550 "Display name for list; can not be empty.",
551 ),
552 ),
553 format: None,
554 default: None,
555 min_length: Some(1usize),
556 max_length: Some(64usize),
557 min_graphemes: None,
558 max_graphemes: None,
559 r#enum: None,
560 r#const: None,
561 known_values: None,
562 }),
563 );
564 map.insert(
565 ::jacquard_common::smol_str::SmolStr::new_static("purpose"),
566 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
567 description: None,
568 r#ref: ::jacquard_common::CowStr::new_static(
569 "app.bsky.graph.defs#listPurpose",
570 ),
571 }),
572 );
573 map
574 },
575 }),
576 }),
577 );
578 map
579 },
580 }
581}