atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: com.atproto.label.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod query_labels;
9
10#[cfg(feature = "streaming")]
11pub mod subscribe_labels;
12
13/// Metadata tag on an atproto resource (eg, repo or record).
14#[jacquard_derive::lexicon]
15#[derive(
16 serde::Serialize,
17 serde::Deserialize,
18 Debug,
19 Clone,
20 PartialEq,
21 Eq,
22 jacquard_derive::IntoStatic
23)]
24#[serde(rename_all = "camelCase")]
25pub struct Label<'a> {
26 /// Optionally, CID specifying the specific version of 'uri' resource this label applies to.
27 #[serde(skip_serializing_if = "std::option::Option::is_none")]
28 #[serde(borrow)]
29 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
30 /// Timestamp when this label was created.
31 pub cts: jacquard_common::types::string::Datetime,
32 /// Timestamp at which this label expires (no longer applies).
33 #[serde(skip_serializing_if = "std::option::Option::is_none")]
34 pub exp: std::option::Option<jacquard_common::types::string::Datetime>,
35 /// If true, this is a negation label, overwriting a previous label.
36 #[serde(skip_serializing_if = "std::option::Option::is_none")]
37 pub neg: std::option::Option<bool>,
38 /// Signature of dag-cbor encoded label.
39 #[serde(skip_serializing_if = "std::option::Option::is_none")]
40 #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")]
41 pub sig: std::option::Option<bytes::Bytes>,
42 /// DID of the actor who created this label.
43 #[serde(borrow)]
44 pub src: jacquard_common::types::string::Did<'a>,
45 /// AT URI of the record, repository (account), or other resource that this label applies to.
46 #[serde(borrow)]
47 pub uri: jacquard_common::types::string::Uri<'a>,
48 /// The short string name of the value or type of this label.
49 #[serde(borrow)]
50 pub val: jacquard_common::CowStr<'a>,
51 /// The AT Protocol version of the label object.
52 #[serde(skip_serializing_if = "std::option::Option::is_none")]
53 pub ver: std::option::Option<i64>,
54}
55
56pub mod label_state {
57
58 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
59 #[allow(unused)]
60 use ::core::marker::PhantomData;
61 mod sealed {
62 pub trait Sealed {}
63 }
64 /// State trait tracking which required fields have been set
65 pub trait State: sealed::Sealed {
66 type Cts;
67 type Src;
68 type Uri;
69 type Val;
70 }
71 /// Empty state - all required fields are unset
72 pub struct Empty(());
73 impl sealed::Sealed for Empty {}
74 impl State for Empty {
75 type Cts = Unset;
76 type Src = Unset;
77 type Uri = Unset;
78 type Val = Unset;
79 }
80 ///State transition - sets the `cts` field to Set
81 pub struct SetCts<S: State = Empty>(PhantomData<fn() -> S>);
82 impl<S: State> sealed::Sealed for SetCts<S> {}
83 impl<S: State> State for SetCts<S> {
84 type Cts = Set<members::cts>;
85 type Src = S::Src;
86 type Uri = S::Uri;
87 type Val = S::Val;
88 }
89 ///State transition - sets the `src` field to Set
90 pub struct SetSrc<S: State = Empty>(PhantomData<fn() -> S>);
91 impl<S: State> sealed::Sealed for SetSrc<S> {}
92 impl<S: State> State for SetSrc<S> {
93 type Cts = S::Cts;
94 type Src = Set<members::src>;
95 type Uri = S::Uri;
96 type Val = S::Val;
97 }
98 ///State transition - sets the `uri` field to Set
99 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
100 impl<S: State> sealed::Sealed for SetUri<S> {}
101 impl<S: State> State for SetUri<S> {
102 type Cts = S::Cts;
103 type Src = S::Src;
104 type Uri = Set<members::uri>;
105 type Val = S::Val;
106 }
107 ///State transition - sets the `val` field to Set
108 pub struct SetVal<S: State = Empty>(PhantomData<fn() -> S>);
109 impl<S: State> sealed::Sealed for SetVal<S> {}
110 impl<S: State> State for SetVal<S> {
111 type Cts = S::Cts;
112 type Src = S::Src;
113 type Uri = S::Uri;
114 type Val = Set<members::val>;
115 }
116 /// Marker types for field names
117 #[allow(non_camel_case_types)]
118 pub mod members {
119 ///Marker type for the `cts` field
120 pub struct cts(());
121 ///Marker type for the `src` field
122 pub struct src(());
123 ///Marker type for the `uri` field
124 pub struct uri(());
125 ///Marker type for the `val` field
126 pub struct val(());
127 }
128}
129
130/// Builder for constructing an instance of this type
131pub struct LabelBuilder<'a, S: label_state::State> {
132 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
133 __unsafe_private_named: (
134 ::core::option::Option<jacquard_common::types::string::Cid<'a>>,
135 ::core::option::Option<jacquard_common::types::string::Datetime>,
136 ::core::option::Option<jacquard_common::types::string::Datetime>,
137 ::core::option::Option<bool>,
138 ::core::option::Option<bytes::Bytes>,
139 ::core::option::Option<jacquard_common::types::string::Did<'a>>,
140 ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
141 ::core::option::Option<jacquard_common::CowStr<'a>>,
142 ::core::option::Option<i64>,
143 ),
144 _phantom: ::core::marker::PhantomData<&'a ()>,
145}
146
147impl<'a> Label<'a> {
148 /// Create a new builder for this type
149 pub fn new() -> LabelBuilder<'a, label_state::Empty> {
150 LabelBuilder::new()
151 }
152}
153
154impl<'a> LabelBuilder<'a, label_state::Empty> {
155 /// Create a new builder with all fields unset
156 pub fn new() -> Self {
157 LabelBuilder {
158 _phantom_state: ::core::marker::PhantomData,
159 __unsafe_private_named: (
160 None,
161 None,
162 None,
163 None,
164 None,
165 None,
166 None,
167 None,
168 None,
169 ),
170 _phantom: ::core::marker::PhantomData,
171 }
172 }
173}
174
175impl<'a, S: label_state::State> LabelBuilder<'a, S> {
176 /// Set the `cid` field (optional)
177 pub fn cid(
178 mut self,
179 value: impl Into<Option<jacquard_common::types::string::Cid<'a>>>,
180 ) -> Self {
181 self.__unsafe_private_named.0 = value.into();
182 self
183 }
184 /// Set the `cid` field to an Option value (optional)
185 pub fn maybe_cid(
186 mut self,
187 value: Option<jacquard_common::types::string::Cid<'a>>,
188 ) -> Self {
189 self.__unsafe_private_named.0 = value;
190 self
191 }
192}
193
194impl<'a, S> LabelBuilder<'a, S>
195where
196 S: label_state::State,
197 S::Cts: label_state::IsUnset,
198{
199 /// Set the `cts` field (required)
200 pub fn cts(
201 mut self,
202 value: impl Into<jacquard_common::types::string::Datetime>,
203 ) -> LabelBuilder<'a, label_state::SetCts<S>> {
204 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
205 LabelBuilder {
206 _phantom_state: ::core::marker::PhantomData,
207 __unsafe_private_named: self.__unsafe_private_named,
208 _phantom: ::core::marker::PhantomData,
209 }
210 }
211}
212
213impl<'a, S: label_state::State> LabelBuilder<'a, S> {
214 /// Set the `exp` field (optional)
215 pub fn exp(
216 mut self,
217 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
218 ) -> Self {
219 self.__unsafe_private_named.2 = value.into();
220 self
221 }
222 /// Set the `exp` field to an Option value (optional)
223 pub fn maybe_exp(
224 mut self,
225 value: Option<jacquard_common::types::string::Datetime>,
226 ) -> Self {
227 self.__unsafe_private_named.2 = value;
228 self
229 }
230}
231
232impl<'a, S: label_state::State> LabelBuilder<'a, S> {
233 /// Set the `neg` field (optional)
234 pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self {
235 self.__unsafe_private_named.3 = value.into();
236 self
237 }
238 /// Set the `neg` field to an Option value (optional)
239 pub fn maybe_neg(mut self, value: Option<bool>) -> Self {
240 self.__unsafe_private_named.3 = value;
241 self
242 }
243}
244
245impl<'a, S: label_state::State> LabelBuilder<'a, S> {
246 /// Set the `sig` field (optional)
247 pub fn sig(mut self, value: impl Into<Option<bytes::Bytes>>) -> Self {
248 self.__unsafe_private_named.4 = value.into();
249 self
250 }
251 /// Set the `sig` field to an Option value (optional)
252 pub fn maybe_sig(mut self, value: Option<bytes::Bytes>) -> Self {
253 self.__unsafe_private_named.4 = value;
254 self
255 }
256}
257
258impl<'a, S> LabelBuilder<'a, S>
259where
260 S: label_state::State,
261 S::Src: label_state::IsUnset,
262{
263 /// Set the `src` field (required)
264 pub fn src(
265 mut self,
266 value: impl Into<jacquard_common::types::string::Did<'a>>,
267 ) -> LabelBuilder<'a, label_state::SetSrc<S>> {
268 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
269 LabelBuilder {
270 _phantom_state: ::core::marker::PhantomData,
271 __unsafe_private_named: self.__unsafe_private_named,
272 _phantom: ::core::marker::PhantomData,
273 }
274 }
275}
276
277impl<'a, S> LabelBuilder<'a, S>
278where
279 S: label_state::State,
280 S::Uri: label_state::IsUnset,
281{
282 /// Set the `uri` field (required)
283 pub fn uri(
284 mut self,
285 value: impl Into<jacquard_common::types::string::Uri<'a>>,
286 ) -> LabelBuilder<'a, label_state::SetUri<S>> {
287 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
288 LabelBuilder {
289 _phantom_state: ::core::marker::PhantomData,
290 __unsafe_private_named: self.__unsafe_private_named,
291 _phantom: ::core::marker::PhantomData,
292 }
293 }
294}
295
296impl<'a, S> LabelBuilder<'a, S>
297where
298 S: label_state::State,
299 S::Val: label_state::IsUnset,
300{
301 /// Set the `val` field (required)
302 pub fn val(
303 mut self,
304 value: impl Into<jacquard_common::CowStr<'a>>,
305 ) -> LabelBuilder<'a, label_state::SetVal<S>> {
306 self.__unsafe_private_named.7 = ::core::option::Option::Some(value.into());
307 LabelBuilder {
308 _phantom_state: ::core::marker::PhantomData,
309 __unsafe_private_named: self.__unsafe_private_named,
310 _phantom: ::core::marker::PhantomData,
311 }
312 }
313}
314
315impl<'a, S: label_state::State> LabelBuilder<'a, S> {
316 /// Set the `ver` field (optional)
317 pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self {
318 self.__unsafe_private_named.8 = value.into();
319 self
320 }
321 /// Set the `ver` field to an Option value (optional)
322 pub fn maybe_ver(mut self, value: Option<i64>) -> Self {
323 self.__unsafe_private_named.8 = value;
324 self
325 }
326}
327
328impl<'a, S> LabelBuilder<'a, S>
329where
330 S: label_state::State,
331 S::Cts: label_state::IsSet,
332 S::Src: label_state::IsSet,
333 S::Uri: label_state::IsSet,
334 S::Val: label_state::IsSet,
335{
336 /// Build the final struct
337 pub fn build(self) -> Label<'a> {
338 Label {
339 cid: self.__unsafe_private_named.0,
340 cts: self.__unsafe_private_named.1.unwrap(),
341 exp: self.__unsafe_private_named.2,
342 neg: self.__unsafe_private_named.3,
343 sig: self.__unsafe_private_named.4,
344 src: self.__unsafe_private_named.5.unwrap(),
345 uri: self.__unsafe_private_named.6.unwrap(),
346 val: self.__unsafe_private_named.7.unwrap(),
347 ver: self.__unsafe_private_named.8,
348 extra_data: Default::default(),
349 }
350 }
351 /// Build the final struct with custom extra_data
352 pub fn build_with_data(
353 self,
354 extra_data: std::collections::BTreeMap<
355 jacquard_common::smol_str::SmolStr,
356 jacquard_common::types::value::Data<'a>,
357 >,
358 ) -> Label<'a> {
359 Label {
360 cid: self.__unsafe_private_named.0,
361 cts: self.__unsafe_private_named.1.unwrap(),
362 exp: self.__unsafe_private_named.2,
363 neg: self.__unsafe_private_named.3,
364 sig: self.__unsafe_private_named.4,
365 src: self.__unsafe_private_named.5.unwrap(),
366 uri: self.__unsafe_private_named.6.unwrap(),
367 val: self.__unsafe_private_named.7.unwrap(),
368 ver: self.__unsafe_private_named.8,
369 extra_data: Some(extra_data),
370 }
371 }
372}
373
374fn lexicon_doc_com_atproto_label_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
375 'static,
376> {
377 ::jacquard_lexicon::lexicon::LexiconDoc {
378 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
379 id: ::jacquard_common::CowStr::new_static("com.atproto.label.defs"),
380 revision: None,
381 description: None,
382 defs: {
383 let mut map = ::alloc::collections::BTreeMap::new();
384 map.insert(
385 ::jacquard_common::smol_str::SmolStr::new_static("label"),
386 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
387 description: Some(
388 ::jacquard_common::CowStr::new_static(
389 "Metadata tag on an atproto resource (eg, repo or record).",
390 ),
391 ),
392 required: Some(
393 vec![
394 ::jacquard_common::smol_str::SmolStr::new_static("src"),
395 ::jacquard_common::smol_str::SmolStr::new_static("uri"),
396 ::jacquard_common::smol_str::SmolStr::new_static("val"),
397 ::jacquard_common::smol_str::SmolStr::new_static("cts")
398 ],
399 ),
400 nullable: None,
401 properties: {
402 #[allow(unused_mut)]
403 let mut map = ::alloc::collections::BTreeMap::new();
404 map.insert(
405 ::jacquard_common::smol_str::SmolStr::new_static("cid"),
406 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
407 description: Some(
408 ::jacquard_common::CowStr::new_static(
409 "Optionally, CID specifying the specific version of 'uri' resource this label applies to.",
410 ),
411 ),
412 format: Some(
413 ::jacquard_lexicon::lexicon::LexStringFormat::Cid,
414 ),
415 default: None,
416 min_length: None,
417 max_length: None,
418 min_graphemes: None,
419 max_graphemes: None,
420 r#enum: None,
421 r#const: None,
422 known_values: None,
423 }),
424 );
425 map.insert(
426 ::jacquard_common::smol_str::SmolStr::new_static("cts"),
427 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
428 description: Some(
429 ::jacquard_common::CowStr::new_static(
430 "Timestamp when this label was created.",
431 ),
432 ),
433 format: Some(
434 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
435 ),
436 default: None,
437 min_length: None,
438 max_length: None,
439 min_graphemes: None,
440 max_graphemes: None,
441 r#enum: None,
442 r#const: None,
443 known_values: None,
444 }),
445 );
446 map.insert(
447 ::jacquard_common::smol_str::SmolStr::new_static("exp"),
448 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
449 description: Some(
450 ::jacquard_common::CowStr::new_static(
451 "Timestamp at which this label expires (no longer applies).",
452 ),
453 ),
454 format: Some(
455 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
456 ),
457 default: None,
458 min_length: None,
459 max_length: None,
460 min_graphemes: None,
461 max_graphemes: None,
462 r#enum: None,
463 r#const: None,
464 known_values: None,
465 }),
466 );
467 map.insert(
468 ::jacquard_common::smol_str::SmolStr::new_static("neg"),
469 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
470 description: None,
471 default: None,
472 r#const: None,
473 }),
474 );
475 map.insert(
476 ::jacquard_common::smol_str::SmolStr::new_static("sig"),
477 ::jacquard_lexicon::lexicon::LexObjectProperty::Bytes(::jacquard_lexicon::lexicon::LexBytes {
478 description: None,
479 max_length: None,
480 min_length: None,
481 }),
482 );
483 map.insert(
484 ::jacquard_common::smol_str::SmolStr::new_static("src"),
485 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
486 description: Some(
487 ::jacquard_common::CowStr::new_static(
488 "DID of the actor who created this label.",
489 ),
490 ),
491 format: Some(
492 ::jacquard_lexicon::lexicon::LexStringFormat::Did,
493 ),
494 default: None,
495 min_length: None,
496 max_length: None,
497 min_graphemes: None,
498 max_graphemes: None,
499 r#enum: None,
500 r#const: None,
501 known_values: None,
502 }),
503 );
504 map.insert(
505 ::jacquard_common::smol_str::SmolStr::new_static("uri"),
506 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
507 description: Some(
508 ::jacquard_common::CowStr::new_static(
509 "AT URI of the record, repository (account), or other resource that this label applies to.",
510 ),
511 ),
512 format: Some(
513 ::jacquard_lexicon::lexicon::LexStringFormat::Uri,
514 ),
515 default: None,
516 min_length: None,
517 max_length: None,
518 min_graphemes: None,
519 max_graphemes: None,
520 r#enum: None,
521 r#const: None,
522 known_values: None,
523 }),
524 );
525 map.insert(
526 ::jacquard_common::smol_str::SmolStr::new_static("val"),
527 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
528 description: Some(
529 ::jacquard_common::CowStr::new_static(
530 "The short string name of the value or type of this label.",
531 ),
532 ),
533 format: None,
534 default: None,
535 min_length: None,
536 max_length: Some(128usize),
537 min_graphemes: None,
538 max_graphemes: None,
539 r#enum: None,
540 r#const: None,
541 known_values: None,
542 }),
543 );
544 map.insert(
545 ::jacquard_common::smol_str::SmolStr::new_static("ver"),
546 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
547 description: None,
548 default: None,
549 minimum: None,
550 maximum: None,
551 r#enum: None,
552 r#const: None,
553 }),
554 );
555 map
556 },
557 }),
558 );
559 map.insert(
560 ::jacquard_common::smol_str::SmolStr::new_static("labelValue"),
561 ::jacquard_lexicon::lexicon::LexUserType::String(::jacquard_lexicon::lexicon::LexString {
562 description: None,
563 format: None,
564 default: None,
565 min_length: None,
566 max_length: None,
567 min_graphemes: None,
568 max_graphemes: None,
569 r#enum: None,
570 r#const: None,
571 known_values: None,
572 }),
573 );
574 map.insert(
575 ::jacquard_common::smol_str::SmolStr::new_static("labelValueDefinition"),
576 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
577 description: Some(
578 ::jacquard_common::CowStr::new_static(
579 "Declares a label value and its expected interpretations and behaviors.",
580 ),
581 ),
582 required: Some(
583 vec![
584 ::jacquard_common::smol_str::SmolStr::new_static("identifier"),
585 ::jacquard_common::smol_str::SmolStr::new_static("severity"),
586 ::jacquard_common::smol_str::SmolStr::new_static("blurs"),
587 ::jacquard_common::smol_str::SmolStr::new_static("locales")
588 ],
589 ),
590 nullable: None,
591 properties: {
592 #[allow(unused_mut)]
593 let mut map = ::alloc::collections::BTreeMap::new();
594 map.insert(
595 ::jacquard_common::smol_str::SmolStr::new_static(
596 "adultOnly",
597 ),
598 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
599 description: None,
600 default: None,
601 r#const: None,
602 }),
603 );
604 map.insert(
605 ::jacquard_common::smol_str::SmolStr::new_static("blurs"),
606 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
607 description: Some(
608 ::jacquard_common::CowStr::new_static(
609 "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.",
610 ),
611 ),
612 format: None,
613 default: None,
614 min_length: None,
615 max_length: None,
616 min_graphemes: None,
617 max_graphemes: None,
618 r#enum: None,
619 r#const: None,
620 known_values: None,
621 }),
622 );
623 map.insert(
624 ::jacquard_common::smol_str::SmolStr::new_static(
625 "defaultSetting",
626 ),
627 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
628 description: Some(
629 ::jacquard_common::CowStr::new_static(
630 "The default setting for this label.",
631 ),
632 ),
633 format: None,
634 default: None,
635 min_length: None,
636 max_length: None,
637 min_graphemes: None,
638 max_graphemes: None,
639 r#enum: None,
640 r#const: None,
641 known_values: None,
642 }),
643 );
644 map.insert(
645 ::jacquard_common::smol_str::SmolStr::new_static(
646 "identifier",
647 ),
648 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
649 description: Some(
650 ::jacquard_common::CowStr::new_static(
651 "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).",
652 ),
653 ),
654 format: None,
655 default: None,
656 min_length: None,
657 max_length: Some(100usize),
658 min_graphemes: None,
659 max_graphemes: Some(100usize),
660 r#enum: None,
661 r#const: None,
662 known_values: None,
663 }),
664 );
665 map.insert(
666 ::jacquard_common::smol_str::SmolStr::new_static("locales"),
667 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
668 description: None,
669 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
670 description: None,
671 r#ref: ::jacquard_common::CowStr::new_static(
672 "#labelValueDefinitionStrings",
673 ),
674 }),
675 min_length: None,
676 max_length: None,
677 }),
678 );
679 map.insert(
680 ::jacquard_common::smol_str::SmolStr::new_static("severity"),
681 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
682 description: Some(
683 ::jacquard_common::CowStr::new_static(
684 "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.",
685 ),
686 ),
687 format: None,
688 default: None,
689 min_length: None,
690 max_length: None,
691 min_graphemes: None,
692 max_graphemes: None,
693 r#enum: None,
694 r#const: None,
695 known_values: None,
696 }),
697 );
698 map
699 },
700 }),
701 );
702 map.insert(
703 ::jacquard_common::smol_str::SmolStr::new_static(
704 "labelValueDefinitionStrings",
705 ),
706 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
707 description: Some(
708 ::jacquard_common::CowStr::new_static(
709 "Strings which describe the label in the UI, localized into a specific language.",
710 ),
711 ),
712 required: Some(
713 vec![
714 ::jacquard_common::smol_str::SmolStr::new_static("lang"),
715 ::jacquard_common::smol_str::SmolStr::new_static("name"),
716 ::jacquard_common::smol_str::SmolStr::new_static("description")
717 ],
718 ),
719 nullable: None,
720 properties: {
721 #[allow(unused_mut)]
722 let mut map = ::alloc::collections::BTreeMap::new();
723 map.insert(
724 ::jacquard_common::smol_str::SmolStr::new_static(
725 "description",
726 ),
727 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
728 description: Some(
729 ::jacquard_common::CowStr::new_static(
730 "A longer description of what the label means and why it might be applied.",
731 ),
732 ),
733 format: None,
734 default: None,
735 min_length: None,
736 max_length: Some(100000usize),
737 min_graphemes: None,
738 max_graphemes: Some(10000usize),
739 r#enum: None,
740 r#const: None,
741 known_values: None,
742 }),
743 );
744 map.insert(
745 ::jacquard_common::smol_str::SmolStr::new_static("lang"),
746 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
747 description: Some(
748 ::jacquard_common::CowStr::new_static(
749 "The code of the language these strings are written in.",
750 ),
751 ),
752 format: Some(
753 ::jacquard_lexicon::lexicon::LexStringFormat::Language,
754 ),
755 default: None,
756 min_length: None,
757 max_length: None,
758 min_graphemes: None,
759 max_graphemes: None,
760 r#enum: None,
761 r#const: None,
762 known_values: None,
763 }),
764 );
765 map.insert(
766 ::jacquard_common::smol_str::SmolStr::new_static("name"),
767 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
768 description: Some(
769 ::jacquard_common::CowStr::new_static(
770 "A short human-readable name for the label.",
771 ),
772 ),
773 format: None,
774 default: None,
775 min_length: None,
776 max_length: Some(640usize),
777 min_graphemes: None,
778 max_graphemes: Some(64usize),
779 r#enum: None,
780 r#const: None,
781 known_values: None,
782 }),
783 );
784 map
785 },
786 }),
787 );
788 map.insert(
789 ::jacquard_common::smol_str::SmolStr::new_static("selfLabel"),
790 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
791 description: Some(
792 ::jacquard_common::CowStr::new_static(
793 "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.",
794 ),
795 ),
796 required: Some(
797 vec![::jacquard_common::smol_str::SmolStr::new_static("val")],
798 ),
799 nullable: None,
800 properties: {
801 #[allow(unused_mut)]
802 let mut map = ::alloc::collections::BTreeMap::new();
803 map.insert(
804 ::jacquard_common::smol_str::SmolStr::new_static("val"),
805 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
806 description: Some(
807 ::jacquard_common::CowStr::new_static(
808 "The short string name of the value or type of this label.",
809 ),
810 ),
811 format: None,
812 default: None,
813 min_length: None,
814 max_length: Some(128usize),
815 min_graphemes: None,
816 max_graphemes: None,
817 r#enum: None,
818 r#const: None,
819 known_values: None,
820 }),
821 );
822 map
823 },
824 }),
825 );
826 map.insert(
827 ::jacquard_common::smol_str::SmolStr::new_static("selfLabels"),
828 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
829 description: Some(
830 ::jacquard_common::CowStr::new_static(
831 "Metadata tags on an atproto record, published by the author within the record.",
832 ),
833 ),
834 required: Some(
835 vec![::jacquard_common::smol_str::SmolStr::new_static("values")],
836 ),
837 nullable: None,
838 properties: {
839 #[allow(unused_mut)]
840 let mut map = ::alloc::collections::BTreeMap::new();
841 map.insert(
842 ::jacquard_common::smol_str::SmolStr::new_static("values"),
843 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
844 description: None,
845 items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef {
846 description: None,
847 r#ref: ::jacquard_common::CowStr::new_static("#selfLabel"),
848 }),
849 min_length: None,
850 max_length: Some(10usize),
851 }),
852 );
853 map
854 },
855 }),
856 );
857 map
858 },
859 }
860}
861
862impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Label<'a> {
863 fn nsid() -> &'static str {
864 "com.atproto.label.defs"
865 }
866 fn def_name() -> &'static str {
867 "label"
868 }
869 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
870 lexicon_doc_com_atproto_label_defs()
871 }
872 fn validate(
873 &self,
874 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
875 {
876 let value = &self.val;
877 #[allow(unused_comparisons)]
878 if <str>::len(value.as_ref()) > 128usize {
879 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
880 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
881 "val",
882 ),
883 max: 128usize,
884 actual: <str>::len(value.as_ref()),
885 });
886 }
887 }
888 Ok(())
889 }
890}
891
892#[derive(Debug, Clone, PartialEq, Eq, Hash)]
893pub enum LabelValue<'a> {
894 Hide,
895 NoPromote,
896 Warn,
897 NoUnauthenticated,
898 DmcaViolation,
899 Doxxing,
900 Porn,
901 Sexual,
902 Nudity,
903 Nsfl,
904 Gore,
905 Other(jacquard_common::CowStr<'a>),
906}
907
908impl<'a> LabelValue<'a> {
909 pub fn as_str(&self) -> &str {
910 match self {
911 Self::Hide => "!hide",
912 Self::NoPromote => "!no-promote",
913 Self::Warn => "!warn",
914 Self::NoUnauthenticated => "!no-unauthenticated",
915 Self::DmcaViolation => "dmca-violation",
916 Self::Doxxing => "doxxing",
917 Self::Porn => "porn",
918 Self::Sexual => "sexual",
919 Self::Nudity => "nudity",
920 Self::Nsfl => "nsfl",
921 Self::Gore => "gore",
922 Self::Other(s) => s.as_ref(),
923 }
924 }
925}
926
927impl<'a> From<&'a str> for LabelValue<'a> {
928 fn from(s: &'a str) -> Self {
929 match s {
930 "!hide" => Self::Hide,
931 "!no-promote" => Self::NoPromote,
932 "!warn" => Self::Warn,
933 "!no-unauthenticated" => Self::NoUnauthenticated,
934 "dmca-violation" => Self::DmcaViolation,
935 "doxxing" => Self::Doxxing,
936 "porn" => Self::Porn,
937 "sexual" => Self::Sexual,
938 "nudity" => Self::Nudity,
939 "nsfl" => Self::Nsfl,
940 "gore" => Self::Gore,
941 _ => Self::Other(jacquard_common::CowStr::from(s)),
942 }
943 }
944}
945
946impl<'a> From<String> for LabelValue<'a> {
947 fn from(s: String) -> Self {
948 match s.as_str() {
949 "!hide" => Self::Hide,
950 "!no-promote" => Self::NoPromote,
951 "!warn" => Self::Warn,
952 "!no-unauthenticated" => Self::NoUnauthenticated,
953 "dmca-violation" => Self::DmcaViolation,
954 "doxxing" => Self::Doxxing,
955 "porn" => Self::Porn,
956 "sexual" => Self::Sexual,
957 "nudity" => Self::Nudity,
958 "nsfl" => Self::Nsfl,
959 "gore" => Self::Gore,
960 _ => Self::Other(jacquard_common::CowStr::from(s)),
961 }
962 }
963}
964
965impl<'a> AsRef<str> for LabelValue<'a> {
966 fn as_ref(&self) -> &str {
967 self.as_str()
968 }
969}
970
971impl<'a> core::fmt::Display for LabelValue<'a> {
972 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
973 write!(f, "{}", self.as_str())
974 }
975}
976
977impl<'a> serde::Serialize for LabelValue<'a> {
978 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
979 where
980 S: serde::Serializer,
981 {
982 serializer.serialize_str(self.as_str())
983 }
984}
985
986impl<'de, 'a> serde::Deserialize<'de> for LabelValue<'a>
987where
988 'de: 'a,
989{
990 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
991 where
992 D: serde::Deserializer<'de>,
993 {
994 let s = <&'de str>::deserialize(deserializer)?;
995 Ok(Self::from(s))
996 }
997}
998
999impl jacquard_common::IntoStatic for LabelValue<'_> {
1000 type Output = LabelValue<'static>;
1001 fn into_static(self) -> Self::Output {
1002 match self {
1003 LabelValue::Hide => LabelValue::Hide,
1004 LabelValue::NoPromote => LabelValue::NoPromote,
1005 LabelValue::Warn => LabelValue::Warn,
1006 LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated,
1007 LabelValue::DmcaViolation => LabelValue::DmcaViolation,
1008 LabelValue::Doxxing => LabelValue::Doxxing,
1009 LabelValue::Porn => LabelValue::Porn,
1010 LabelValue::Sexual => LabelValue::Sexual,
1011 LabelValue::Nudity => LabelValue::Nudity,
1012 LabelValue::Nsfl => LabelValue::Nsfl,
1013 LabelValue::Gore => LabelValue::Gore,
1014 LabelValue::Other(v) => LabelValue::Other(v.into_static()),
1015 }
1016 }
1017}
1018
1019/// Declares a label value and its expected interpretations and behaviors.
1020#[jacquard_derive::lexicon]
1021#[derive(
1022 serde::Serialize,
1023 serde::Deserialize,
1024 Debug,
1025 Clone,
1026 PartialEq,
1027 Eq,
1028 jacquard_derive::IntoStatic
1029)]
1030#[serde(rename_all = "camelCase")]
1031pub struct LabelValueDefinition<'a> {
1032 /// Does the user need to have adult content enabled in order to configure this label?
1033 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1034 pub adult_only: std::option::Option<bool>,
1035 /// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
1036 #[serde(borrow)]
1037 pub blurs: LabelValueDefinitionBlurs<'a>,
1038 /// The default setting for this label.
1039 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1040 #[serde(borrow)]
1041 pub default_setting: std::option::Option<LabelValueDefinitionDefaultSetting<'a>>,
1042 /// The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).
1043 #[serde(borrow)]
1044 pub identifier: jacquard_common::CowStr<'a>,
1045 #[serde(borrow)]
1046 pub locales: Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>,
1047 /// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
1048 #[serde(borrow)]
1049 pub severity: LabelValueDefinitionSeverity<'a>,
1050}
1051
1052pub mod label_value_definition_state {
1053
1054 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1055 #[allow(unused)]
1056 use ::core::marker::PhantomData;
1057 mod sealed {
1058 pub trait Sealed {}
1059 }
1060 /// State trait tracking which required fields have been set
1061 pub trait State: sealed::Sealed {
1062 type Severity;
1063 type Identifier;
1064 type Locales;
1065 type Blurs;
1066 }
1067 /// Empty state - all required fields are unset
1068 pub struct Empty(());
1069 impl sealed::Sealed for Empty {}
1070 impl State for Empty {
1071 type Severity = Unset;
1072 type Identifier = Unset;
1073 type Locales = Unset;
1074 type Blurs = Unset;
1075 }
1076 ///State transition - sets the `severity` field to Set
1077 pub struct SetSeverity<S: State = Empty>(PhantomData<fn() -> S>);
1078 impl<S: State> sealed::Sealed for SetSeverity<S> {}
1079 impl<S: State> State for SetSeverity<S> {
1080 type Severity = Set<members::severity>;
1081 type Identifier = S::Identifier;
1082 type Locales = S::Locales;
1083 type Blurs = S::Blurs;
1084 }
1085 ///State transition - sets the `identifier` field to Set
1086 pub struct SetIdentifier<S: State = Empty>(PhantomData<fn() -> S>);
1087 impl<S: State> sealed::Sealed for SetIdentifier<S> {}
1088 impl<S: State> State for SetIdentifier<S> {
1089 type Severity = S::Severity;
1090 type Identifier = Set<members::identifier>;
1091 type Locales = S::Locales;
1092 type Blurs = S::Blurs;
1093 }
1094 ///State transition - sets the `locales` field to Set
1095 pub struct SetLocales<S: State = Empty>(PhantomData<fn() -> S>);
1096 impl<S: State> sealed::Sealed for SetLocales<S> {}
1097 impl<S: State> State for SetLocales<S> {
1098 type Severity = S::Severity;
1099 type Identifier = S::Identifier;
1100 type Locales = Set<members::locales>;
1101 type Blurs = S::Blurs;
1102 }
1103 ///State transition - sets the `blurs` field to Set
1104 pub struct SetBlurs<S: State = Empty>(PhantomData<fn() -> S>);
1105 impl<S: State> sealed::Sealed for SetBlurs<S> {}
1106 impl<S: State> State for SetBlurs<S> {
1107 type Severity = S::Severity;
1108 type Identifier = S::Identifier;
1109 type Locales = S::Locales;
1110 type Blurs = Set<members::blurs>;
1111 }
1112 /// Marker types for field names
1113 #[allow(non_camel_case_types)]
1114 pub mod members {
1115 ///Marker type for the `severity` field
1116 pub struct severity(());
1117 ///Marker type for the `identifier` field
1118 pub struct identifier(());
1119 ///Marker type for the `locales` field
1120 pub struct locales(());
1121 ///Marker type for the `blurs` field
1122 pub struct blurs(());
1123 }
1124}
1125
1126/// Builder for constructing an instance of this type
1127pub struct LabelValueDefinitionBuilder<'a, S: label_value_definition_state::State> {
1128 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
1129 __unsafe_private_named: (
1130 ::core::option::Option<bool>,
1131 ::core::option::Option<LabelValueDefinitionBlurs<'a>>,
1132 ::core::option::Option<LabelValueDefinitionDefaultSetting<'a>>,
1133 ::core::option::Option<jacquard_common::CowStr<'a>>,
1134 ::core::option::Option<
1135 Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>,
1136 >,
1137 ::core::option::Option<LabelValueDefinitionSeverity<'a>>,
1138 ),
1139 _phantom: ::core::marker::PhantomData<&'a ()>,
1140}
1141
1142impl<'a> LabelValueDefinition<'a> {
1143 /// Create a new builder for this type
1144 pub fn new() -> LabelValueDefinitionBuilder<
1145 'a,
1146 label_value_definition_state::Empty,
1147 > {
1148 LabelValueDefinitionBuilder::new()
1149 }
1150}
1151
1152impl<'a> LabelValueDefinitionBuilder<'a, label_value_definition_state::Empty> {
1153 /// Create a new builder with all fields unset
1154 pub fn new() -> Self {
1155 LabelValueDefinitionBuilder {
1156 _phantom_state: ::core::marker::PhantomData,
1157 __unsafe_private_named: (None, None, None, None, None, None),
1158 _phantom: ::core::marker::PhantomData,
1159 }
1160 }
1161}
1162
1163impl<'a, S: label_value_definition_state::State> LabelValueDefinitionBuilder<'a, S> {
1164 /// Set the `adultOnly` field (optional)
1165 pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self {
1166 self.__unsafe_private_named.0 = value.into();
1167 self
1168 }
1169 /// Set the `adultOnly` field to an Option value (optional)
1170 pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self {
1171 self.__unsafe_private_named.0 = value;
1172 self
1173 }
1174}
1175
1176impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1177where
1178 S: label_value_definition_state::State,
1179 S::Blurs: label_value_definition_state::IsUnset,
1180{
1181 /// Set the `blurs` field (required)
1182 pub fn blurs(
1183 mut self,
1184 value: impl Into<LabelValueDefinitionBlurs<'a>>,
1185 ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetBlurs<S>> {
1186 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
1187 LabelValueDefinitionBuilder {
1188 _phantom_state: ::core::marker::PhantomData,
1189 __unsafe_private_named: self.__unsafe_private_named,
1190 _phantom: ::core::marker::PhantomData,
1191 }
1192 }
1193}
1194
1195impl<'a, S: label_value_definition_state::State> LabelValueDefinitionBuilder<'a, S> {
1196 /// Set the `defaultSetting` field (optional)
1197 pub fn default_setting(
1198 mut self,
1199 value: impl Into<Option<LabelValueDefinitionDefaultSetting<'a>>>,
1200 ) -> Self {
1201 self.__unsafe_private_named.2 = value.into();
1202 self
1203 }
1204 /// Set the `defaultSetting` field to an Option value (optional)
1205 pub fn maybe_default_setting(
1206 mut self,
1207 value: Option<LabelValueDefinitionDefaultSetting<'a>>,
1208 ) -> Self {
1209 self.__unsafe_private_named.2 = value;
1210 self
1211 }
1212}
1213
1214impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1215where
1216 S: label_value_definition_state::State,
1217 S::Identifier: label_value_definition_state::IsUnset,
1218{
1219 /// Set the `identifier` field (required)
1220 pub fn identifier(
1221 mut self,
1222 value: impl Into<jacquard_common::CowStr<'a>>,
1223 ) -> LabelValueDefinitionBuilder<
1224 'a,
1225 label_value_definition_state::SetIdentifier<S>,
1226 > {
1227 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
1228 LabelValueDefinitionBuilder {
1229 _phantom_state: ::core::marker::PhantomData,
1230 __unsafe_private_named: self.__unsafe_private_named,
1231 _phantom: ::core::marker::PhantomData,
1232 }
1233 }
1234}
1235
1236impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1237where
1238 S: label_value_definition_state::State,
1239 S::Locales: label_value_definition_state::IsUnset,
1240{
1241 /// Set the `locales` field (required)
1242 pub fn locales(
1243 mut self,
1244 value: impl Into<Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>>,
1245 ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetLocales<S>> {
1246 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
1247 LabelValueDefinitionBuilder {
1248 _phantom_state: ::core::marker::PhantomData,
1249 __unsafe_private_named: self.__unsafe_private_named,
1250 _phantom: ::core::marker::PhantomData,
1251 }
1252 }
1253}
1254
1255impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1256where
1257 S: label_value_definition_state::State,
1258 S::Severity: label_value_definition_state::IsUnset,
1259{
1260 /// Set the `severity` field (required)
1261 pub fn severity(
1262 mut self,
1263 value: impl Into<LabelValueDefinitionSeverity<'a>>,
1264 ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetSeverity<S>> {
1265 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
1266 LabelValueDefinitionBuilder {
1267 _phantom_state: ::core::marker::PhantomData,
1268 __unsafe_private_named: self.__unsafe_private_named,
1269 _phantom: ::core::marker::PhantomData,
1270 }
1271 }
1272}
1273
1274impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1275where
1276 S: label_value_definition_state::State,
1277 S::Severity: label_value_definition_state::IsSet,
1278 S::Identifier: label_value_definition_state::IsSet,
1279 S::Locales: label_value_definition_state::IsSet,
1280 S::Blurs: label_value_definition_state::IsSet,
1281{
1282 /// Build the final struct
1283 pub fn build(self) -> LabelValueDefinition<'a> {
1284 LabelValueDefinition {
1285 adult_only: self.__unsafe_private_named.0,
1286 blurs: self.__unsafe_private_named.1.unwrap(),
1287 default_setting: self.__unsafe_private_named.2,
1288 identifier: self.__unsafe_private_named.3.unwrap(),
1289 locales: self.__unsafe_private_named.4.unwrap(),
1290 severity: self.__unsafe_private_named.5.unwrap(),
1291 extra_data: Default::default(),
1292 }
1293 }
1294 /// Build the final struct with custom extra_data
1295 pub fn build_with_data(
1296 self,
1297 extra_data: std::collections::BTreeMap<
1298 jacquard_common::smol_str::SmolStr,
1299 jacquard_common::types::value::Data<'a>,
1300 >,
1301 ) -> LabelValueDefinition<'a> {
1302 LabelValueDefinition {
1303 adult_only: self.__unsafe_private_named.0,
1304 blurs: self.__unsafe_private_named.1.unwrap(),
1305 default_setting: self.__unsafe_private_named.2,
1306 identifier: self.__unsafe_private_named.3.unwrap(),
1307 locales: self.__unsafe_private_named.4.unwrap(),
1308 severity: self.__unsafe_private_named.5.unwrap(),
1309 extra_data: Some(extra_data),
1310 }
1311 }
1312}
1313
1314/// What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.
1315#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1316pub enum LabelValueDefinitionBlurs<'a> {
1317 Content,
1318 Media,
1319 None,
1320 Other(jacquard_common::CowStr<'a>),
1321}
1322
1323impl<'a> LabelValueDefinitionBlurs<'a> {
1324 pub fn as_str(&self) -> &str {
1325 match self {
1326 Self::Content => "content",
1327 Self::Media => "media",
1328 Self::None => "none",
1329 Self::Other(s) => s.as_ref(),
1330 }
1331 }
1332}
1333
1334impl<'a> From<&'a str> for LabelValueDefinitionBlurs<'a> {
1335 fn from(s: &'a str) -> Self {
1336 match s {
1337 "content" => Self::Content,
1338 "media" => Self::Media,
1339 "none" => Self::None,
1340 _ => Self::Other(jacquard_common::CowStr::from(s)),
1341 }
1342 }
1343}
1344
1345impl<'a> From<String> for LabelValueDefinitionBlurs<'a> {
1346 fn from(s: String) -> Self {
1347 match s.as_str() {
1348 "content" => Self::Content,
1349 "media" => Self::Media,
1350 "none" => Self::None,
1351 _ => Self::Other(jacquard_common::CowStr::from(s)),
1352 }
1353 }
1354}
1355
1356impl<'a> core::fmt::Display for LabelValueDefinitionBlurs<'a> {
1357 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1358 write!(f, "{}", self.as_str())
1359 }
1360}
1361
1362impl<'a> AsRef<str> for LabelValueDefinitionBlurs<'a> {
1363 fn as_ref(&self) -> &str {
1364 self.as_str()
1365 }
1366}
1367
1368impl<'a> serde::Serialize for LabelValueDefinitionBlurs<'a> {
1369 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1370 where
1371 S: serde::Serializer,
1372 {
1373 serializer.serialize_str(self.as_str())
1374 }
1375}
1376
1377impl<'de, 'a> serde::Deserialize<'de> for LabelValueDefinitionBlurs<'a>
1378where
1379 'de: 'a,
1380{
1381 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1382 where
1383 D: serde::Deserializer<'de>,
1384 {
1385 let s = <&'de str>::deserialize(deserializer)?;
1386 Ok(Self::from(s))
1387 }
1388}
1389
1390impl<'a> Default for LabelValueDefinitionBlurs<'a> {
1391 fn default() -> Self {
1392 Self::Other(Default::default())
1393 }
1394}
1395
1396impl jacquard_common::IntoStatic for LabelValueDefinitionBlurs<'_> {
1397 type Output = LabelValueDefinitionBlurs<'static>;
1398 fn into_static(self) -> Self::Output {
1399 match self {
1400 LabelValueDefinitionBlurs::Content => LabelValueDefinitionBlurs::Content,
1401 LabelValueDefinitionBlurs::Media => LabelValueDefinitionBlurs::Media,
1402 LabelValueDefinitionBlurs::None => LabelValueDefinitionBlurs::None,
1403 LabelValueDefinitionBlurs::Other(v) => {
1404 LabelValueDefinitionBlurs::Other(v.into_static())
1405 }
1406 }
1407 }
1408}
1409
1410/// The default setting for this label.
1411#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1412pub enum LabelValueDefinitionDefaultSetting<'a> {
1413 Ignore,
1414 Warn,
1415 Hide,
1416 Other(jacquard_common::CowStr<'a>),
1417}
1418
1419impl<'a> LabelValueDefinitionDefaultSetting<'a> {
1420 pub fn as_str(&self) -> &str {
1421 match self {
1422 Self::Ignore => "ignore",
1423 Self::Warn => "warn",
1424 Self::Hide => "hide",
1425 Self::Other(s) => s.as_ref(),
1426 }
1427 }
1428}
1429
1430impl<'a> From<&'a str> for LabelValueDefinitionDefaultSetting<'a> {
1431 fn from(s: &'a str) -> Self {
1432 match s {
1433 "ignore" => Self::Ignore,
1434 "warn" => Self::Warn,
1435 "hide" => Self::Hide,
1436 _ => Self::Other(jacquard_common::CowStr::from(s)),
1437 }
1438 }
1439}
1440
1441impl<'a> From<String> for LabelValueDefinitionDefaultSetting<'a> {
1442 fn from(s: String) -> Self {
1443 match s.as_str() {
1444 "ignore" => Self::Ignore,
1445 "warn" => Self::Warn,
1446 "hide" => Self::Hide,
1447 _ => Self::Other(jacquard_common::CowStr::from(s)),
1448 }
1449 }
1450}
1451
1452impl<'a> core::fmt::Display for LabelValueDefinitionDefaultSetting<'a> {
1453 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1454 write!(f, "{}", self.as_str())
1455 }
1456}
1457
1458impl<'a> AsRef<str> for LabelValueDefinitionDefaultSetting<'a> {
1459 fn as_ref(&self) -> &str {
1460 self.as_str()
1461 }
1462}
1463
1464impl<'a> serde::Serialize for LabelValueDefinitionDefaultSetting<'a> {
1465 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1466 where
1467 S: serde::Serializer,
1468 {
1469 serializer.serialize_str(self.as_str())
1470 }
1471}
1472
1473impl<'de, 'a> serde::Deserialize<'de> for LabelValueDefinitionDefaultSetting<'a>
1474where
1475 'de: 'a,
1476{
1477 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1478 where
1479 D: serde::Deserializer<'de>,
1480 {
1481 let s = <&'de str>::deserialize(deserializer)?;
1482 Ok(Self::from(s))
1483 }
1484}
1485
1486impl<'a> Default for LabelValueDefinitionDefaultSetting<'a> {
1487 fn default() -> Self {
1488 Self::Other(Default::default())
1489 }
1490}
1491
1492impl jacquard_common::IntoStatic for LabelValueDefinitionDefaultSetting<'_> {
1493 type Output = LabelValueDefinitionDefaultSetting<'static>;
1494 fn into_static(self) -> Self::Output {
1495 match self {
1496 LabelValueDefinitionDefaultSetting::Ignore => {
1497 LabelValueDefinitionDefaultSetting::Ignore
1498 }
1499 LabelValueDefinitionDefaultSetting::Warn => {
1500 LabelValueDefinitionDefaultSetting::Warn
1501 }
1502 LabelValueDefinitionDefaultSetting::Hide => {
1503 LabelValueDefinitionDefaultSetting::Hide
1504 }
1505 LabelValueDefinitionDefaultSetting::Other(v) => {
1506 LabelValueDefinitionDefaultSetting::Other(v.into_static())
1507 }
1508 }
1509 }
1510}
1511
1512/// How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.
1513#[derive(Debug, Clone, PartialEq, Eq, Hash)]
1514pub enum LabelValueDefinitionSeverity<'a> {
1515 Inform,
1516 Alert,
1517 None,
1518 Other(jacquard_common::CowStr<'a>),
1519}
1520
1521impl<'a> LabelValueDefinitionSeverity<'a> {
1522 pub fn as_str(&self) -> &str {
1523 match self {
1524 Self::Inform => "inform",
1525 Self::Alert => "alert",
1526 Self::None => "none",
1527 Self::Other(s) => s.as_ref(),
1528 }
1529 }
1530}
1531
1532impl<'a> From<&'a str> for LabelValueDefinitionSeverity<'a> {
1533 fn from(s: &'a str) -> Self {
1534 match s {
1535 "inform" => Self::Inform,
1536 "alert" => Self::Alert,
1537 "none" => Self::None,
1538 _ => Self::Other(jacquard_common::CowStr::from(s)),
1539 }
1540 }
1541}
1542
1543impl<'a> From<String> for LabelValueDefinitionSeverity<'a> {
1544 fn from(s: String) -> Self {
1545 match s.as_str() {
1546 "inform" => Self::Inform,
1547 "alert" => Self::Alert,
1548 "none" => Self::None,
1549 _ => Self::Other(jacquard_common::CowStr::from(s)),
1550 }
1551 }
1552}
1553
1554impl<'a> core::fmt::Display for LabelValueDefinitionSeverity<'a> {
1555 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
1556 write!(f, "{}", self.as_str())
1557 }
1558}
1559
1560impl<'a> AsRef<str> for LabelValueDefinitionSeverity<'a> {
1561 fn as_ref(&self) -> &str {
1562 self.as_str()
1563 }
1564}
1565
1566impl<'a> serde::Serialize for LabelValueDefinitionSeverity<'a> {
1567 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1568 where
1569 S: serde::Serializer,
1570 {
1571 serializer.serialize_str(self.as_str())
1572 }
1573}
1574
1575impl<'de, 'a> serde::Deserialize<'de> for LabelValueDefinitionSeverity<'a>
1576where
1577 'de: 'a,
1578{
1579 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
1580 where
1581 D: serde::Deserializer<'de>,
1582 {
1583 let s = <&'de str>::deserialize(deserializer)?;
1584 Ok(Self::from(s))
1585 }
1586}
1587
1588impl<'a> Default for LabelValueDefinitionSeverity<'a> {
1589 fn default() -> Self {
1590 Self::Other(Default::default())
1591 }
1592}
1593
1594impl jacquard_common::IntoStatic for LabelValueDefinitionSeverity<'_> {
1595 type Output = LabelValueDefinitionSeverity<'static>;
1596 fn into_static(self) -> Self::Output {
1597 match self {
1598 LabelValueDefinitionSeverity::Inform => LabelValueDefinitionSeverity::Inform,
1599 LabelValueDefinitionSeverity::Alert => LabelValueDefinitionSeverity::Alert,
1600 LabelValueDefinitionSeverity::None => LabelValueDefinitionSeverity::None,
1601 LabelValueDefinitionSeverity::Other(v) => {
1602 LabelValueDefinitionSeverity::Other(v.into_static())
1603 }
1604 }
1605 }
1606}
1607
1608impl<'a> ::jacquard_lexicon::schema::LexiconSchema for LabelValueDefinition<'a> {
1609 fn nsid() -> &'static str {
1610 "com.atproto.label.defs"
1611 }
1612 fn def_name() -> &'static str {
1613 "labelValueDefinition"
1614 }
1615 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1616 lexicon_doc_com_atproto_label_defs()
1617 }
1618 fn validate(
1619 &self,
1620 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1621 {
1622 let value = &self.identifier;
1623 #[allow(unused_comparisons)]
1624 if <str>::len(value.as_ref()) > 100usize {
1625 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1626 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1627 "identifier",
1628 ),
1629 max: 100usize,
1630 actual: <str>::len(value.as_ref()),
1631 });
1632 }
1633 }
1634 {
1635 let value = &self.identifier;
1636 {
1637 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
1638 value.as_ref(),
1639 true,
1640 )
1641 .count();
1642 if count > 100usize {
1643 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
1644 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1645 "identifier",
1646 ),
1647 max: 100usize,
1648 actual: count,
1649 });
1650 }
1651 }
1652 }
1653 Ok(())
1654 }
1655}
1656
1657/// Strings which describe the label in the UI, localized into a specific language.
1658#[jacquard_derive::lexicon]
1659#[derive(
1660 serde::Serialize,
1661 serde::Deserialize,
1662 Debug,
1663 Clone,
1664 PartialEq,
1665 Eq,
1666 jacquard_derive::IntoStatic
1667)]
1668#[serde(rename_all = "camelCase")]
1669pub struct LabelValueDefinitionStrings<'a> {
1670 /// A longer description of what the label means and why it might be applied.
1671 #[serde(borrow)]
1672 pub description: jacquard_common::CowStr<'a>,
1673 /// The code of the language these strings are written in.
1674 pub lang: jacquard_common::types::string::Language,
1675 /// A short human-readable name for the label.
1676 #[serde(borrow)]
1677 pub name: jacquard_common::CowStr<'a>,
1678}
1679
1680pub mod label_value_definition_strings_state {
1681
1682 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1683 #[allow(unused)]
1684 use ::core::marker::PhantomData;
1685 mod sealed {
1686 pub trait Sealed {}
1687 }
1688 /// State trait tracking which required fields have been set
1689 pub trait State: sealed::Sealed {
1690 type Lang;
1691 type Description;
1692 type Name;
1693 }
1694 /// Empty state - all required fields are unset
1695 pub struct Empty(());
1696 impl sealed::Sealed for Empty {}
1697 impl State for Empty {
1698 type Lang = Unset;
1699 type Description = Unset;
1700 type Name = Unset;
1701 }
1702 ///State transition - sets the `lang` field to Set
1703 pub struct SetLang<S: State = Empty>(PhantomData<fn() -> S>);
1704 impl<S: State> sealed::Sealed for SetLang<S> {}
1705 impl<S: State> State for SetLang<S> {
1706 type Lang = Set<members::lang>;
1707 type Description = S::Description;
1708 type Name = S::Name;
1709 }
1710 ///State transition - sets the `description` field to Set
1711 pub struct SetDescription<S: State = Empty>(PhantomData<fn() -> S>);
1712 impl<S: State> sealed::Sealed for SetDescription<S> {}
1713 impl<S: State> State for SetDescription<S> {
1714 type Lang = S::Lang;
1715 type Description = Set<members::description>;
1716 type Name = S::Name;
1717 }
1718 ///State transition - sets the `name` field to Set
1719 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
1720 impl<S: State> sealed::Sealed for SetName<S> {}
1721 impl<S: State> State for SetName<S> {
1722 type Lang = S::Lang;
1723 type Description = S::Description;
1724 type Name = Set<members::name>;
1725 }
1726 /// Marker types for field names
1727 #[allow(non_camel_case_types)]
1728 pub mod members {
1729 ///Marker type for the `lang` field
1730 pub struct lang(());
1731 ///Marker type for the `description` field
1732 pub struct description(());
1733 ///Marker type for the `name` field
1734 pub struct name(());
1735 }
1736}
1737
1738/// Builder for constructing an instance of this type
1739pub struct LabelValueDefinitionStringsBuilder<
1740 'a,
1741 S: label_value_definition_strings_state::State,
1742> {
1743 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
1744 __unsafe_private_named: (
1745 ::core::option::Option<jacquard_common::CowStr<'a>>,
1746 ::core::option::Option<jacquard_common::types::string::Language>,
1747 ::core::option::Option<jacquard_common::CowStr<'a>>,
1748 ),
1749 _phantom: ::core::marker::PhantomData<&'a ()>,
1750}
1751
1752impl<'a> LabelValueDefinitionStrings<'a> {
1753 /// Create a new builder for this type
1754 pub fn new() -> LabelValueDefinitionStringsBuilder<
1755 'a,
1756 label_value_definition_strings_state::Empty,
1757 > {
1758 LabelValueDefinitionStringsBuilder::new()
1759 }
1760}
1761
1762impl<
1763 'a,
1764> LabelValueDefinitionStringsBuilder<'a, label_value_definition_strings_state::Empty> {
1765 /// Create a new builder with all fields unset
1766 pub fn new() -> Self {
1767 LabelValueDefinitionStringsBuilder {
1768 _phantom_state: ::core::marker::PhantomData,
1769 __unsafe_private_named: (None, None, None),
1770 _phantom: ::core::marker::PhantomData,
1771 }
1772 }
1773}
1774
1775impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1776where
1777 S: label_value_definition_strings_state::State,
1778 S::Description: label_value_definition_strings_state::IsUnset,
1779{
1780 /// Set the `description` field (required)
1781 pub fn description(
1782 mut self,
1783 value: impl Into<jacquard_common::CowStr<'a>>,
1784 ) -> LabelValueDefinitionStringsBuilder<
1785 'a,
1786 label_value_definition_strings_state::SetDescription<S>,
1787 > {
1788 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
1789 LabelValueDefinitionStringsBuilder {
1790 _phantom_state: ::core::marker::PhantomData,
1791 __unsafe_private_named: self.__unsafe_private_named,
1792 _phantom: ::core::marker::PhantomData,
1793 }
1794 }
1795}
1796
1797impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1798where
1799 S: label_value_definition_strings_state::State,
1800 S::Lang: label_value_definition_strings_state::IsUnset,
1801{
1802 /// Set the `lang` field (required)
1803 pub fn lang(
1804 mut self,
1805 value: impl Into<jacquard_common::types::string::Language>,
1806 ) -> LabelValueDefinitionStringsBuilder<
1807 'a,
1808 label_value_definition_strings_state::SetLang<S>,
1809 > {
1810 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
1811 LabelValueDefinitionStringsBuilder {
1812 _phantom_state: ::core::marker::PhantomData,
1813 __unsafe_private_named: self.__unsafe_private_named,
1814 _phantom: ::core::marker::PhantomData,
1815 }
1816 }
1817}
1818
1819impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1820where
1821 S: label_value_definition_strings_state::State,
1822 S::Name: label_value_definition_strings_state::IsUnset,
1823{
1824 /// Set the `name` field (required)
1825 pub fn name(
1826 mut self,
1827 value: impl Into<jacquard_common::CowStr<'a>>,
1828 ) -> LabelValueDefinitionStringsBuilder<
1829 'a,
1830 label_value_definition_strings_state::SetName<S>,
1831 > {
1832 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
1833 LabelValueDefinitionStringsBuilder {
1834 _phantom_state: ::core::marker::PhantomData,
1835 __unsafe_private_named: self.__unsafe_private_named,
1836 _phantom: ::core::marker::PhantomData,
1837 }
1838 }
1839}
1840
1841impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1842where
1843 S: label_value_definition_strings_state::State,
1844 S::Lang: label_value_definition_strings_state::IsSet,
1845 S::Description: label_value_definition_strings_state::IsSet,
1846 S::Name: label_value_definition_strings_state::IsSet,
1847{
1848 /// Build the final struct
1849 pub fn build(self) -> LabelValueDefinitionStrings<'a> {
1850 LabelValueDefinitionStrings {
1851 description: self.__unsafe_private_named.0.unwrap(),
1852 lang: self.__unsafe_private_named.1.unwrap(),
1853 name: self.__unsafe_private_named.2.unwrap(),
1854 extra_data: Default::default(),
1855 }
1856 }
1857 /// Build the final struct with custom extra_data
1858 pub fn build_with_data(
1859 self,
1860 extra_data: std::collections::BTreeMap<
1861 jacquard_common::smol_str::SmolStr,
1862 jacquard_common::types::value::Data<'a>,
1863 >,
1864 ) -> LabelValueDefinitionStrings<'a> {
1865 LabelValueDefinitionStrings {
1866 description: self.__unsafe_private_named.0.unwrap(),
1867 lang: self.__unsafe_private_named.1.unwrap(),
1868 name: self.__unsafe_private_named.2.unwrap(),
1869 extra_data: Some(extra_data),
1870 }
1871 }
1872}
1873
1874impl<'a> ::jacquard_lexicon::schema::LexiconSchema for LabelValueDefinitionStrings<'a> {
1875 fn nsid() -> &'static str {
1876 "com.atproto.label.defs"
1877 }
1878 fn def_name() -> &'static str {
1879 "labelValueDefinitionStrings"
1880 }
1881 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1882 lexicon_doc_com_atproto_label_defs()
1883 }
1884 fn validate(
1885 &self,
1886 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1887 {
1888 let value = &self.description;
1889 #[allow(unused_comparisons)]
1890 if <str>::len(value.as_ref()) > 100000usize {
1891 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1892 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1893 "description",
1894 ),
1895 max: 100000usize,
1896 actual: <str>::len(value.as_ref()),
1897 });
1898 }
1899 }
1900 {
1901 let value = &self.description;
1902 {
1903 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
1904 value.as_ref(),
1905 true,
1906 )
1907 .count();
1908 if count > 10000usize {
1909 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
1910 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1911 "description",
1912 ),
1913 max: 10000usize,
1914 actual: count,
1915 });
1916 }
1917 }
1918 }
1919 {
1920 let value = &self.name;
1921 #[allow(unused_comparisons)]
1922 if <str>::len(value.as_ref()) > 640usize {
1923 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1924 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1925 "name",
1926 ),
1927 max: 640usize,
1928 actual: <str>::len(value.as_ref()),
1929 });
1930 }
1931 }
1932 {
1933 let value = &self.name;
1934 {
1935 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
1936 value.as_ref(),
1937 true,
1938 )
1939 .count();
1940 if count > 64usize {
1941 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
1942 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1943 "name",
1944 ),
1945 max: 64usize,
1946 actual: count,
1947 });
1948 }
1949 }
1950 }
1951 Ok(())
1952 }
1953}
1954
1955/// Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.
1956#[jacquard_derive::lexicon]
1957#[derive(
1958 serde::Serialize,
1959 serde::Deserialize,
1960 Debug,
1961 Clone,
1962 PartialEq,
1963 Eq,
1964 jacquard_derive::IntoStatic,
1965 Default
1966)]
1967#[serde(rename_all = "camelCase")]
1968pub struct SelfLabel<'a> {
1969 /// The short string name of the value or type of this label.
1970 #[serde(borrow)]
1971 pub val: jacquard_common::CowStr<'a>,
1972}
1973
1974impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SelfLabel<'a> {
1975 fn nsid() -> &'static str {
1976 "com.atproto.label.defs"
1977 }
1978 fn def_name() -> &'static str {
1979 "selfLabel"
1980 }
1981 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1982 lexicon_doc_com_atproto_label_defs()
1983 }
1984 fn validate(
1985 &self,
1986 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1987 {
1988 let value = &self.val;
1989 #[allow(unused_comparisons)]
1990 if <str>::len(value.as_ref()) > 128usize {
1991 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1992 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1993 "val",
1994 ),
1995 max: 128usize,
1996 actual: <str>::len(value.as_ref()),
1997 });
1998 }
1999 }
2000 Ok(())
2001 }
2002}
2003
2004/// Metadata tags on an atproto record, published by the author within the record.
2005#[jacquard_derive::lexicon]
2006#[derive(
2007 serde::Serialize,
2008 serde::Deserialize,
2009 Debug,
2010 Clone,
2011 PartialEq,
2012 Eq,
2013 jacquard_derive::IntoStatic
2014)]
2015#[serde(rename_all = "camelCase")]
2016pub struct SelfLabels<'a> {
2017 #[serde(borrow)]
2018 pub values: Vec<crate::com_atproto::label::SelfLabel<'a>>,
2019}
2020
2021pub mod self_labels_state {
2022
2023 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
2024 #[allow(unused)]
2025 use ::core::marker::PhantomData;
2026 mod sealed {
2027 pub trait Sealed {}
2028 }
2029 /// State trait tracking which required fields have been set
2030 pub trait State: sealed::Sealed {
2031 type Values;
2032 }
2033 /// Empty state - all required fields are unset
2034 pub struct Empty(());
2035 impl sealed::Sealed for Empty {}
2036 impl State for Empty {
2037 type Values = Unset;
2038 }
2039 ///State transition - sets the `values` field to Set
2040 pub struct SetValues<S: State = Empty>(PhantomData<fn() -> S>);
2041 impl<S: State> sealed::Sealed for SetValues<S> {}
2042 impl<S: State> State for SetValues<S> {
2043 type Values = Set<members::values>;
2044 }
2045 /// Marker types for field names
2046 #[allow(non_camel_case_types)]
2047 pub mod members {
2048 ///Marker type for the `values` field
2049 pub struct values(());
2050 }
2051}
2052
2053/// Builder for constructing an instance of this type
2054pub struct SelfLabelsBuilder<'a, S: self_labels_state::State> {
2055 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
2056 __unsafe_private_named: (
2057 ::core::option::Option<Vec<crate::com_atproto::label::SelfLabel<'a>>>,
2058 ),
2059 _phantom: ::core::marker::PhantomData<&'a ()>,
2060}
2061
2062impl<'a> SelfLabels<'a> {
2063 /// Create a new builder for this type
2064 pub fn new() -> SelfLabelsBuilder<'a, self_labels_state::Empty> {
2065 SelfLabelsBuilder::new()
2066 }
2067}
2068
2069impl<'a> SelfLabelsBuilder<'a, self_labels_state::Empty> {
2070 /// Create a new builder with all fields unset
2071 pub fn new() -> Self {
2072 SelfLabelsBuilder {
2073 _phantom_state: ::core::marker::PhantomData,
2074 __unsafe_private_named: (None,),
2075 _phantom: ::core::marker::PhantomData,
2076 }
2077 }
2078}
2079
2080impl<'a, S> SelfLabelsBuilder<'a, S>
2081where
2082 S: self_labels_state::State,
2083 S::Values: self_labels_state::IsUnset,
2084{
2085 /// Set the `values` field (required)
2086 pub fn values(
2087 mut self,
2088 value: impl Into<Vec<crate::com_atproto::label::SelfLabel<'a>>>,
2089 ) -> SelfLabelsBuilder<'a, self_labels_state::SetValues<S>> {
2090 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
2091 SelfLabelsBuilder {
2092 _phantom_state: ::core::marker::PhantomData,
2093 __unsafe_private_named: self.__unsafe_private_named,
2094 _phantom: ::core::marker::PhantomData,
2095 }
2096 }
2097}
2098
2099impl<'a, S> SelfLabelsBuilder<'a, S>
2100where
2101 S: self_labels_state::State,
2102 S::Values: self_labels_state::IsSet,
2103{
2104 /// Build the final struct
2105 pub fn build(self) -> SelfLabels<'a> {
2106 SelfLabels {
2107 values: self.__unsafe_private_named.0.unwrap(),
2108 extra_data: Default::default(),
2109 }
2110 }
2111 /// Build the final struct with custom extra_data
2112 pub fn build_with_data(
2113 self,
2114 extra_data: std::collections::BTreeMap<
2115 jacquard_common::smol_str::SmolStr,
2116 jacquard_common::types::value::Data<'a>,
2117 >,
2118 ) -> SelfLabels<'a> {
2119 SelfLabels {
2120 values: self.__unsafe_private_named.0.unwrap(),
2121 extra_data: Some(extra_data),
2122 }
2123 }
2124}
2125
2126impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SelfLabels<'a> {
2127 fn nsid() -> &'static str {
2128 "com.atproto.label.defs"
2129 }
2130 fn def_name() -> &'static str {
2131 "selfLabels"
2132 }
2133 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
2134 lexicon_doc_com_atproto_label_defs()
2135 }
2136 fn validate(
2137 &self,
2138 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
2139 {
2140 let value = &self.values;
2141 #[allow(unused_comparisons)]
2142 if value.len() > 10usize {
2143 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
2144 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
2145 "values",
2146 ),
2147 max: 10usize,
2148 actual: value.len(),
2149 });
2150 }
2151 }
2152 Ok(())
2153 }
2154}