1pub mod query_labels;
9
10#[cfg(feature = "streaming")]
11pub mod subscribe_labels;
12
13#[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 #[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 pub cts: jacquard_common::types::string::Datetime,
32 #[serde(skip_serializing_if = "std::option::Option::is_none")]
34 pub exp: std::option::Option<jacquard_common::types::string::Datetime>,
35 #[serde(skip_serializing_if = "std::option::Option::is_none")]
37 pub neg: std::option::Option<bool>,
38 #[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 #[serde(borrow)]
44 pub src: jacquard_common::types::string::Did<'a>,
45 #[serde(borrow)]
47 pub uri: jacquard_common::types::string::Uri<'a>,
48 #[serde(borrow)]
50 pub val: jacquard_common::CowStr<'a>,
51 #[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 pub trait State: sealed::Sealed {
66 type Cts;
67 type Uri;
68 type Src;
69 type Val;
70 }
71 pub struct Empty(());
73 impl sealed::Sealed for Empty {}
74 impl State for Empty {
75 type Cts = Unset;
76 type Uri = Unset;
77 type Src = Unset;
78 type Val = Unset;
79 }
80 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 Uri = S::Uri;
86 type Src = S::Src;
87 type Val = S::Val;
88 }
89 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
91 impl<S: State> sealed::Sealed for SetUri<S> {}
92 impl<S: State> State for SetUri<S> {
93 type Cts = S::Cts;
94 type Uri = Set<members::uri>;
95 type Src = S::Src;
96 type Val = S::Val;
97 }
98 pub struct SetSrc<S: State = Empty>(PhantomData<fn() -> S>);
100 impl<S: State> sealed::Sealed for SetSrc<S> {}
101 impl<S: State> State for SetSrc<S> {
102 type Cts = S::Cts;
103 type Uri = S::Uri;
104 type Src = Set<members::src>;
105 type Val = S::Val;
106 }
107 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 Uri = S::Uri;
113 type Src = S::Src;
114 type Val = Set<members::val>;
115 }
116 #[allow(non_camel_case_types)]
118 pub mod members {
119 pub struct cts(());
121 pub struct uri(());
123 pub struct src(());
125 pub struct val(());
127 }
128}
129
130pub 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 pub fn new() -> LabelBuilder<'a, label_state::Empty> {
150 LabelBuilder::new()
151 }
152}
153
154impl<'a> LabelBuilder<'a, label_state::Empty> {
155 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 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 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 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 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 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 pub fn neg(mut self, value: impl Into<Option<bool>>) -> Self {
235 self.__unsafe_private_named.3 = value.into();
236 self
237 }
238 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 pub fn sig(mut self, value: impl Into<Option<bytes::Bytes>>) -> Self {
248 self.__unsafe_private_named.4 = value.into();
249 self
250 }
251 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 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 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 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 pub fn ver(mut self, value: impl Into<Option<i64>>) -> Self {
318 self.__unsafe_private_named.8 = value.into();
319 self
320 }
321 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::Uri: label_state::IsSet,
333 S::Src: label_state::IsSet,
334 S::Val: label_state::IsSet,
335{
336 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 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 = ::std::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 = ::std::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 = ::std::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 = ::std::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 = ::std::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 = ::std::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 ) -> ::std::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> serde::Serialize for LabelValue<'a> {
972 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
973 where
974 S: serde::Serializer,
975 {
976 serializer.serialize_str(self.as_str())
977 }
978}
979
980impl<'de, 'a> serde::Deserialize<'de> for LabelValue<'a>
981where
982 'de: 'a,
983{
984 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
985 where
986 D: serde::Deserializer<'de>,
987 {
988 let s = <&'de str>::deserialize(deserializer)?;
989 Ok(Self::from(s))
990 }
991}
992
993impl jacquard_common::IntoStatic for LabelValue<'_> {
994 type Output = LabelValue<'static>;
995 fn into_static(self) -> Self::Output {
996 match self {
997 LabelValue::Hide => LabelValue::Hide,
998 LabelValue::NoPromote => LabelValue::NoPromote,
999 LabelValue::Warn => LabelValue::Warn,
1000 LabelValue::NoUnauthenticated => LabelValue::NoUnauthenticated,
1001 LabelValue::DmcaViolation => LabelValue::DmcaViolation,
1002 LabelValue::Doxxing => LabelValue::Doxxing,
1003 LabelValue::Porn => LabelValue::Porn,
1004 LabelValue::Sexual => LabelValue::Sexual,
1005 LabelValue::Nudity => LabelValue::Nudity,
1006 LabelValue::Nsfl => LabelValue::Nsfl,
1007 LabelValue::Gore => LabelValue::Gore,
1008 LabelValue::Other(v) => LabelValue::Other(v.into_static()),
1009 }
1010 }
1011}
1012
1013#[jacquard_derive::lexicon]
1015#[derive(
1016 serde::Serialize,
1017 serde::Deserialize,
1018 Debug,
1019 Clone,
1020 PartialEq,
1021 Eq,
1022 jacquard_derive::IntoStatic
1023)]
1024#[serde(rename_all = "camelCase")]
1025pub struct LabelValueDefinition<'a> {
1026 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1028 pub adult_only: std::option::Option<bool>,
1029 #[serde(borrow)]
1031 pub blurs: jacquard_common::CowStr<'a>,
1032 #[serde(skip_serializing_if = "std::option::Option::is_none")]
1034 #[serde(borrow)]
1035 pub default_setting: std::option::Option<jacquard_common::CowStr<'a>>,
1036 #[serde(borrow)]
1038 pub identifier: jacquard_common::CowStr<'a>,
1039 #[serde(borrow)]
1040 pub locales: Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>,
1041 #[serde(borrow)]
1043 pub severity: jacquard_common::CowStr<'a>,
1044}
1045
1046pub mod label_value_definition_state {
1047
1048 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1049 #[allow(unused)]
1050 use ::core::marker::PhantomData;
1051 mod sealed {
1052 pub trait Sealed {}
1053 }
1054 pub trait State: sealed::Sealed {
1056 type Blurs;
1057 type Locales;
1058 type Identifier;
1059 type Severity;
1060 }
1061 pub struct Empty(());
1063 impl sealed::Sealed for Empty {}
1064 impl State for Empty {
1065 type Blurs = Unset;
1066 type Locales = Unset;
1067 type Identifier = Unset;
1068 type Severity = Unset;
1069 }
1070 pub struct SetBlurs<S: State = Empty>(PhantomData<fn() -> S>);
1072 impl<S: State> sealed::Sealed for SetBlurs<S> {}
1073 impl<S: State> State for SetBlurs<S> {
1074 type Blurs = Set<members::blurs>;
1075 type Locales = S::Locales;
1076 type Identifier = S::Identifier;
1077 type Severity = S::Severity;
1078 }
1079 pub struct SetLocales<S: State = Empty>(PhantomData<fn() -> S>);
1081 impl<S: State> sealed::Sealed for SetLocales<S> {}
1082 impl<S: State> State for SetLocales<S> {
1083 type Blurs = S::Blurs;
1084 type Locales = Set<members::locales>;
1085 type Identifier = S::Identifier;
1086 type Severity = S::Severity;
1087 }
1088 pub struct SetIdentifier<S: State = Empty>(PhantomData<fn() -> S>);
1090 impl<S: State> sealed::Sealed for SetIdentifier<S> {}
1091 impl<S: State> State for SetIdentifier<S> {
1092 type Blurs = S::Blurs;
1093 type Locales = S::Locales;
1094 type Identifier = Set<members::identifier>;
1095 type Severity = S::Severity;
1096 }
1097 pub struct SetSeverity<S: State = Empty>(PhantomData<fn() -> S>);
1099 impl<S: State> sealed::Sealed for SetSeverity<S> {}
1100 impl<S: State> State for SetSeverity<S> {
1101 type Blurs = S::Blurs;
1102 type Locales = S::Locales;
1103 type Identifier = S::Identifier;
1104 type Severity = Set<members::severity>;
1105 }
1106 #[allow(non_camel_case_types)]
1108 pub mod members {
1109 pub struct blurs(());
1111 pub struct locales(());
1113 pub struct identifier(());
1115 pub struct severity(());
1117 }
1118}
1119
1120pub struct LabelValueDefinitionBuilder<'a, S: label_value_definition_state::State> {
1122 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
1123 __unsafe_private_named: (
1124 ::core::option::Option<bool>,
1125 ::core::option::Option<jacquard_common::CowStr<'a>>,
1126 ::core::option::Option<jacquard_common::CowStr<'a>>,
1127 ::core::option::Option<jacquard_common::CowStr<'a>>,
1128 ::core::option::Option<
1129 Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>,
1130 >,
1131 ::core::option::Option<jacquard_common::CowStr<'a>>,
1132 ),
1133 _phantom: ::core::marker::PhantomData<&'a ()>,
1134}
1135
1136impl<'a> LabelValueDefinition<'a> {
1137 pub fn new() -> LabelValueDefinitionBuilder<
1139 'a,
1140 label_value_definition_state::Empty,
1141 > {
1142 LabelValueDefinitionBuilder::new()
1143 }
1144}
1145
1146impl<'a> LabelValueDefinitionBuilder<'a, label_value_definition_state::Empty> {
1147 pub fn new() -> Self {
1149 LabelValueDefinitionBuilder {
1150 _phantom_state: ::core::marker::PhantomData,
1151 __unsafe_private_named: (None, None, None, None, None, None),
1152 _phantom: ::core::marker::PhantomData,
1153 }
1154 }
1155}
1156
1157impl<'a, S: label_value_definition_state::State> LabelValueDefinitionBuilder<'a, S> {
1158 pub fn adult_only(mut self, value: impl Into<Option<bool>>) -> Self {
1160 self.__unsafe_private_named.0 = value.into();
1161 self
1162 }
1163 pub fn maybe_adult_only(mut self, value: Option<bool>) -> Self {
1165 self.__unsafe_private_named.0 = value;
1166 self
1167 }
1168}
1169
1170impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1171where
1172 S: label_value_definition_state::State,
1173 S::Blurs: label_value_definition_state::IsUnset,
1174{
1175 pub fn blurs(
1177 mut self,
1178 value: impl Into<jacquard_common::CowStr<'a>>,
1179 ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetBlurs<S>> {
1180 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
1181 LabelValueDefinitionBuilder {
1182 _phantom_state: ::core::marker::PhantomData,
1183 __unsafe_private_named: self.__unsafe_private_named,
1184 _phantom: ::core::marker::PhantomData,
1185 }
1186 }
1187}
1188
1189impl<'a, S: label_value_definition_state::State> LabelValueDefinitionBuilder<'a, S> {
1190 pub fn default_setting(
1192 mut self,
1193 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
1194 ) -> Self {
1195 self.__unsafe_private_named.2 = value.into();
1196 self
1197 }
1198 pub fn maybe_default_setting(
1200 mut self,
1201 value: Option<jacquard_common::CowStr<'a>>,
1202 ) -> Self {
1203 self.__unsafe_private_named.2 = value;
1204 self
1205 }
1206}
1207
1208impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1209where
1210 S: label_value_definition_state::State,
1211 S::Identifier: label_value_definition_state::IsUnset,
1212{
1213 pub fn identifier(
1215 mut self,
1216 value: impl Into<jacquard_common::CowStr<'a>>,
1217 ) -> LabelValueDefinitionBuilder<
1218 'a,
1219 label_value_definition_state::SetIdentifier<S>,
1220 > {
1221 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
1222 LabelValueDefinitionBuilder {
1223 _phantom_state: ::core::marker::PhantomData,
1224 __unsafe_private_named: self.__unsafe_private_named,
1225 _phantom: ::core::marker::PhantomData,
1226 }
1227 }
1228}
1229
1230impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1231where
1232 S: label_value_definition_state::State,
1233 S::Locales: label_value_definition_state::IsUnset,
1234{
1235 pub fn locales(
1237 mut self,
1238 value: impl Into<Vec<crate::com_atproto::label::LabelValueDefinitionStrings<'a>>>,
1239 ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetLocales<S>> {
1240 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
1241 LabelValueDefinitionBuilder {
1242 _phantom_state: ::core::marker::PhantomData,
1243 __unsafe_private_named: self.__unsafe_private_named,
1244 _phantom: ::core::marker::PhantomData,
1245 }
1246 }
1247}
1248
1249impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1250where
1251 S: label_value_definition_state::State,
1252 S::Severity: label_value_definition_state::IsUnset,
1253{
1254 pub fn severity(
1256 mut self,
1257 value: impl Into<jacquard_common::CowStr<'a>>,
1258 ) -> LabelValueDefinitionBuilder<'a, label_value_definition_state::SetSeverity<S>> {
1259 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
1260 LabelValueDefinitionBuilder {
1261 _phantom_state: ::core::marker::PhantomData,
1262 __unsafe_private_named: self.__unsafe_private_named,
1263 _phantom: ::core::marker::PhantomData,
1264 }
1265 }
1266}
1267
1268impl<'a, S> LabelValueDefinitionBuilder<'a, S>
1269where
1270 S: label_value_definition_state::State,
1271 S::Blurs: label_value_definition_state::IsSet,
1272 S::Locales: label_value_definition_state::IsSet,
1273 S::Identifier: label_value_definition_state::IsSet,
1274 S::Severity: label_value_definition_state::IsSet,
1275{
1276 pub fn build(self) -> LabelValueDefinition<'a> {
1278 LabelValueDefinition {
1279 adult_only: self.__unsafe_private_named.0,
1280 blurs: self.__unsafe_private_named.1.unwrap(),
1281 default_setting: self.__unsafe_private_named.2,
1282 identifier: self.__unsafe_private_named.3.unwrap(),
1283 locales: self.__unsafe_private_named.4.unwrap(),
1284 severity: self.__unsafe_private_named.5.unwrap(),
1285 extra_data: Default::default(),
1286 }
1287 }
1288 pub fn build_with_data(
1290 self,
1291 extra_data: std::collections::BTreeMap<
1292 jacquard_common::smol_str::SmolStr,
1293 jacquard_common::types::value::Data<'a>,
1294 >,
1295 ) -> LabelValueDefinition<'a> {
1296 LabelValueDefinition {
1297 adult_only: self.__unsafe_private_named.0,
1298 blurs: self.__unsafe_private_named.1.unwrap(),
1299 default_setting: self.__unsafe_private_named.2,
1300 identifier: self.__unsafe_private_named.3.unwrap(),
1301 locales: self.__unsafe_private_named.4.unwrap(),
1302 severity: self.__unsafe_private_named.5.unwrap(),
1303 extra_data: Some(extra_data),
1304 }
1305 }
1306}
1307
1308impl<'a> ::jacquard_lexicon::schema::LexiconSchema for LabelValueDefinition<'a> {
1309 fn nsid() -> &'static str {
1310 "com.atproto.label.defs"
1311 }
1312 fn def_name() -> &'static str {
1313 "labelValueDefinition"
1314 }
1315 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1316 lexicon_doc_com_atproto_label_defs()
1317 }
1318 fn validate(
1319 &self,
1320 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1321 {
1322 let value = &self.identifier;
1323 #[allow(unused_comparisons)]
1324 if <str>::len(value.as_ref()) > 100usize {
1325 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1326 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1327 "identifier",
1328 ),
1329 max: 100usize,
1330 actual: <str>::len(value.as_ref()),
1331 });
1332 }
1333 }
1334 {
1335 let value = &self.identifier;
1336 {
1337 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
1338 value.as_ref(),
1339 true,
1340 )
1341 .count();
1342 if count > 100usize {
1343 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
1344 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1345 "identifier",
1346 ),
1347 max: 100usize,
1348 actual: count,
1349 });
1350 }
1351 }
1352 }
1353 Ok(())
1354 }
1355}
1356
1357#[jacquard_derive::lexicon]
1359#[derive(
1360 serde::Serialize,
1361 serde::Deserialize,
1362 Debug,
1363 Clone,
1364 PartialEq,
1365 Eq,
1366 jacquard_derive::IntoStatic
1367)]
1368#[serde(rename_all = "camelCase")]
1369pub struct LabelValueDefinitionStrings<'a> {
1370 #[serde(borrow)]
1372 pub description: jacquard_common::CowStr<'a>,
1373 pub lang: jacquard_common::types::string::Language,
1375 #[serde(borrow)]
1377 pub name: jacquard_common::CowStr<'a>,
1378}
1379
1380pub mod label_value_definition_strings_state {
1381
1382 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1383 #[allow(unused)]
1384 use ::core::marker::PhantomData;
1385 mod sealed {
1386 pub trait Sealed {}
1387 }
1388 pub trait State: sealed::Sealed {
1390 type Description;
1391 type Lang;
1392 type Name;
1393 }
1394 pub struct Empty(());
1396 impl sealed::Sealed for Empty {}
1397 impl State for Empty {
1398 type Description = Unset;
1399 type Lang = Unset;
1400 type Name = Unset;
1401 }
1402 pub struct SetDescription<S: State = Empty>(PhantomData<fn() -> S>);
1404 impl<S: State> sealed::Sealed for SetDescription<S> {}
1405 impl<S: State> State for SetDescription<S> {
1406 type Description = Set<members::description>;
1407 type Lang = S::Lang;
1408 type Name = S::Name;
1409 }
1410 pub struct SetLang<S: State = Empty>(PhantomData<fn() -> S>);
1412 impl<S: State> sealed::Sealed for SetLang<S> {}
1413 impl<S: State> State for SetLang<S> {
1414 type Description = S::Description;
1415 type Lang = Set<members::lang>;
1416 type Name = S::Name;
1417 }
1418 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
1420 impl<S: State> sealed::Sealed for SetName<S> {}
1421 impl<S: State> State for SetName<S> {
1422 type Description = S::Description;
1423 type Lang = S::Lang;
1424 type Name = Set<members::name>;
1425 }
1426 #[allow(non_camel_case_types)]
1428 pub mod members {
1429 pub struct description(());
1431 pub struct lang(());
1433 pub struct name(());
1435 }
1436}
1437
1438pub struct LabelValueDefinitionStringsBuilder<
1440 'a,
1441 S: label_value_definition_strings_state::State,
1442> {
1443 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
1444 __unsafe_private_named: (
1445 ::core::option::Option<jacquard_common::CowStr<'a>>,
1446 ::core::option::Option<jacquard_common::types::string::Language>,
1447 ::core::option::Option<jacquard_common::CowStr<'a>>,
1448 ),
1449 _phantom: ::core::marker::PhantomData<&'a ()>,
1450}
1451
1452impl<'a> LabelValueDefinitionStrings<'a> {
1453 pub fn new() -> LabelValueDefinitionStringsBuilder<
1455 'a,
1456 label_value_definition_strings_state::Empty,
1457 > {
1458 LabelValueDefinitionStringsBuilder::new()
1459 }
1460}
1461
1462impl<
1463 'a,
1464> LabelValueDefinitionStringsBuilder<'a, label_value_definition_strings_state::Empty> {
1465 pub fn new() -> Self {
1467 LabelValueDefinitionStringsBuilder {
1468 _phantom_state: ::core::marker::PhantomData,
1469 __unsafe_private_named: (None, None, None),
1470 _phantom: ::core::marker::PhantomData,
1471 }
1472 }
1473}
1474
1475impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1476where
1477 S: label_value_definition_strings_state::State,
1478 S::Description: label_value_definition_strings_state::IsUnset,
1479{
1480 pub fn description(
1482 mut self,
1483 value: impl Into<jacquard_common::CowStr<'a>>,
1484 ) -> LabelValueDefinitionStringsBuilder<
1485 'a,
1486 label_value_definition_strings_state::SetDescription<S>,
1487 > {
1488 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
1489 LabelValueDefinitionStringsBuilder {
1490 _phantom_state: ::core::marker::PhantomData,
1491 __unsafe_private_named: self.__unsafe_private_named,
1492 _phantom: ::core::marker::PhantomData,
1493 }
1494 }
1495}
1496
1497impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1498where
1499 S: label_value_definition_strings_state::State,
1500 S::Lang: label_value_definition_strings_state::IsUnset,
1501{
1502 pub fn lang(
1504 mut self,
1505 value: impl Into<jacquard_common::types::string::Language>,
1506 ) -> LabelValueDefinitionStringsBuilder<
1507 'a,
1508 label_value_definition_strings_state::SetLang<S>,
1509 > {
1510 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
1511 LabelValueDefinitionStringsBuilder {
1512 _phantom_state: ::core::marker::PhantomData,
1513 __unsafe_private_named: self.__unsafe_private_named,
1514 _phantom: ::core::marker::PhantomData,
1515 }
1516 }
1517}
1518
1519impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1520where
1521 S: label_value_definition_strings_state::State,
1522 S::Name: label_value_definition_strings_state::IsUnset,
1523{
1524 pub fn name(
1526 mut self,
1527 value: impl Into<jacquard_common::CowStr<'a>>,
1528 ) -> LabelValueDefinitionStringsBuilder<
1529 'a,
1530 label_value_definition_strings_state::SetName<S>,
1531 > {
1532 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
1533 LabelValueDefinitionStringsBuilder {
1534 _phantom_state: ::core::marker::PhantomData,
1535 __unsafe_private_named: self.__unsafe_private_named,
1536 _phantom: ::core::marker::PhantomData,
1537 }
1538 }
1539}
1540
1541impl<'a, S> LabelValueDefinitionStringsBuilder<'a, S>
1542where
1543 S: label_value_definition_strings_state::State,
1544 S::Description: label_value_definition_strings_state::IsSet,
1545 S::Lang: label_value_definition_strings_state::IsSet,
1546 S::Name: label_value_definition_strings_state::IsSet,
1547{
1548 pub fn build(self) -> LabelValueDefinitionStrings<'a> {
1550 LabelValueDefinitionStrings {
1551 description: self.__unsafe_private_named.0.unwrap(),
1552 lang: self.__unsafe_private_named.1.unwrap(),
1553 name: self.__unsafe_private_named.2.unwrap(),
1554 extra_data: Default::default(),
1555 }
1556 }
1557 pub fn build_with_data(
1559 self,
1560 extra_data: std::collections::BTreeMap<
1561 jacquard_common::smol_str::SmolStr,
1562 jacquard_common::types::value::Data<'a>,
1563 >,
1564 ) -> LabelValueDefinitionStrings<'a> {
1565 LabelValueDefinitionStrings {
1566 description: self.__unsafe_private_named.0.unwrap(),
1567 lang: self.__unsafe_private_named.1.unwrap(),
1568 name: self.__unsafe_private_named.2.unwrap(),
1569 extra_data: Some(extra_data),
1570 }
1571 }
1572}
1573
1574impl<'a> ::jacquard_lexicon::schema::LexiconSchema for LabelValueDefinitionStrings<'a> {
1575 fn nsid() -> &'static str {
1576 "com.atproto.label.defs"
1577 }
1578 fn def_name() -> &'static str {
1579 "labelValueDefinitionStrings"
1580 }
1581 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1582 lexicon_doc_com_atproto_label_defs()
1583 }
1584 fn validate(
1585 &self,
1586 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1587 {
1588 let value = &self.description;
1589 #[allow(unused_comparisons)]
1590 if <str>::len(value.as_ref()) > 100000usize {
1591 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1592 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1593 "description",
1594 ),
1595 max: 100000usize,
1596 actual: <str>::len(value.as_ref()),
1597 });
1598 }
1599 }
1600 {
1601 let value = &self.description;
1602 {
1603 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
1604 value.as_ref(),
1605 true,
1606 )
1607 .count();
1608 if count > 10000usize {
1609 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
1610 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1611 "description",
1612 ),
1613 max: 10000usize,
1614 actual: count,
1615 });
1616 }
1617 }
1618 }
1619 {
1620 let value = &self.name;
1621 #[allow(unused_comparisons)]
1622 if <str>::len(value.as_ref()) > 640usize {
1623 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1624 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1625 "name",
1626 ),
1627 max: 640usize,
1628 actual: <str>::len(value.as_ref()),
1629 });
1630 }
1631 }
1632 {
1633 let value = &self.name;
1634 {
1635 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
1636 value.as_ref(),
1637 true,
1638 )
1639 .count();
1640 if count > 64usize {
1641 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
1642 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1643 "name",
1644 ),
1645 max: 64usize,
1646 actual: count,
1647 });
1648 }
1649 }
1650 }
1651 Ok(())
1652 }
1653}
1654
1655#[jacquard_derive::lexicon]
1657#[derive(
1658 serde::Serialize,
1659 serde::Deserialize,
1660 Debug,
1661 Clone,
1662 PartialEq,
1663 Eq,
1664 jacquard_derive::IntoStatic,
1665 Default
1666)]
1667#[serde(rename_all = "camelCase")]
1668pub struct SelfLabel<'a> {
1669 #[serde(borrow)]
1671 pub val: jacquard_common::CowStr<'a>,
1672}
1673
1674impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SelfLabel<'a> {
1675 fn nsid() -> &'static str {
1676 "com.atproto.label.defs"
1677 }
1678 fn def_name() -> &'static str {
1679 "selfLabel"
1680 }
1681 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1682 lexicon_doc_com_atproto_label_defs()
1683 }
1684 fn validate(
1685 &self,
1686 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1687 {
1688 let value = &self.val;
1689 #[allow(unused_comparisons)]
1690 if <str>::len(value.as_ref()) > 128usize {
1691 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1692 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1693 "val",
1694 ),
1695 max: 128usize,
1696 actual: <str>::len(value.as_ref()),
1697 });
1698 }
1699 }
1700 Ok(())
1701 }
1702}
1703
1704#[jacquard_derive::lexicon]
1706#[derive(
1707 serde::Serialize,
1708 serde::Deserialize,
1709 Debug,
1710 Clone,
1711 PartialEq,
1712 Eq,
1713 jacquard_derive::IntoStatic
1714)]
1715#[serde(rename_all = "camelCase")]
1716pub struct SelfLabels<'a> {
1717 #[serde(borrow)]
1718 pub values: Vec<crate::com_atproto::label::SelfLabel<'a>>,
1719}
1720
1721pub mod self_labels_state {
1722
1723 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1724 #[allow(unused)]
1725 use ::core::marker::PhantomData;
1726 mod sealed {
1727 pub trait Sealed {}
1728 }
1729 pub trait State: sealed::Sealed {
1731 type Values;
1732 }
1733 pub struct Empty(());
1735 impl sealed::Sealed for Empty {}
1736 impl State for Empty {
1737 type Values = Unset;
1738 }
1739 pub struct SetValues<S: State = Empty>(PhantomData<fn() -> S>);
1741 impl<S: State> sealed::Sealed for SetValues<S> {}
1742 impl<S: State> State for SetValues<S> {
1743 type Values = Set<members::values>;
1744 }
1745 #[allow(non_camel_case_types)]
1747 pub mod members {
1748 pub struct values(());
1750 }
1751}
1752
1753pub struct SelfLabelsBuilder<'a, S: self_labels_state::State> {
1755 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
1756 __unsafe_private_named: (
1757 ::core::option::Option<Vec<crate::com_atproto::label::SelfLabel<'a>>>,
1758 ),
1759 _phantom: ::core::marker::PhantomData<&'a ()>,
1760}
1761
1762impl<'a> SelfLabels<'a> {
1763 pub fn new() -> SelfLabelsBuilder<'a, self_labels_state::Empty> {
1765 SelfLabelsBuilder::new()
1766 }
1767}
1768
1769impl<'a> SelfLabelsBuilder<'a, self_labels_state::Empty> {
1770 pub fn new() -> Self {
1772 SelfLabelsBuilder {
1773 _phantom_state: ::core::marker::PhantomData,
1774 __unsafe_private_named: (None,),
1775 _phantom: ::core::marker::PhantomData,
1776 }
1777 }
1778}
1779
1780impl<'a, S> SelfLabelsBuilder<'a, S>
1781where
1782 S: self_labels_state::State,
1783 S::Values: self_labels_state::IsUnset,
1784{
1785 pub fn values(
1787 mut self,
1788 value: impl Into<Vec<crate::com_atproto::label::SelfLabel<'a>>>,
1789 ) -> SelfLabelsBuilder<'a, self_labels_state::SetValues<S>> {
1790 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
1791 SelfLabelsBuilder {
1792 _phantom_state: ::core::marker::PhantomData,
1793 __unsafe_private_named: self.__unsafe_private_named,
1794 _phantom: ::core::marker::PhantomData,
1795 }
1796 }
1797}
1798
1799impl<'a, S> SelfLabelsBuilder<'a, S>
1800where
1801 S: self_labels_state::State,
1802 S::Values: self_labels_state::IsSet,
1803{
1804 pub fn build(self) -> SelfLabels<'a> {
1806 SelfLabels {
1807 values: self.__unsafe_private_named.0.unwrap(),
1808 extra_data: Default::default(),
1809 }
1810 }
1811 pub fn build_with_data(
1813 self,
1814 extra_data: std::collections::BTreeMap<
1815 jacquard_common::smol_str::SmolStr,
1816 jacquard_common::types::value::Data<'a>,
1817 >,
1818 ) -> SelfLabels<'a> {
1819 SelfLabels {
1820 values: self.__unsafe_private_named.0.unwrap(),
1821 extra_data: Some(extra_data),
1822 }
1823 }
1824}
1825
1826impl<'a> ::jacquard_lexicon::schema::LexiconSchema for SelfLabels<'a> {
1827 fn nsid() -> &'static str {
1828 "com.atproto.label.defs"
1829 }
1830 fn def_name() -> &'static str {
1831 "selfLabels"
1832 }
1833 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
1834 lexicon_doc_com_atproto_label_defs()
1835 }
1836 fn validate(
1837 &self,
1838 ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
1839 {
1840 let value = &self.values;
1841 #[allow(unused_comparisons)]
1842 if value.len() > 10usize {
1843 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
1844 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
1845 "values",
1846 ),
1847 max: 10usize,
1848 actual: value.len(),
1849 });
1850 }
1851 }
1852 Ok(())
1853 }
1854}