1pub mod get_services;
9pub mod service;
10
11
12#[allow(unused_imports)]
13use alloc::collections::BTreeMap;
14
15#[allow(unused_imports)]
16use core::marker::PhantomData;
17
18#[allow(unused_imports)]
19use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
20use jacquard_common::types::string::{AtUri, Nsid, Cid, Datetime};
21use jacquard_derive::{IntoStatic, lexicon};
22use jacquard_lexicon::lexicon::LexiconDoc;
23use jacquard_lexicon::schema::LexiconSchema;
24
25#[allow(unused_imports)]
26use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
27use serde::{Serialize, Deserialize};
28use crate::app_bsky::actor::ProfileView;
29use crate::com_atproto::label::Label;
30use crate::com_atproto::label::LabelValue;
31use crate::com_atproto::label::LabelValueDefinition;
32use crate::com_atproto::moderation::ReasonType;
33use crate::com_atproto::moderation::SubjectType;
34use crate::app_bsky::labeler;
35
36#[lexicon]
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(rename_all = "camelCase")]
39pub struct LabelerPolicies<'a> {
40 #[serde(skip_serializing_if = "Option::is_none")]
42 #[serde(borrow)]
43 pub label_value_definitions: Option<Vec<LabelValueDefinition<'a>>>,
44 #[serde(borrow)]
46 pub label_values: Vec<LabelValue<'a>>,
47}
48
49
50#[lexicon]
51#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
52#[serde(rename_all = "camelCase")]
53pub struct LabelerView<'a> {
54 #[serde(borrow)]
55 pub cid: Cid<'a>,
56 #[serde(borrow)]
57 pub creator: ProfileView<'a>,
58 pub indexed_at: Datetime,
59 #[serde(skip_serializing_if = "Option::is_none")]
60 #[serde(borrow)]
61 pub labels: Option<Vec<Label<'a>>>,
62 #[serde(skip_serializing_if = "Option::is_none")]
63 pub like_count: Option<i64>,
64 #[serde(borrow)]
65 pub uri: AtUri<'a>,
66 #[serde(skip_serializing_if = "Option::is_none")]
67 #[serde(borrow)]
68 pub viewer: Option<labeler::LabelerViewerState<'a>>,
69}
70
71
72#[lexicon]
73#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
74#[serde(rename_all = "camelCase")]
75pub struct LabelerViewDetailed<'a> {
76 #[serde(borrow)]
77 pub cid: Cid<'a>,
78 #[serde(borrow)]
79 pub creator: ProfileView<'a>,
80 pub indexed_at: Datetime,
81 #[serde(skip_serializing_if = "Option::is_none")]
82 #[serde(borrow)]
83 pub labels: Option<Vec<Label<'a>>>,
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub like_count: Option<i64>,
86 #[serde(borrow)]
87 pub policies: labeler::LabelerPolicies<'a>,
88 #[serde(skip_serializing_if = "Option::is_none")]
90 #[serde(borrow)]
91 pub reason_types: Option<Vec<ReasonType<'a>>>,
92 #[serde(skip_serializing_if = "Option::is_none")]
94 #[serde(borrow)]
95 pub subject_collections: Option<Vec<Nsid<'a>>>,
96 #[serde(skip_serializing_if = "Option::is_none")]
98 #[serde(borrow)]
99 pub subject_types: Option<Vec<SubjectType<'a>>>,
100 #[serde(borrow)]
101 pub uri: AtUri<'a>,
102 #[serde(skip_serializing_if = "Option::is_none")]
103 #[serde(borrow)]
104 pub viewer: Option<labeler::LabelerViewerState<'a>>,
105}
106
107
108#[lexicon]
109#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
110#[serde(rename_all = "camelCase")]
111pub struct LabelerViewerState<'a> {
112 #[serde(skip_serializing_if = "Option::is_none")]
113 #[serde(borrow)]
114 pub like: Option<AtUri<'a>>,
115}
116
117impl<'a> LexiconSchema for LabelerPolicies<'a> {
118 fn nsid() -> &'static str {
119 "app.bsky.labeler.defs"
120 }
121 fn def_name() -> &'static str {
122 "labelerPolicies"
123 }
124 fn lexicon_doc() -> LexiconDoc<'static> {
125 lexicon_doc_app_bsky_labeler_defs()
126 }
127 fn validate(&self) -> Result<(), ConstraintError> {
128 Ok(())
129 }
130}
131
132impl<'a> LexiconSchema for LabelerView<'a> {
133 fn nsid() -> &'static str {
134 "app.bsky.labeler.defs"
135 }
136 fn def_name() -> &'static str {
137 "labelerView"
138 }
139 fn lexicon_doc() -> LexiconDoc<'static> {
140 lexicon_doc_app_bsky_labeler_defs()
141 }
142 fn validate(&self) -> Result<(), ConstraintError> {
143 if let Some(ref value) = self.like_count {
144 if *value < 0i64 {
145 return Err(ConstraintError::Minimum {
146 path: ValidationPath::from_field("like_count"),
147 min: 0i64,
148 actual: *value,
149 });
150 }
151 }
152 Ok(())
153 }
154}
155
156impl<'a> LexiconSchema for LabelerViewDetailed<'a> {
157 fn nsid() -> &'static str {
158 "app.bsky.labeler.defs"
159 }
160 fn def_name() -> &'static str {
161 "labelerViewDetailed"
162 }
163 fn lexicon_doc() -> LexiconDoc<'static> {
164 lexicon_doc_app_bsky_labeler_defs()
165 }
166 fn validate(&self) -> Result<(), ConstraintError> {
167 if let Some(ref value) = self.like_count {
168 if *value < 0i64 {
169 return Err(ConstraintError::Minimum {
170 path: ValidationPath::from_field("like_count"),
171 min: 0i64,
172 actual: *value,
173 });
174 }
175 }
176 Ok(())
177 }
178}
179
180impl<'a> LexiconSchema for LabelerViewerState<'a> {
181 fn nsid() -> &'static str {
182 "app.bsky.labeler.defs"
183 }
184 fn def_name() -> &'static str {
185 "labelerViewerState"
186 }
187 fn lexicon_doc() -> LexiconDoc<'static> {
188 lexicon_doc_app_bsky_labeler_defs()
189 }
190 fn validate(&self) -> Result<(), ConstraintError> {
191 Ok(())
192 }
193}
194
195pub mod labeler_policies_state {
196
197 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
198 #[allow(unused)]
199 use ::core::marker::PhantomData;
200 mod sealed {
201 pub trait Sealed {}
202 }
203 pub trait State: sealed::Sealed {
205 type LabelValues;
206 }
207 pub struct Empty(());
209 impl sealed::Sealed for Empty {}
210 impl State for Empty {
211 type LabelValues = Unset;
212 }
213 pub struct SetLabelValues<S: State = Empty>(PhantomData<fn() -> S>);
215 impl<S: State> sealed::Sealed for SetLabelValues<S> {}
216 impl<S: State> State for SetLabelValues<S> {
217 type LabelValues = Set<members::label_values>;
218 }
219 #[allow(non_camel_case_types)]
221 pub mod members {
222 pub struct label_values(());
224 }
225}
226
227pub struct LabelerPoliciesBuilder<'a, S: labeler_policies_state::State> {
229 _state: PhantomData<fn() -> S>,
230 _fields: (Option<Vec<LabelValueDefinition<'a>>>, Option<Vec<LabelValue<'a>>>),
231 _lifetime: PhantomData<&'a ()>,
232}
233
234impl<'a> LabelerPolicies<'a> {
235 pub fn new() -> LabelerPoliciesBuilder<'a, labeler_policies_state::Empty> {
237 LabelerPoliciesBuilder::new()
238 }
239}
240
241impl<'a> LabelerPoliciesBuilder<'a, labeler_policies_state::Empty> {
242 pub fn new() -> Self {
244 LabelerPoliciesBuilder {
245 _state: PhantomData,
246 _fields: (None, None),
247 _lifetime: PhantomData,
248 }
249 }
250}
251
252impl<'a, S: labeler_policies_state::State> LabelerPoliciesBuilder<'a, S> {
253 pub fn label_value_definitions(
255 mut self,
256 value: impl Into<Option<Vec<LabelValueDefinition<'a>>>>,
257 ) -> Self {
258 self._fields.0 = value.into();
259 self
260 }
261 pub fn maybe_label_value_definitions(
263 mut self,
264 value: Option<Vec<LabelValueDefinition<'a>>>,
265 ) -> Self {
266 self._fields.0 = value;
267 self
268 }
269}
270
271impl<'a, S> LabelerPoliciesBuilder<'a, S>
272where
273 S: labeler_policies_state::State,
274 S::LabelValues: labeler_policies_state::IsUnset,
275{
276 pub fn label_values(
278 mut self,
279 value: impl Into<Vec<LabelValue<'a>>>,
280 ) -> LabelerPoliciesBuilder<'a, labeler_policies_state::SetLabelValues<S>> {
281 self._fields.1 = Option::Some(value.into());
282 LabelerPoliciesBuilder {
283 _state: PhantomData,
284 _fields: self._fields,
285 _lifetime: PhantomData,
286 }
287 }
288}
289
290impl<'a, S> LabelerPoliciesBuilder<'a, S>
291where
292 S: labeler_policies_state::State,
293 S::LabelValues: labeler_policies_state::IsSet,
294{
295 pub fn build(self) -> LabelerPolicies<'a> {
297 LabelerPolicies {
298 label_value_definitions: self._fields.0,
299 label_values: self._fields.1.unwrap(),
300 extra_data: Default::default(),
301 }
302 }
303 pub fn build_with_data(
305 self,
306 extra_data: BTreeMap<
307 jacquard_common::deps::smol_str::SmolStr,
308 jacquard_common::types::value::Data<'a>,
309 >,
310 ) -> LabelerPolicies<'a> {
311 LabelerPolicies {
312 label_value_definitions: self._fields.0,
313 label_values: self._fields.1.unwrap(),
314 extra_data: Some(extra_data),
315 }
316 }
317}
318
319fn lexicon_doc_app_bsky_labeler_defs() -> LexiconDoc<'static> {
320 #[allow(unused_imports)]
321 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
322 use jacquard_lexicon::lexicon::*;
323 use alloc::collections::BTreeMap;
324 LexiconDoc {
325 lexicon: Lexicon::Lexicon1,
326 id: CowStr::new_static("app.bsky.labeler.defs"),
327 defs: {
328 let mut map = BTreeMap::new();
329 map.insert(
330 SmolStr::new_static("labelerPolicies"),
331 LexUserType::Object(LexObject {
332 required: Some(vec![SmolStr::new_static("labelValues")]),
333 properties: {
334 #[allow(unused_mut)]
335 let mut map = BTreeMap::new();
336 map.insert(
337 SmolStr::new_static("labelValueDefinitions"),
338 LexObjectProperty::Array(LexArray {
339 description: Some(
340 CowStr::new_static(
341 "Label values created by this labeler and scoped exclusively to it. Labels defined here will override global label definitions for this labeler.",
342 ),
343 ),
344 items: LexArrayItem::Ref(LexRef {
345 r#ref: CowStr::new_static(
346 "com.atproto.label.defs#labelValueDefinition",
347 ),
348 ..Default::default()
349 }),
350 ..Default::default()
351 }),
352 );
353 map.insert(
354 SmolStr::new_static("labelValues"),
355 LexObjectProperty::Array(LexArray {
356 description: Some(
357 CowStr::new_static(
358 "The label values which this labeler publishes. May include global or custom labels.",
359 ),
360 ),
361 items: LexArrayItem::Ref(LexRef {
362 r#ref: CowStr::new_static(
363 "com.atproto.label.defs#labelValue",
364 ),
365 ..Default::default()
366 }),
367 ..Default::default()
368 }),
369 );
370 map
371 },
372 ..Default::default()
373 }),
374 );
375 map.insert(
376 SmolStr::new_static("labelerView"),
377 LexUserType::Object(LexObject {
378 required: Some(
379 vec![
380 SmolStr::new_static("uri"), SmolStr::new_static("cid"),
381 SmolStr::new_static("creator"),
382 SmolStr::new_static("indexedAt")
383 ],
384 ),
385 properties: {
386 #[allow(unused_mut)]
387 let mut map = BTreeMap::new();
388 map.insert(
389 SmolStr::new_static("cid"),
390 LexObjectProperty::String(LexString {
391 format: Some(LexStringFormat::Cid),
392 ..Default::default()
393 }),
394 );
395 map.insert(
396 SmolStr::new_static("creator"),
397 LexObjectProperty::Ref(LexRef {
398 r#ref: CowStr::new_static(
399 "app.bsky.actor.defs#profileView",
400 ),
401 ..Default::default()
402 }),
403 );
404 map.insert(
405 SmolStr::new_static("indexedAt"),
406 LexObjectProperty::String(LexString {
407 format: Some(LexStringFormat::Datetime),
408 ..Default::default()
409 }),
410 );
411 map.insert(
412 SmolStr::new_static("labels"),
413 LexObjectProperty::Array(LexArray {
414 items: LexArrayItem::Ref(LexRef {
415 r#ref: CowStr::new_static("com.atproto.label.defs#label"),
416 ..Default::default()
417 }),
418 ..Default::default()
419 }),
420 );
421 map.insert(
422 SmolStr::new_static("likeCount"),
423 LexObjectProperty::Integer(LexInteger {
424 minimum: Some(0i64),
425 ..Default::default()
426 }),
427 );
428 map.insert(
429 SmolStr::new_static("uri"),
430 LexObjectProperty::String(LexString {
431 format: Some(LexStringFormat::AtUri),
432 ..Default::default()
433 }),
434 );
435 map.insert(
436 SmolStr::new_static("viewer"),
437 LexObjectProperty::Ref(LexRef {
438 r#ref: CowStr::new_static("#labelerViewerState"),
439 ..Default::default()
440 }),
441 );
442 map
443 },
444 ..Default::default()
445 }),
446 );
447 map.insert(
448 SmolStr::new_static("labelerViewDetailed"),
449 LexUserType::Object(LexObject {
450 required: Some(
451 vec![
452 SmolStr::new_static("uri"), SmolStr::new_static("cid"),
453 SmolStr::new_static("creator"),
454 SmolStr::new_static("policies"),
455 SmolStr::new_static("indexedAt")
456 ],
457 ),
458 properties: {
459 #[allow(unused_mut)]
460 let mut map = BTreeMap::new();
461 map.insert(
462 SmolStr::new_static("cid"),
463 LexObjectProperty::String(LexString {
464 format: Some(LexStringFormat::Cid),
465 ..Default::default()
466 }),
467 );
468 map.insert(
469 SmolStr::new_static("creator"),
470 LexObjectProperty::Ref(LexRef {
471 r#ref: CowStr::new_static(
472 "app.bsky.actor.defs#profileView",
473 ),
474 ..Default::default()
475 }),
476 );
477 map.insert(
478 SmolStr::new_static("indexedAt"),
479 LexObjectProperty::String(LexString {
480 format: Some(LexStringFormat::Datetime),
481 ..Default::default()
482 }),
483 );
484 map.insert(
485 SmolStr::new_static("labels"),
486 LexObjectProperty::Array(LexArray {
487 items: LexArrayItem::Ref(LexRef {
488 r#ref: CowStr::new_static("com.atproto.label.defs#label"),
489 ..Default::default()
490 }),
491 ..Default::default()
492 }),
493 );
494 map.insert(
495 SmolStr::new_static("likeCount"),
496 LexObjectProperty::Integer(LexInteger {
497 minimum: Some(0i64),
498 ..Default::default()
499 }),
500 );
501 map.insert(
502 SmolStr::new_static("policies"),
503 LexObjectProperty::Ref(LexRef {
504 r#ref: CowStr::new_static(
505 "app.bsky.labeler.defs#labelerPolicies",
506 ),
507 ..Default::default()
508 }),
509 );
510 map.insert(
511 SmolStr::new_static("reasonTypes"),
512 LexObjectProperty::Array(LexArray {
513 description: Some(
514 CowStr::new_static(
515 "The set of report reason 'codes' which are in-scope for this service to review and action. These usually align to policy categories. If not defined (distinct from empty array), all reason types are allowed.",
516 ),
517 ),
518 items: LexArrayItem::Ref(LexRef {
519 r#ref: CowStr::new_static(
520 "com.atproto.moderation.defs#reasonType",
521 ),
522 ..Default::default()
523 }),
524 ..Default::default()
525 }),
526 );
527 map.insert(
528 SmolStr::new_static("subjectCollections"),
529 LexObjectProperty::Array(LexArray {
530 description: Some(
531 CowStr::new_static(
532 "Set of record types (collection NSIDs) which can be reported to this service. If not defined (distinct from empty array), default is any record type.",
533 ),
534 ),
535 items: LexArrayItem::String(LexString {
536 format: Some(LexStringFormat::Nsid),
537 ..Default::default()
538 }),
539 ..Default::default()
540 }),
541 );
542 map.insert(
543 SmolStr::new_static("subjectTypes"),
544 LexObjectProperty::Array(LexArray {
545 description: Some(
546 CowStr::new_static(
547 "The set of subject types (account, record, etc) this service accepts reports on.",
548 ),
549 ),
550 items: LexArrayItem::Ref(LexRef {
551 r#ref: CowStr::new_static(
552 "com.atproto.moderation.defs#subjectType",
553 ),
554 ..Default::default()
555 }),
556 ..Default::default()
557 }),
558 );
559 map.insert(
560 SmolStr::new_static("uri"),
561 LexObjectProperty::String(LexString {
562 format: Some(LexStringFormat::AtUri),
563 ..Default::default()
564 }),
565 );
566 map.insert(
567 SmolStr::new_static("viewer"),
568 LexObjectProperty::Ref(LexRef {
569 r#ref: CowStr::new_static("#labelerViewerState"),
570 ..Default::default()
571 }),
572 );
573 map
574 },
575 ..Default::default()
576 }),
577 );
578 map.insert(
579 SmolStr::new_static("labelerViewerState"),
580 LexUserType::Object(LexObject {
581 properties: {
582 #[allow(unused_mut)]
583 let mut map = BTreeMap::new();
584 map.insert(
585 SmolStr::new_static("like"),
586 LexObjectProperty::String(LexString {
587 format: Some(LexStringFormat::AtUri),
588 ..Default::default()
589 }),
590 );
591 map
592 },
593 ..Default::default()
594 }),
595 );
596 map
597 },
598 ..Default::default()
599 }
600}
601
602pub mod labeler_view_state {
603
604 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
605 #[allow(unused)]
606 use ::core::marker::PhantomData;
607 mod sealed {
608 pub trait Sealed {}
609 }
610 pub trait State: sealed::Sealed {
612 type Creator;
613 type Uri;
614 type Cid;
615 type IndexedAt;
616 }
617 pub struct Empty(());
619 impl sealed::Sealed for Empty {}
620 impl State for Empty {
621 type Creator = Unset;
622 type Uri = Unset;
623 type Cid = Unset;
624 type IndexedAt = Unset;
625 }
626 pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
628 impl<S: State> sealed::Sealed for SetCreator<S> {}
629 impl<S: State> State for SetCreator<S> {
630 type Creator = Set<members::creator>;
631 type Uri = S::Uri;
632 type Cid = S::Cid;
633 type IndexedAt = S::IndexedAt;
634 }
635 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
637 impl<S: State> sealed::Sealed for SetUri<S> {}
638 impl<S: State> State for SetUri<S> {
639 type Creator = S::Creator;
640 type Uri = Set<members::uri>;
641 type Cid = S::Cid;
642 type IndexedAt = S::IndexedAt;
643 }
644 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
646 impl<S: State> sealed::Sealed for SetCid<S> {}
647 impl<S: State> State for SetCid<S> {
648 type Creator = S::Creator;
649 type Uri = S::Uri;
650 type Cid = Set<members::cid>;
651 type IndexedAt = S::IndexedAt;
652 }
653 pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
655 impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
656 impl<S: State> State for SetIndexedAt<S> {
657 type Creator = S::Creator;
658 type Uri = S::Uri;
659 type Cid = S::Cid;
660 type IndexedAt = Set<members::indexed_at>;
661 }
662 #[allow(non_camel_case_types)]
664 pub mod members {
665 pub struct creator(());
667 pub struct uri(());
669 pub struct cid(());
671 pub struct indexed_at(());
673 }
674}
675
676pub struct LabelerViewBuilder<'a, S: labeler_view_state::State> {
678 _state: PhantomData<fn() -> S>,
679 _fields: (
680 Option<Cid<'a>>,
681 Option<ProfileView<'a>>,
682 Option<Datetime>,
683 Option<Vec<Label<'a>>>,
684 Option<i64>,
685 Option<AtUri<'a>>,
686 Option<labeler::LabelerViewerState<'a>>,
687 ),
688 _lifetime: PhantomData<&'a ()>,
689}
690
691impl<'a> LabelerView<'a> {
692 pub fn new() -> LabelerViewBuilder<'a, labeler_view_state::Empty> {
694 LabelerViewBuilder::new()
695 }
696}
697
698impl<'a> LabelerViewBuilder<'a, labeler_view_state::Empty> {
699 pub fn new() -> Self {
701 LabelerViewBuilder {
702 _state: PhantomData,
703 _fields: (None, None, None, None, None, None, None),
704 _lifetime: PhantomData,
705 }
706 }
707}
708
709impl<'a, S> LabelerViewBuilder<'a, S>
710where
711 S: labeler_view_state::State,
712 S::Cid: labeler_view_state::IsUnset,
713{
714 pub fn cid(
716 mut self,
717 value: impl Into<Cid<'a>>,
718 ) -> LabelerViewBuilder<'a, labeler_view_state::SetCid<S>> {
719 self._fields.0 = Option::Some(value.into());
720 LabelerViewBuilder {
721 _state: PhantomData,
722 _fields: self._fields,
723 _lifetime: PhantomData,
724 }
725 }
726}
727
728impl<'a, S> LabelerViewBuilder<'a, S>
729where
730 S: labeler_view_state::State,
731 S::Creator: labeler_view_state::IsUnset,
732{
733 pub fn creator(
735 mut self,
736 value: impl Into<ProfileView<'a>>,
737 ) -> LabelerViewBuilder<'a, labeler_view_state::SetCreator<S>> {
738 self._fields.1 = Option::Some(value.into());
739 LabelerViewBuilder {
740 _state: PhantomData,
741 _fields: self._fields,
742 _lifetime: PhantomData,
743 }
744 }
745}
746
747impl<'a, S> LabelerViewBuilder<'a, S>
748where
749 S: labeler_view_state::State,
750 S::IndexedAt: labeler_view_state::IsUnset,
751{
752 pub fn indexed_at(
754 mut self,
755 value: impl Into<Datetime>,
756 ) -> LabelerViewBuilder<'a, labeler_view_state::SetIndexedAt<S>> {
757 self._fields.2 = Option::Some(value.into());
758 LabelerViewBuilder {
759 _state: PhantomData,
760 _fields: self._fields,
761 _lifetime: PhantomData,
762 }
763 }
764}
765
766impl<'a, S: labeler_view_state::State> LabelerViewBuilder<'a, S> {
767 pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> Self {
769 self._fields.3 = value.into();
770 self
771 }
772 pub fn maybe_labels(mut self, value: Option<Vec<Label<'a>>>) -> Self {
774 self._fields.3 = value;
775 self
776 }
777}
778
779impl<'a, S: labeler_view_state::State> LabelerViewBuilder<'a, S> {
780 pub fn like_count(mut self, value: impl Into<Option<i64>>) -> Self {
782 self._fields.4 = value.into();
783 self
784 }
785 pub fn maybe_like_count(mut self, value: Option<i64>) -> Self {
787 self._fields.4 = value;
788 self
789 }
790}
791
792impl<'a, S> LabelerViewBuilder<'a, S>
793where
794 S: labeler_view_state::State,
795 S::Uri: labeler_view_state::IsUnset,
796{
797 pub fn uri(
799 mut self,
800 value: impl Into<AtUri<'a>>,
801 ) -> LabelerViewBuilder<'a, labeler_view_state::SetUri<S>> {
802 self._fields.5 = Option::Some(value.into());
803 LabelerViewBuilder {
804 _state: PhantomData,
805 _fields: self._fields,
806 _lifetime: PhantomData,
807 }
808 }
809}
810
811impl<'a, S: labeler_view_state::State> LabelerViewBuilder<'a, S> {
812 pub fn viewer(
814 mut self,
815 value: impl Into<Option<labeler::LabelerViewerState<'a>>>,
816 ) -> Self {
817 self._fields.6 = value.into();
818 self
819 }
820 pub fn maybe_viewer(
822 mut self,
823 value: Option<labeler::LabelerViewerState<'a>>,
824 ) -> Self {
825 self._fields.6 = value;
826 self
827 }
828}
829
830impl<'a, S> LabelerViewBuilder<'a, S>
831where
832 S: labeler_view_state::State,
833 S::Creator: labeler_view_state::IsSet,
834 S::Uri: labeler_view_state::IsSet,
835 S::Cid: labeler_view_state::IsSet,
836 S::IndexedAt: labeler_view_state::IsSet,
837{
838 pub fn build(self) -> LabelerView<'a> {
840 LabelerView {
841 cid: self._fields.0.unwrap(),
842 creator: self._fields.1.unwrap(),
843 indexed_at: self._fields.2.unwrap(),
844 labels: self._fields.3,
845 like_count: self._fields.4,
846 uri: self._fields.5.unwrap(),
847 viewer: self._fields.6,
848 extra_data: Default::default(),
849 }
850 }
851 pub fn build_with_data(
853 self,
854 extra_data: BTreeMap<
855 jacquard_common::deps::smol_str::SmolStr,
856 jacquard_common::types::value::Data<'a>,
857 >,
858 ) -> LabelerView<'a> {
859 LabelerView {
860 cid: self._fields.0.unwrap(),
861 creator: self._fields.1.unwrap(),
862 indexed_at: self._fields.2.unwrap(),
863 labels: self._fields.3,
864 like_count: self._fields.4,
865 uri: self._fields.5.unwrap(),
866 viewer: self._fields.6,
867 extra_data: Some(extra_data),
868 }
869 }
870}
871
872pub mod labeler_view_detailed_state {
873
874 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
875 #[allow(unused)]
876 use ::core::marker::PhantomData;
877 mod sealed {
878 pub trait Sealed {}
879 }
880 pub trait State: sealed::Sealed {
882 type Creator;
883 type Policies;
884 type IndexedAt;
885 type Cid;
886 type Uri;
887 }
888 pub struct Empty(());
890 impl sealed::Sealed for Empty {}
891 impl State for Empty {
892 type Creator = Unset;
893 type Policies = Unset;
894 type IndexedAt = Unset;
895 type Cid = Unset;
896 type Uri = Unset;
897 }
898 pub struct SetCreator<S: State = Empty>(PhantomData<fn() -> S>);
900 impl<S: State> sealed::Sealed for SetCreator<S> {}
901 impl<S: State> State for SetCreator<S> {
902 type Creator = Set<members::creator>;
903 type Policies = S::Policies;
904 type IndexedAt = S::IndexedAt;
905 type Cid = S::Cid;
906 type Uri = S::Uri;
907 }
908 pub struct SetPolicies<S: State = Empty>(PhantomData<fn() -> S>);
910 impl<S: State> sealed::Sealed for SetPolicies<S> {}
911 impl<S: State> State for SetPolicies<S> {
912 type Creator = S::Creator;
913 type Policies = Set<members::policies>;
914 type IndexedAt = S::IndexedAt;
915 type Cid = S::Cid;
916 type Uri = S::Uri;
917 }
918 pub struct SetIndexedAt<S: State = Empty>(PhantomData<fn() -> S>);
920 impl<S: State> sealed::Sealed for SetIndexedAt<S> {}
921 impl<S: State> State for SetIndexedAt<S> {
922 type Creator = S::Creator;
923 type Policies = S::Policies;
924 type IndexedAt = Set<members::indexed_at>;
925 type Cid = S::Cid;
926 type Uri = S::Uri;
927 }
928 pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
930 impl<S: State> sealed::Sealed for SetCid<S> {}
931 impl<S: State> State for SetCid<S> {
932 type Creator = S::Creator;
933 type Policies = S::Policies;
934 type IndexedAt = S::IndexedAt;
935 type Cid = Set<members::cid>;
936 type Uri = S::Uri;
937 }
938 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
940 impl<S: State> sealed::Sealed for SetUri<S> {}
941 impl<S: State> State for SetUri<S> {
942 type Creator = S::Creator;
943 type Policies = S::Policies;
944 type IndexedAt = S::IndexedAt;
945 type Cid = S::Cid;
946 type Uri = Set<members::uri>;
947 }
948 #[allow(non_camel_case_types)]
950 pub mod members {
951 pub struct creator(());
953 pub struct policies(());
955 pub struct indexed_at(());
957 pub struct cid(());
959 pub struct uri(());
961 }
962}
963
964pub struct LabelerViewDetailedBuilder<'a, S: labeler_view_detailed_state::State> {
966 _state: PhantomData<fn() -> S>,
967 _fields: (
968 Option<Cid<'a>>,
969 Option<ProfileView<'a>>,
970 Option<Datetime>,
971 Option<Vec<Label<'a>>>,
972 Option<i64>,
973 Option<labeler::LabelerPolicies<'a>>,
974 Option<Vec<ReasonType<'a>>>,
975 Option<Vec<Nsid<'a>>>,
976 Option<Vec<SubjectType<'a>>>,
977 Option<AtUri<'a>>,
978 Option<labeler::LabelerViewerState<'a>>,
979 ),
980 _lifetime: PhantomData<&'a ()>,
981}
982
983impl<'a> LabelerViewDetailed<'a> {
984 pub fn new() -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::Empty> {
986 LabelerViewDetailedBuilder::new()
987 }
988}
989
990impl<'a> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::Empty> {
991 pub fn new() -> Self {
993 LabelerViewDetailedBuilder {
994 _state: PhantomData,
995 _fields: (None, None, None, None, None, None, None, None, None, None, None),
996 _lifetime: PhantomData,
997 }
998 }
999}
1000
1001impl<'a, S> LabelerViewDetailedBuilder<'a, S>
1002where
1003 S: labeler_view_detailed_state::State,
1004 S::Cid: labeler_view_detailed_state::IsUnset,
1005{
1006 pub fn cid(
1008 mut self,
1009 value: impl Into<Cid<'a>>,
1010 ) -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::SetCid<S>> {
1011 self._fields.0 = Option::Some(value.into());
1012 LabelerViewDetailedBuilder {
1013 _state: PhantomData,
1014 _fields: self._fields,
1015 _lifetime: PhantomData,
1016 }
1017 }
1018}
1019
1020impl<'a, S> LabelerViewDetailedBuilder<'a, S>
1021where
1022 S: labeler_view_detailed_state::State,
1023 S::Creator: labeler_view_detailed_state::IsUnset,
1024{
1025 pub fn creator(
1027 mut self,
1028 value: impl Into<ProfileView<'a>>,
1029 ) -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::SetCreator<S>> {
1030 self._fields.1 = Option::Some(value.into());
1031 LabelerViewDetailedBuilder {
1032 _state: PhantomData,
1033 _fields: self._fields,
1034 _lifetime: PhantomData,
1035 }
1036 }
1037}
1038
1039impl<'a, S> LabelerViewDetailedBuilder<'a, S>
1040where
1041 S: labeler_view_detailed_state::State,
1042 S::IndexedAt: labeler_view_detailed_state::IsUnset,
1043{
1044 pub fn indexed_at(
1046 mut self,
1047 value: impl Into<Datetime>,
1048 ) -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::SetIndexedAt<S>> {
1049 self._fields.2 = Option::Some(value.into());
1050 LabelerViewDetailedBuilder {
1051 _state: PhantomData,
1052 _fields: self._fields,
1053 _lifetime: PhantomData,
1054 }
1055 }
1056}
1057
1058impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
1059 pub fn labels(mut self, value: impl Into<Option<Vec<Label<'a>>>>) -> Self {
1061 self._fields.3 = value.into();
1062 self
1063 }
1064 pub fn maybe_labels(mut self, value: Option<Vec<Label<'a>>>) -> Self {
1066 self._fields.3 = value;
1067 self
1068 }
1069}
1070
1071impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
1072 pub fn like_count(mut self, value: impl Into<Option<i64>>) -> Self {
1074 self._fields.4 = value.into();
1075 self
1076 }
1077 pub fn maybe_like_count(mut self, value: Option<i64>) -> Self {
1079 self._fields.4 = value;
1080 self
1081 }
1082}
1083
1084impl<'a, S> LabelerViewDetailedBuilder<'a, S>
1085where
1086 S: labeler_view_detailed_state::State,
1087 S::Policies: labeler_view_detailed_state::IsUnset,
1088{
1089 pub fn policies(
1091 mut self,
1092 value: impl Into<labeler::LabelerPolicies<'a>>,
1093 ) -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::SetPolicies<S>> {
1094 self._fields.5 = Option::Some(value.into());
1095 LabelerViewDetailedBuilder {
1096 _state: PhantomData,
1097 _fields: self._fields,
1098 _lifetime: PhantomData,
1099 }
1100 }
1101}
1102
1103impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
1104 pub fn reason_types(
1106 mut self,
1107 value: impl Into<Option<Vec<ReasonType<'a>>>>,
1108 ) -> Self {
1109 self._fields.6 = value.into();
1110 self
1111 }
1112 pub fn maybe_reason_types(mut self, value: Option<Vec<ReasonType<'a>>>) -> Self {
1114 self._fields.6 = value;
1115 self
1116 }
1117}
1118
1119impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
1120 pub fn subject_collections(
1122 mut self,
1123 value: impl Into<Option<Vec<Nsid<'a>>>>,
1124 ) -> Self {
1125 self._fields.7 = value.into();
1126 self
1127 }
1128 pub fn maybe_subject_collections(mut self, value: Option<Vec<Nsid<'a>>>) -> Self {
1130 self._fields.7 = value;
1131 self
1132 }
1133}
1134
1135impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
1136 pub fn subject_types(
1138 mut self,
1139 value: impl Into<Option<Vec<SubjectType<'a>>>>,
1140 ) -> Self {
1141 self._fields.8 = value.into();
1142 self
1143 }
1144 pub fn maybe_subject_types(mut self, value: Option<Vec<SubjectType<'a>>>) -> Self {
1146 self._fields.8 = value;
1147 self
1148 }
1149}
1150
1151impl<'a, S> LabelerViewDetailedBuilder<'a, S>
1152where
1153 S: labeler_view_detailed_state::State,
1154 S::Uri: labeler_view_detailed_state::IsUnset,
1155{
1156 pub fn uri(
1158 mut self,
1159 value: impl Into<AtUri<'a>>,
1160 ) -> LabelerViewDetailedBuilder<'a, labeler_view_detailed_state::SetUri<S>> {
1161 self._fields.9 = Option::Some(value.into());
1162 LabelerViewDetailedBuilder {
1163 _state: PhantomData,
1164 _fields: self._fields,
1165 _lifetime: PhantomData,
1166 }
1167 }
1168}
1169
1170impl<'a, S: labeler_view_detailed_state::State> LabelerViewDetailedBuilder<'a, S> {
1171 pub fn viewer(
1173 mut self,
1174 value: impl Into<Option<labeler::LabelerViewerState<'a>>>,
1175 ) -> Self {
1176 self._fields.10 = value.into();
1177 self
1178 }
1179 pub fn maybe_viewer(
1181 mut self,
1182 value: Option<labeler::LabelerViewerState<'a>>,
1183 ) -> Self {
1184 self._fields.10 = value;
1185 self
1186 }
1187}
1188
1189impl<'a, S> LabelerViewDetailedBuilder<'a, S>
1190where
1191 S: labeler_view_detailed_state::State,
1192 S::Creator: labeler_view_detailed_state::IsSet,
1193 S::Policies: labeler_view_detailed_state::IsSet,
1194 S::IndexedAt: labeler_view_detailed_state::IsSet,
1195 S::Cid: labeler_view_detailed_state::IsSet,
1196 S::Uri: labeler_view_detailed_state::IsSet,
1197{
1198 pub fn build(self) -> LabelerViewDetailed<'a> {
1200 LabelerViewDetailed {
1201 cid: self._fields.0.unwrap(),
1202 creator: self._fields.1.unwrap(),
1203 indexed_at: self._fields.2.unwrap(),
1204 labels: self._fields.3,
1205 like_count: self._fields.4,
1206 policies: self._fields.5.unwrap(),
1207 reason_types: self._fields.6,
1208 subject_collections: self._fields.7,
1209 subject_types: self._fields.8,
1210 uri: self._fields.9.unwrap(),
1211 viewer: self._fields.10,
1212 extra_data: Default::default(),
1213 }
1214 }
1215 pub fn build_with_data(
1217 self,
1218 extra_data: BTreeMap<
1219 jacquard_common::deps::smol_str::SmolStr,
1220 jacquard_common::types::value::Data<'a>,
1221 >,
1222 ) -> LabelerViewDetailed<'a> {
1223 LabelerViewDetailed {
1224 cid: self._fields.0.unwrap(),
1225 creator: self._fields.1.unwrap(),
1226 indexed_at: self._fields.2.unwrap(),
1227 labels: self._fields.3,
1228 like_count: self._fields.4,
1229 policies: self._fields.5.unwrap(),
1230 reason_types: self._fields.6,
1231 subject_collections: self._fields.7,
1232 subject_types: self._fields.8,
1233 uri: self._fields.9.unwrap(),
1234 viewer: self._fields.10,
1235 extra_data: Some(extra_data),
1236 }
1237 }
1238}