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