1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::types::string::{Did, UriValue};
18use jacquard_derive::{IntoStatic, lexicon, open_union};
19use jacquard_lexicon::lexicon::LexiconDoc;
20use jacquard_lexicon::schema::LexiconSchema;
21
22#[allow(unused_imports)]
23use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
24use serde::{Serialize, Deserialize};
25use crate::pub_leaflet::richtext::facet;
26#[lexicon]
29#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
30#[serde(rename_all = "camelCase")]
31pub struct AtMention<'a> {
32 #[serde(borrow)]
33 pub at_uri: UriValue<'a>,
34}
35
36#[lexicon]
39#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
40#[serde(rename_all = "camelCase")]
41pub struct Bold<'a> {}
42#[lexicon]
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
46#[serde(rename_all = "camelCase")]
47pub struct ByteSlice<'a> {
48 pub byte_end: i64,
49 pub byte_start: i64,
50}
51
52#[lexicon]
55#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
56#[serde(rename_all = "camelCase")]
57pub struct Code<'a> {}
58#[lexicon]
61#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
62#[serde(rename_all = "camelCase")]
63pub struct DidMention<'a> {
64 #[serde(borrow)]
65 pub did: Did<'a>,
66}
67
68#[lexicon]
71#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
72#[serde(rename_all = "camelCase")]
73pub struct Footnote<'a> {
74 #[serde(skip_serializing_if = "Option::is_none")]
75 #[serde(borrow)]
76 pub content_facets: Option<Vec<facet::Facet<'a>>>,
77 #[serde(borrow)]
78 pub content_plaintext: CowStr<'a>,
79 #[serde(borrow)]
80 pub footnote_id: CowStr<'a>,
81}
82
83#[lexicon]
86#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
87#[serde(rename_all = "camelCase")]
88pub struct Highlight<'a> {}
89#[lexicon]
92#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
93#[serde(rename_all = "camelCase")]
94pub struct Id<'a> {
95 #[serde(skip_serializing_if = "Option::is_none")]
96 #[serde(borrow)]
97 pub id: Option<CowStr<'a>>,
98}
99
100#[lexicon]
103#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
104#[serde(rename_all = "camelCase")]
105pub struct Italic<'a> {}
106#[lexicon]
109#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
110#[serde(rename_all = "camelCase")]
111pub struct Link<'a> {
112 #[serde(borrow)]
113 pub uri: CowStr<'a>,
114}
115
116#[lexicon]
119#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
120#[serde(rename_all = "camelCase")]
121pub struct Facet<'a> {
122 #[serde(borrow)]
123 pub features: Vec<FacetFeaturesItem<'a>>,
124 #[serde(borrow)]
125 pub index: facet::ByteSlice<'a>,
126}
127
128
129#[open_union]
130#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
131#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
132pub enum FacetFeaturesItem<'a> {
133 #[serde(rename = "pub.leaflet.richtext.facet#link")]
134 Link(Box<facet::Link<'a>>),
135 #[serde(rename = "pub.leaflet.richtext.facet#didMention")]
136 DidMention(Box<facet::DidMention<'a>>),
137 #[serde(rename = "pub.leaflet.richtext.facet#atMention")]
138 AtMention(Box<facet::AtMention<'a>>),
139 #[serde(rename = "pub.leaflet.richtext.facet#code")]
140 Code(Box<facet::Code<'a>>),
141 #[serde(rename = "pub.leaflet.richtext.facet#highlight")]
142 Highlight(Box<facet::Highlight<'a>>),
143 #[serde(rename = "pub.leaflet.richtext.facet#underline")]
144 Underline(Box<facet::Underline<'a>>),
145 #[serde(rename = "pub.leaflet.richtext.facet#strikethrough")]
146 Strikethrough(Box<facet::Strikethrough<'a>>),
147 #[serde(rename = "pub.leaflet.richtext.facet#id")]
148 Id(Box<facet::Id<'a>>),
149 #[serde(rename = "pub.leaflet.richtext.facet#bold")]
150 Bold(Box<facet::Bold<'a>>),
151 #[serde(rename = "pub.leaflet.richtext.facet#italic")]
152 Italic(Box<facet::Italic<'a>>),
153 #[serde(rename = "pub.leaflet.richtext.facet#footnote")]
154 Footnote(Box<facet::Footnote<'a>>),
155}
156
157#[lexicon]
160#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
161#[serde(rename_all = "camelCase")]
162pub struct Strikethrough<'a> {}
163#[lexicon]
166#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
167#[serde(rename_all = "camelCase")]
168pub struct Underline<'a> {}
169impl<'a> LexiconSchema for AtMention<'a> {
170 fn nsid() -> &'static str {
171 "pub.leaflet.richtext.facet"
172 }
173 fn def_name() -> &'static str {
174 "atMention"
175 }
176 fn lexicon_doc() -> LexiconDoc<'static> {
177 lexicon_doc_pub_leaflet_richtext_facet()
178 }
179 fn validate(&self) -> Result<(), ConstraintError> {
180 Ok(())
181 }
182}
183
184impl<'a> LexiconSchema for Bold<'a> {
185 fn nsid() -> &'static str {
186 "pub.leaflet.richtext.facet"
187 }
188 fn def_name() -> &'static str {
189 "bold"
190 }
191 fn lexicon_doc() -> LexiconDoc<'static> {
192 lexicon_doc_pub_leaflet_richtext_facet()
193 }
194 fn validate(&self) -> Result<(), ConstraintError> {
195 Ok(())
196 }
197}
198
199impl<'a> LexiconSchema for ByteSlice<'a> {
200 fn nsid() -> &'static str {
201 "pub.leaflet.richtext.facet"
202 }
203 fn def_name() -> &'static str {
204 "byteSlice"
205 }
206 fn lexicon_doc() -> LexiconDoc<'static> {
207 lexicon_doc_pub_leaflet_richtext_facet()
208 }
209 fn validate(&self) -> Result<(), ConstraintError> {
210 {
211 let value = &self.byte_end;
212 if *value < 0i64 {
213 return Err(ConstraintError::Minimum {
214 path: ValidationPath::from_field("byte_end"),
215 min: 0i64,
216 actual: *value,
217 });
218 }
219 }
220 {
221 let value = &self.byte_start;
222 if *value < 0i64 {
223 return Err(ConstraintError::Minimum {
224 path: ValidationPath::from_field("byte_start"),
225 min: 0i64,
226 actual: *value,
227 });
228 }
229 }
230 Ok(())
231 }
232}
233
234impl<'a> LexiconSchema for Code<'a> {
235 fn nsid() -> &'static str {
236 "pub.leaflet.richtext.facet"
237 }
238 fn def_name() -> &'static str {
239 "code"
240 }
241 fn lexicon_doc() -> LexiconDoc<'static> {
242 lexicon_doc_pub_leaflet_richtext_facet()
243 }
244 fn validate(&self) -> Result<(), ConstraintError> {
245 Ok(())
246 }
247}
248
249impl<'a> LexiconSchema for DidMention<'a> {
250 fn nsid() -> &'static str {
251 "pub.leaflet.richtext.facet"
252 }
253 fn def_name() -> &'static str {
254 "didMention"
255 }
256 fn lexicon_doc() -> LexiconDoc<'static> {
257 lexicon_doc_pub_leaflet_richtext_facet()
258 }
259 fn validate(&self) -> Result<(), ConstraintError> {
260 Ok(())
261 }
262}
263
264impl<'a> LexiconSchema for Footnote<'a> {
265 fn nsid() -> &'static str {
266 "pub.leaflet.richtext.facet"
267 }
268 fn def_name() -> &'static str {
269 "footnote"
270 }
271 fn lexicon_doc() -> LexiconDoc<'static> {
272 lexicon_doc_pub_leaflet_richtext_facet()
273 }
274 fn validate(&self) -> Result<(), ConstraintError> {
275 Ok(())
276 }
277}
278
279impl<'a> LexiconSchema for Highlight<'a> {
280 fn nsid() -> &'static str {
281 "pub.leaflet.richtext.facet"
282 }
283 fn def_name() -> &'static str {
284 "highlight"
285 }
286 fn lexicon_doc() -> LexiconDoc<'static> {
287 lexicon_doc_pub_leaflet_richtext_facet()
288 }
289 fn validate(&self) -> Result<(), ConstraintError> {
290 Ok(())
291 }
292}
293
294impl<'a> LexiconSchema for Id<'a> {
295 fn nsid() -> &'static str {
296 "pub.leaflet.richtext.facet"
297 }
298 fn def_name() -> &'static str {
299 "id"
300 }
301 fn lexicon_doc() -> LexiconDoc<'static> {
302 lexicon_doc_pub_leaflet_richtext_facet()
303 }
304 fn validate(&self) -> Result<(), ConstraintError> {
305 Ok(())
306 }
307}
308
309impl<'a> LexiconSchema for Italic<'a> {
310 fn nsid() -> &'static str {
311 "pub.leaflet.richtext.facet"
312 }
313 fn def_name() -> &'static str {
314 "italic"
315 }
316 fn lexicon_doc() -> LexiconDoc<'static> {
317 lexicon_doc_pub_leaflet_richtext_facet()
318 }
319 fn validate(&self) -> Result<(), ConstraintError> {
320 Ok(())
321 }
322}
323
324impl<'a> LexiconSchema for Link<'a> {
325 fn nsid() -> &'static str {
326 "pub.leaflet.richtext.facet"
327 }
328 fn def_name() -> &'static str {
329 "link"
330 }
331 fn lexicon_doc() -> LexiconDoc<'static> {
332 lexicon_doc_pub_leaflet_richtext_facet()
333 }
334 fn validate(&self) -> Result<(), ConstraintError> {
335 Ok(())
336 }
337}
338
339impl<'a> LexiconSchema for Facet<'a> {
340 fn nsid() -> &'static str {
341 "pub.leaflet.richtext.facet"
342 }
343 fn def_name() -> &'static str {
344 "main"
345 }
346 fn lexicon_doc() -> LexiconDoc<'static> {
347 lexicon_doc_pub_leaflet_richtext_facet()
348 }
349 fn validate(&self) -> Result<(), ConstraintError> {
350 Ok(())
351 }
352}
353
354impl<'a> LexiconSchema for Strikethrough<'a> {
355 fn nsid() -> &'static str {
356 "pub.leaflet.richtext.facet"
357 }
358 fn def_name() -> &'static str {
359 "strikethrough"
360 }
361 fn lexicon_doc() -> LexiconDoc<'static> {
362 lexicon_doc_pub_leaflet_richtext_facet()
363 }
364 fn validate(&self) -> Result<(), ConstraintError> {
365 Ok(())
366 }
367}
368
369impl<'a> LexiconSchema for Underline<'a> {
370 fn nsid() -> &'static str {
371 "pub.leaflet.richtext.facet"
372 }
373 fn def_name() -> &'static str {
374 "underline"
375 }
376 fn lexicon_doc() -> LexiconDoc<'static> {
377 lexicon_doc_pub_leaflet_richtext_facet()
378 }
379 fn validate(&self) -> Result<(), ConstraintError> {
380 Ok(())
381 }
382}
383
384pub mod at_mention_state {
385
386 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
387 #[allow(unused)]
388 use ::core::marker::PhantomData;
389 mod sealed {
390 pub trait Sealed {}
391 }
392 pub trait State: sealed::Sealed {
394 type AtUri;
395 }
396 pub struct Empty(());
398 impl sealed::Sealed for Empty {}
399 impl State for Empty {
400 type AtUri = Unset;
401 }
402 pub struct SetAtUri<S: State = Empty>(PhantomData<fn() -> S>);
404 impl<S: State> sealed::Sealed for SetAtUri<S> {}
405 impl<S: State> State for SetAtUri<S> {
406 type AtUri = Set<members::at_uri>;
407 }
408 #[allow(non_camel_case_types)]
410 pub mod members {
411 pub struct at_uri(());
413 }
414}
415
416pub struct AtMentionBuilder<'a, S: at_mention_state::State> {
418 _state: PhantomData<fn() -> S>,
419 _fields: (Option<UriValue<'a>>,),
420 _lifetime: PhantomData<&'a ()>,
421}
422
423impl<'a> AtMention<'a> {
424 pub fn new() -> AtMentionBuilder<'a, at_mention_state::Empty> {
426 AtMentionBuilder::new()
427 }
428}
429
430impl<'a> AtMentionBuilder<'a, at_mention_state::Empty> {
431 pub fn new() -> Self {
433 AtMentionBuilder {
434 _state: PhantomData,
435 _fields: (None,),
436 _lifetime: PhantomData,
437 }
438 }
439}
440
441impl<'a, S> AtMentionBuilder<'a, S>
442where
443 S: at_mention_state::State,
444 S::AtUri: at_mention_state::IsUnset,
445{
446 pub fn at_uri(
448 mut self,
449 value: impl Into<UriValue<'a>>,
450 ) -> AtMentionBuilder<'a, at_mention_state::SetAtUri<S>> {
451 self._fields.0 = Option::Some(value.into());
452 AtMentionBuilder {
453 _state: PhantomData,
454 _fields: self._fields,
455 _lifetime: PhantomData,
456 }
457 }
458}
459
460impl<'a, S> AtMentionBuilder<'a, S>
461where
462 S: at_mention_state::State,
463 S::AtUri: at_mention_state::IsSet,
464{
465 pub fn build(self) -> AtMention<'a> {
467 AtMention {
468 at_uri: self._fields.0.unwrap(),
469 extra_data: Default::default(),
470 }
471 }
472 pub fn build_with_data(
474 self,
475 extra_data: BTreeMap<
476 jacquard_common::deps::smol_str::SmolStr,
477 jacquard_common::types::value::Data<'a>,
478 >,
479 ) -> AtMention<'a> {
480 AtMention {
481 at_uri: self._fields.0.unwrap(),
482 extra_data: Some(extra_data),
483 }
484 }
485}
486
487fn lexicon_doc_pub_leaflet_richtext_facet() -> LexiconDoc<'static> {
488 #[allow(unused_imports)]
489 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
490 use jacquard_lexicon::lexicon::*;
491 use alloc::collections::BTreeMap;
492 LexiconDoc {
493 lexicon: Lexicon::Lexicon1,
494 id: CowStr::new_static("pub.leaflet.richtext.facet"),
495 defs: {
496 let mut map = BTreeMap::new();
497 map.insert(
498 SmolStr::new_static("atMention"),
499 LexUserType::Object(LexObject {
500 description: Some(
501 CowStr::new_static("Facet feature for mentioning an AT URI."),
502 ),
503 required: Some(vec![SmolStr::new_static("atURI")]),
504 properties: {
505 #[allow(unused_mut)]
506 let mut map = BTreeMap::new();
507 map.insert(
508 SmolStr::new_static("atURI"),
509 LexObjectProperty::String(LexString {
510 format: Some(LexStringFormat::Uri),
511 ..Default::default()
512 }),
513 );
514 map
515 },
516 ..Default::default()
517 }),
518 );
519 map.insert(
520 SmolStr::new_static("bold"),
521 LexUserType::Object(LexObject {
522 description: Some(CowStr::new_static("Facet feature for bold text")),
523 required: Some(vec![]),
524 properties: {
525 #[allow(unused_mut)]
526 let mut map = BTreeMap::new();
527 map
528 },
529 ..Default::default()
530 }),
531 );
532 map.insert(
533 SmolStr::new_static("byteSlice"),
534 LexUserType::Object(LexObject {
535 description: Some(
536 CowStr::new_static(
537 "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.",
538 ),
539 ),
540 required: Some(
541 vec![
542 SmolStr::new_static("byteStart"),
543 SmolStr::new_static("byteEnd")
544 ],
545 ),
546 properties: {
547 #[allow(unused_mut)]
548 let mut map = BTreeMap::new();
549 map.insert(
550 SmolStr::new_static("byteEnd"),
551 LexObjectProperty::Integer(LexInteger {
552 minimum: Some(0i64),
553 ..Default::default()
554 }),
555 );
556 map.insert(
557 SmolStr::new_static("byteStart"),
558 LexObjectProperty::Integer(LexInteger {
559 minimum: Some(0i64),
560 ..Default::default()
561 }),
562 );
563 map
564 },
565 ..Default::default()
566 }),
567 );
568 map.insert(
569 SmolStr::new_static("code"),
570 LexUserType::Object(LexObject {
571 description: Some(
572 CowStr::new_static("Facet feature for inline code."),
573 ),
574 required: Some(vec![]),
575 properties: {
576 #[allow(unused_mut)]
577 let mut map = BTreeMap::new();
578 map
579 },
580 ..Default::default()
581 }),
582 );
583 map.insert(
584 SmolStr::new_static("didMention"),
585 LexUserType::Object(LexObject {
586 description: Some(
587 CowStr::new_static("Facet feature for mentioning a did."),
588 ),
589 required: Some(vec![SmolStr::new_static("did")]),
590 properties: {
591 #[allow(unused_mut)]
592 let mut map = BTreeMap::new();
593 map.insert(
594 SmolStr::new_static("did"),
595 LexObjectProperty::String(LexString {
596 format: Some(LexStringFormat::Did),
597 ..Default::default()
598 }),
599 );
600 map
601 },
602 ..Default::default()
603 }),
604 );
605 map.insert(
606 SmolStr::new_static("footnote"),
607 LexUserType::Object(LexObject {
608 description: Some(
609 CowStr::new_static("Facet feature for a footnote reference"),
610 ),
611 required: Some(
612 vec![
613 SmolStr::new_static("footnoteId"),
614 SmolStr::new_static("contentPlaintext")
615 ],
616 ),
617 properties: {
618 #[allow(unused_mut)]
619 let mut map = BTreeMap::new();
620 map.insert(
621 SmolStr::new_static("contentFacets"),
622 LexObjectProperty::Array(LexArray {
623 items: LexArrayItem::Ref(LexRef {
624 r#ref: CowStr::new_static("#main"),
625 ..Default::default()
626 }),
627 ..Default::default()
628 }),
629 );
630 map.insert(
631 SmolStr::new_static("contentPlaintext"),
632 LexObjectProperty::String(LexString { ..Default::default() }),
633 );
634 map.insert(
635 SmolStr::new_static("footnoteId"),
636 LexObjectProperty::String(LexString { ..Default::default() }),
637 );
638 map
639 },
640 ..Default::default()
641 }),
642 );
643 map.insert(
644 SmolStr::new_static("highlight"),
645 LexUserType::Object(LexObject {
646 description: Some(
647 CowStr::new_static("Facet feature for highlighted text."),
648 ),
649 required: Some(vec![]),
650 properties: {
651 #[allow(unused_mut)]
652 let mut map = BTreeMap::new();
653 map
654 },
655 ..Default::default()
656 }),
657 );
658 map.insert(
659 SmolStr::new_static("id"),
660 LexUserType::Object(LexObject {
661 description: Some(
662 CowStr::new_static(
663 "Facet feature for an identifier. Used for linking to a segment",
664 ),
665 ),
666 required: Some(vec![]),
667 properties: {
668 #[allow(unused_mut)]
669 let mut map = BTreeMap::new();
670 map.insert(
671 SmolStr::new_static("id"),
672 LexObjectProperty::String(LexString { ..Default::default() }),
673 );
674 map
675 },
676 ..Default::default()
677 }),
678 );
679 map.insert(
680 SmolStr::new_static("italic"),
681 LexUserType::Object(LexObject {
682 description: Some(
683 CowStr::new_static("Facet feature for italic text"),
684 ),
685 required: Some(vec![]),
686 properties: {
687 #[allow(unused_mut)]
688 let mut map = BTreeMap::new();
689 map
690 },
691 ..Default::default()
692 }),
693 );
694 map.insert(
695 SmolStr::new_static("link"),
696 LexUserType::Object(LexObject {
697 description: Some(
698 CowStr::new_static(
699 "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.",
700 ),
701 ),
702 required: Some(vec![SmolStr::new_static("uri")]),
703 properties: {
704 #[allow(unused_mut)]
705 let mut map = BTreeMap::new();
706 map.insert(
707 SmolStr::new_static("uri"),
708 LexObjectProperty::String(LexString { ..Default::default() }),
709 );
710 map
711 },
712 ..Default::default()
713 }),
714 );
715 map.insert(
716 SmolStr::new_static("main"),
717 LexUserType::Object(LexObject {
718 description: Some(
719 CowStr::new_static(
720 "Annotation of a sub-string within rich text.",
721 ),
722 ),
723 required: Some(
724 vec![
725 SmolStr::new_static("index"), SmolStr::new_static("features")
726 ],
727 ),
728 properties: {
729 #[allow(unused_mut)]
730 let mut map = BTreeMap::new();
731 map.insert(
732 SmolStr::new_static("features"),
733 LexObjectProperty::Array(LexArray {
734 items: LexArrayItem::Union(LexRefUnion {
735 refs: vec![
736 CowStr::new_static("#link"),
737 CowStr::new_static("#didMention"),
738 CowStr::new_static("#atMention"),
739 CowStr::new_static("#code"),
740 CowStr::new_static("#highlight"),
741 CowStr::new_static("#underline"),
742 CowStr::new_static("#strikethrough"),
743 CowStr::new_static("#id"), CowStr::new_static("#bold"),
744 CowStr::new_static("#italic"),
745 CowStr::new_static("#footnote")
746 ],
747 ..Default::default()
748 }),
749 ..Default::default()
750 }),
751 );
752 map.insert(
753 SmolStr::new_static("index"),
754 LexObjectProperty::Ref(LexRef {
755 r#ref: CowStr::new_static("#byteSlice"),
756 ..Default::default()
757 }),
758 );
759 map
760 },
761 ..Default::default()
762 }),
763 );
764 map.insert(
765 SmolStr::new_static("strikethrough"),
766 LexUserType::Object(LexObject {
767 description: Some(
768 CowStr::new_static("Facet feature for strikethrough markup"),
769 ),
770 required: Some(vec![]),
771 properties: {
772 #[allow(unused_mut)]
773 let mut map = BTreeMap::new();
774 map
775 },
776 ..Default::default()
777 }),
778 );
779 map.insert(
780 SmolStr::new_static("underline"),
781 LexUserType::Object(LexObject {
782 description: Some(
783 CowStr::new_static("Facet feature for underline markup"),
784 ),
785 required: Some(vec![]),
786 properties: {
787 #[allow(unused_mut)]
788 let mut map = BTreeMap::new();
789 map
790 },
791 ..Default::default()
792 }),
793 );
794 map
795 },
796 ..Default::default()
797 }
798}
799
800pub mod byte_slice_state {
801
802 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
803 #[allow(unused)]
804 use ::core::marker::PhantomData;
805 mod sealed {
806 pub trait Sealed {}
807 }
808 pub trait State: sealed::Sealed {
810 type ByteStart;
811 type ByteEnd;
812 }
813 pub struct Empty(());
815 impl sealed::Sealed for Empty {}
816 impl State for Empty {
817 type ByteStart = Unset;
818 type ByteEnd = Unset;
819 }
820 pub struct SetByteStart<S: State = Empty>(PhantomData<fn() -> S>);
822 impl<S: State> sealed::Sealed for SetByteStart<S> {}
823 impl<S: State> State for SetByteStart<S> {
824 type ByteStart = Set<members::byte_start>;
825 type ByteEnd = S::ByteEnd;
826 }
827 pub struct SetByteEnd<S: State = Empty>(PhantomData<fn() -> S>);
829 impl<S: State> sealed::Sealed for SetByteEnd<S> {}
830 impl<S: State> State for SetByteEnd<S> {
831 type ByteStart = S::ByteStart;
832 type ByteEnd = Set<members::byte_end>;
833 }
834 #[allow(non_camel_case_types)]
836 pub mod members {
837 pub struct byte_start(());
839 pub struct byte_end(());
841 }
842}
843
844pub struct ByteSliceBuilder<'a, S: byte_slice_state::State> {
846 _state: PhantomData<fn() -> S>,
847 _fields: (Option<i64>, Option<i64>),
848 _lifetime: PhantomData<&'a ()>,
849}
850
851impl<'a> ByteSlice<'a> {
852 pub fn new() -> ByteSliceBuilder<'a, byte_slice_state::Empty> {
854 ByteSliceBuilder::new()
855 }
856}
857
858impl<'a> ByteSliceBuilder<'a, byte_slice_state::Empty> {
859 pub fn new() -> Self {
861 ByteSliceBuilder {
862 _state: PhantomData,
863 _fields: (None, None),
864 _lifetime: PhantomData,
865 }
866 }
867}
868
869impl<'a, S> ByteSliceBuilder<'a, S>
870where
871 S: byte_slice_state::State,
872 S::ByteEnd: byte_slice_state::IsUnset,
873{
874 pub fn byte_end(
876 mut self,
877 value: impl Into<i64>,
878 ) -> ByteSliceBuilder<'a, byte_slice_state::SetByteEnd<S>> {
879 self._fields.0 = Option::Some(value.into());
880 ByteSliceBuilder {
881 _state: PhantomData,
882 _fields: self._fields,
883 _lifetime: PhantomData,
884 }
885 }
886}
887
888impl<'a, S> ByteSliceBuilder<'a, S>
889where
890 S: byte_slice_state::State,
891 S::ByteStart: byte_slice_state::IsUnset,
892{
893 pub fn byte_start(
895 mut self,
896 value: impl Into<i64>,
897 ) -> ByteSliceBuilder<'a, byte_slice_state::SetByteStart<S>> {
898 self._fields.1 = Option::Some(value.into());
899 ByteSliceBuilder {
900 _state: PhantomData,
901 _fields: self._fields,
902 _lifetime: PhantomData,
903 }
904 }
905}
906
907impl<'a, S> ByteSliceBuilder<'a, S>
908where
909 S: byte_slice_state::State,
910 S::ByteStart: byte_slice_state::IsSet,
911 S::ByteEnd: byte_slice_state::IsSet,
912{
913 pub fn build(self) -> ByteSlice<'a> {
915 ByteSlice {
916 byte_end: self._fields.0.unwrap(),
917 byte_start: self._fields.1.unwrap(),
918 extra_data: Default::default(),
919 }
920 }
921 pub fn build_with_data(
923 self,
924 extra_data: BTreeMap<
925 jacquard_common::deps::smol_str::SmolStr,
926 jacquard_common::types::value::Data<'a>,
927 >,
928 ) -> ByteSlice<'a> {
929 ByteSlice {
930 byte_end: self._fields.0.unwrap(),
931 byte_start: self._fields.1.unwrap(),
932 extra_data: Some(extra_data),
933 }
934 }
935}
936
937pub mod did_mention_state {
938
939 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
940 #[allow(unused)]
941 use ::core::marker::PhantomData;
942 mod sealed {
943 pub trait Sealed {}
944 }
945 pub trait State: sealed::Sealed {
947 type Did;
948 }
949 pub struct Empty(());
951 impl sealed::Sealed for Empty {}
952 impl State for Empty {
953 type Did = Unset;
954 }
955 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
957 impl<S: State> sealed::Sealed for SetDid<S> {}
958 impl<S: State> State for SetDid<S> {
959 type Did = Set<members::did>;
960 }
961 #[allow(non_camel_case_types)]
963 pub mod members {
964 pub struct did(());
966 }
967}
968
969pub struct DidMentionBuilder<'a, S: did_mention_state::State> {
971 _state: PhantomData<fn() -> S>,
972 _fields: (Option<Did<'a>>,),
973 _lifetime: PhantomData<&'a ()>,
974}
975
976impl<'a> DidMention<'a> {
977 pub fn new() -> DidMentionBuilder<'a, did_mention_state::Empty> {
979 DidMentionBuilder::new()
980 }
981}
982
983impl<'a> DidMentionBuilder<'a, did_mention_state::Empty> {
984 pub fn new() -> Self {
986 DidMentionBuilder {
987 _state: PhantomData,
988 _fields: (None,),
989 _lifetime: PhantomData,
990 }
991 }
992}
993
994impl<'a, S> DidMentionBuilder<'a, S>
995where
996 S: did_mention_state::State,
997 S::Did: did_mention_state::IsUnset,
998{
999 pub fn did(
1001 mut self,
1002 value: impl Into<Did<'a>>,
1003 ) -> DidMentionBuilder<'a, did_mention_state::SetDid<S>> {
1004 self._fields.0 = Option::Some(value.into());
1005 DidMentionBuilder {
1006 _state: PhantomData,
1007 _fields: self._fields,
1008 _lifetime: PhantomData,
1009 }
1010 }
1011}
1012
1013impl<'a, S> DidMentionBuilder<'a, S>
1014where
1015 S: did_mention_state::State,
1016 S::Did: did_mention_state::IsSet,
1017{
1018 pub fn build(self) -> DidMention<'a> {
1020 DidMention {
1021 did: self._fields.0.unwrap(),
1022 extra_data: Default::default(),
1023 }
1024 }
1025 pub fn build_with_data(
1027 self,
1028 extra_data: BTreeMap<
1029 jacquard_common::deps::smol_str::SmolStr,
1030 jacquard_common::types::value::Data<'a>,
1031 >,
1032 ) -> DidMention<'a> {
1033 DidMention {
1034 did: self._fields.0.unwrap(),
1035 extra_data: Some(extra_data),
1036 }
1037 }
1038}
1039
1040pub mod facet_state {
1041
1042 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1043 #[allow(unused)]
1044 use ::core::marker::PhantomData;
1045 mod sealed {
1046 pub trait Sealed {}
1047 }
1048 pub trait State: sealed::Sealed {
1050 type Features;
1051 type Index;
1052 }
1053 pub struct Empty(());
1055 impl sealed::Sealed for Empty {}
1056 impl State for Empty {
1057 type Features = Unset;
1058 type Index = Unset;
1059 }
1060 pub struct SetFeatures<S: State = Empty>(PhantomData<fn() -> S>);
1062 impl<S: State> sealed::Sealed for SetFeatures<S> {}
1063 impl<S: State> State for SetFeatures<S> {
1064 type Features = Set<members::features>;
1065 type Index = S::Index;
1066 }
1067 pub struct SetIndex<S: State = Empty>(PhantomData<fn() -> S>);
1069 impl<S: State> sealed::Sealed for SetIndex<S> {}
1070 impl<S: State> State for SetIndex<S> {
1071 type Features = S::Features;
1072 type Index = Set<members::index>;
1073 }
1074 #[allow(non_camel_case_types)]
1076 pub mod members {
1077 pub struct features(());
1079 pub struct index(());
1081 }
1082}
1083
1084pub struct FacetBuilder<'a, S: facet_state::State> {
1086 _state: PhantomData<fn() -> S>,
1087 _fields: (Option<Vec<FacetFeaturesItem<'a>>>, Option<facet::ByteSlice<'a>>),
1088 _lifetime: PhantomData<&'a ()>,
1089}
1090
1091impl<'a> Facet<'a> {
1092 pub fn new() -> FacetBuilder<'a, facet_state::Empty> {
1094 FacetBuilder::new()
1095 }
1096}
1097
1098impl<'a> FacetBuilder<'a, facet_state::Empty> {
1099 pub fn new() -> Self {
1101 FacetBuilder {
1102 _state: PhantomData,
1103 _fields: (None, None),
1104 _lifetime: PhantomData,
1105 }
1106 }
1107}
1108
1109impl<'a, S> FacetBuilder<'a, S>
1110where
1111 S: facet_state::State,
1112 S::Features: facet_state::IsUnset,
1113{
1114 pub fn features(
1116 mut self,
1117 value: impl Into<Vec<FacetFeaturesItem<'a>>>,
1118 ) -> FacetBuilder<'a, facet_state::SetFeatures<S>> {
1119 self._fields.0 = Option::Some(value.into());
1120 FacetBuilder {
1121 _state: PhantomData,
1122 _fields: self._fields,
1123 _lifetime: PhantomData,
1124 }
1125 }
1126}
1127
1128impl<'a, S> FacetBuilder<'a, S>
1129where
1130 S: facet_state::State,
1131 S::Index: facet_state::IsUnset,
1132{
1133 pub fn index(
1135 mut self,
1136 value: impl Into<facet::ByteSlice<'a>>,
1137 ) -> FacetBuilder<'a, facet_state::SetIndex<S>> {
1138 self._fields.1 = Option::Some(value.into());
1139 FacetBuilder {
1140 _state: PhantomData,
1141 _fields: self._fields,
1142 _lifetime: PhantomData,
1143 }
1144 }
1145}
1146
1147impl<'a, S> FacetBuilder<'a, S>
1148where
1149 S: facet_state::State,
1150 S::Features: facet_state::IsSet,
1151 S::Index: facet_state::IsSet,
1152{
1153 pub fn build(self) -> Facet<'a> {
1155 Facet {
1156 features: self._fields.0.unwrap(),
1157 index: self._fields.1.unwrap(),
1158 extra_data: Default::default(),
1159 }
1160 }
1161 pub fn build_with_data(
1163 self,
1164 extra_data: BTreeMap<
1165 jacquard_common::deps::smol_str::SmolStr,
1166 jacquard_common::types::value::Data<'a>,
1167 >,
1168 ) -> Facet<'a> {
1169 Facet {
1170 features: self._fields.0.unwrap(),
1171 index: self._fields.1.unwrap(),
1172 extra_data: Some(extra_data),
1173 }
1174 }
1175}