Skip to main content

jacquard_api/network_slices/tools/richtext/
facet.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.tools.richtext.facet
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[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::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::network_slices::tools::richtext::facet;
26/// Facet feature for bold text.
27
28#[lexicon]
29#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
30#[serde(rename_all = "camelCase")]
31pub struct Bold<'a> {}
32/// 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.
33
34#[lexicon]
35#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
36#[serde(rename_all = "camelCase")]
37pub struct ByteSlice<'a> {
38    pub byte_end: i64,
39    pub byte_start: i64,
40}
41
42/// Facet feature for inline code.
43
44#[lexicon]
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
46#[serde(rename_all = "camelCase")]
47pub struct Code<'a> {}
48/// Facet feature for fenced code blocks.
49
50#[lexicon]
51#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
52#[serde(rename_all = "camelCase")]
53pub struct CodeBlock<'a> {
54    ///Optional language identifier for syntax highlighting.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    #[serde(borrow)]
57    pub lang: Option<CowStr<'a>>,
58}
59
60/// Facet feature for italic text.
61
62#[lexicon]
63#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
64#[serde(rename_all = "camelCase")]
65pub struct Italic<'a> {}
66/// Facet feature for a URL.
67
68#[lexicon]
69#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
70#[serde(rename_all = "camelCase")]
71pub struct Link<'a> {
72    #[serde(borrow)]
73    pub uri: UriValue<'a>,
74}
75
76/// Annotation of a sub-string within rich text.
77
78#[lexicon]
79#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
80#[serde(rename_all = "camelCase")]
81pub struct Facet<'a> {
82    #[serde(borrow)]
83    pub features: Vec<FacetFeaturesItem<'a>>,
84    #[serde(borrow)]
85    pub index: facet::ByteSlice<'a>,
86}
87
88
89#[open_union]
90#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
91#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
92pub enum FacetFeaturesItem<'a> {
93    #[serde(rename = "network.slices.tools.richtext.facet#link")]
94    Link(Box<facet::Link<'a>>),
95    #[serde(rename = "network.slices.tools.richtext.facet#bold")]
96    Bold(Box<facet::Bold<'a>>),
97    #[serde(rename = "network.slices.tools.richtext.facet#italic")]
98    Italic(Box<facet::Italic<'a>>),
99    #[serde(rename = "network.slices.tools.richtext.facet#code")]
100    Code(Box<facet::Code<'a>>),
101    #[serde(rename = "network.slices.tools.richtext.facet#codeBlock")]
102    CodeBlock(Box<facet::CodeBlock<'a>>),
103}
104
105impl<'a> LexiconSchema for Bold<'a> {
106    fn nsid() -> &'static str {
107        "network.slices.tools.richtext.facet"
108    }
109    fn def_name() -> &'static str {
110        "bold"
111    }
112    fn lexicon_doc() -> LexiconDoc<'static> {
113        lexicon_doc_network_slices_tools_richtext_facet()
114    }
115    fn validate(&self) -> Result<(), ConstraintError> {
116        Ok(())
117    }
118}
119
120impl<'a> LexiconSchema for ByteSlice<'a> {
121    fn nsid() -> &'static str {
122        "network.slices.tools.richtext.facet"
123    }
124    fn def_name() -> &'static str {
125        "byteSlice"
126    }
127    fn lexicon_doc() -> LexiconDoc<'static> {
128        lexicon_doc_network_slices_tools_richtext_facet()
129    }
130    fn validate(&self) -> Result<(), ConstraintError> {
131        {
132            let value = &self.byte_end;
133            if *value < 0i64 {
134                return Err(ConstraintError::Minimum {
135                    path: ValidationPath::from_field("byte_end"),
136                    min: 0i64,
137                    actual: *value,
138                });
139            }
140        }
141        {
142            let value = &self.byte_start;
143            if *value < 0i64 {
144                return Err(ConstraintError::Minimum {
145                    path: ValidationPath::from_field("byte_start"),
146                    min: 0i64,
147                    actual: *value,
148                });
149            }
150        }
151        Ok(())
152    }
153}
154
155impl<'a> LexiconSchema for Code<'a> {
156    fn nsid() -> &'static str {
157        "network.slices.tools.richtext.facet"
158    }
159    fn def_name() -> &'static str {
160        "code"
161    }
162    fn lexicon_doc() -> LexiconDoc<'static> {
163        lexicon_doc_network_slices_tools_richtext_facet()
164    }
165    fn validate(&self) -> Result<(), ConstraintError> {
166        Ok(())
167    }
168}
169
170impl<'a> LexiconSchema for CodeBlock<'a> {
171    fn nsid() -> &'static str {
172        "network.slices.tools.richtext.facet"
173    }
174    fn def_name() -> &'static str {
175        "codeBlock"
176    }
177    fn lexicon_doc() -> LexiconDoc<'static> {
178        lexicon_doc_network_slices_tools_richtext_facet()
179    }
180    fn validate(&self) -> Result<(), ConstraintError> {
181        Ok(())
182    }
183}
184
185impl<'a> LexiconSchema for Italic<'a> {
186    fn nsid() -> &'static str {
187        "network.slices.tools.richtext.facet"
188    }
189    fn def_name() -> &'static str {
190        "italic"
191    }
192    fn lexicon_doc() -> LexiconDoc<'static> {
193        lexicon_doc_network_slices_tools_richtext_facet()
194    }
195    fn validate(&self) -> Result<(), ConstraintError> {
196        Ok(())
197    }
198}
199
200impl<'a> LexiconSchema for Link<'a> {
201    fn nsid() -> &'static str {
202        "network.slices.tools.richtext.facet"
203    }
204    fn def_name() -> &'static str {
205        "link"
206    }
207    fn lexicon_doc() -> LexiconDoc<'static> {
208        lexicon_doc_network_slices_tools_richtext_facet()
209    }
210    fn validate(&self) -> Result<(), ConstraintError> {
211        Ok(())
212    }
213}
214
215impl<'a> LexiconSchema for Facet<'a> {
216    fn nsid() -> &'static str {
217        "network.slices.tools.richtext.facet"
218    }
219    fn def_name() -> &'static str {
220        "main"
221    }
222    fn lexicon_doc() -> LexiconDoc<'static> {
223        lexicon_doc_network_slices_tools_richtext_facet()
224    }
225    fn validate(&self) -> Result<(), ConstraintError> {
226        Ok(())
227    }
228}
229
230fn lexicon_doc_network_slices_tools_richtext_facet() -> LexiconDoc<'static> {
231    #[allow(unused_imports)]
232    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
233    use jacquard_lexicon::lexicon::*;
234    use alloc::collections::BTreeMap;
235    LexiconDoc {
236        lexicon: Lexicon::Lexicon1,
237        id: CowStr::new_static("network.slices.tools.richtext.facet"),
238        defs: {
239            let mut map = BTreeMap::new();
240            map.insert(
241                SmolStr::new_static("bold"),
242                LexUserType::Object(LexObject {
243                    description: Some(
244                        CowStr::new_static("Facet feature for bold text."),
245                    ),
246                    required: Some(vec![]),
247                    properties: {
248                        #[allow(unused_mut)]
249                        let mut map = BTreeMap::new();
250                        map
251                    },
252                    ..Default::default()
253                }),
254            );
255            map.insert(
256                SmolStr::new_static("byteSlice"),
257                LexUserType::Object(LexObject {
258                    description: Some(
259                        CowStr::new_static(
260                            "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.",
261                        ),
262                    ),
263                    required: Some(
264                        vec![
265                            SmolStr::new_static("byteStart"),
266                            SmolStr::new_static("byteEnd")
267                        ],
268                    ),
269                    properties: {
270                        #[allow(unused_mut)]
271                        let mut map = BTreeMap::new();
272                        map.insert(
273                            SmolStr::new_static("byteEnd"),
274                            LexObjectProperty::Integer(LexInteger {
275                                minimum: Some(0i64),
276                                ..Default::default()
277                            }),
278                        );
279                        map.insert(
280                            SmolStr::new_static("byteStart"),
281                            LexObjectProperty::Integer(LexInteger {
282                                minimum: Some(0i64),
283                                ..Default::default()
284                            }),
285                        );
286                        map
287                    },
288                    ..Default::default()
289                }),
290            );
291            map.insert(
292                SmolStr::new_static("code"),
293                LexUserType::Object(LexObject {
294                    description: Some(
295                        CowStr::new_static("Facet feature for inline code."),
296                    ),
297                    required: Some(vec![]),
298                    properties: {
299                        #[allow(unused_mut)]
300                        let mut map = BTreeMap::new();
301                        map
302                    },
303                    ..Default::default()
304                }),
305            );
306            map.insert(
307                SmolStr::new_static("codeBlock"),
308                LexUserType::Object(LexObject {
309                    description: Some(
310                        CowStr::new_static("Facet feature for fenced code blocks."),
311                    ),
312                    required: Some(vec![]),
313                    properties: {
314                        #[allow(unused_mut)]
315                        let mut map = BTreeMap::new();
316                        map.insert(
317                            SmolStr::new_static("lang"),
318                            LexObjectProperty::String(LexString {
319                                description: Some(
320                                    CowStr::new_static(
321                                        "Optional language identifier for syntax highlighting.",
322                                    ),
323                                ),
324                                ..Default::default()
325                            }),
326                        );
327                        map
328                    },
329                    ..Default::default()
330                }),
331            );
332            map.insert(
333                SmolStr::new_static("italic"),
334                LexUserType::Object(LexObject {
335                    description: Some(
336                        CowStr::new_static("Facet feature for italic text."),
337                    ),
338                    required: Some(vec![]),
339                    properties: {
340                        #[allow(unused_mut)]
341                        let mut map = BTreeMap::new();
342                        map
343                    },
344                    ..Default::default()
345                }),
346            );
347            map.insert(
348                SmolStr::new_static("link"),
349                LexUserType::Object(LexObject {
350                    description: Some(CowStr::new_static("Facet feature for a URL.")),
351                    required: Some(vec![SmolStr::new_static("uri")]),
352                    properties: {
353                        #[allow(unused_mut)]
354                        let mut map = BTreeMap::new();
355                        map.insert(
356                            SmolStr::new_static("uri"),
357                            LexObjectProperty::String(LexString {
358                                format: Some(LexStringFormat::Uri),
359                                ..Default::default()
360                            }),
361                        );
362                        map
363                    },
364                    ..Default::default()
365                }),
366            );
367            map.insert(
368                SmolStr::new_static("main"),
369                LexUserType::Object(LexObject {
370                    description: Some(
371                        CowStr::new_static(
372                            "Annotation of a sub-string within rich text.",
373                        ),
374                    ),
375                    required: Some(
376                        vec![
377                            SmolStr::new_static("index"), SmolStr::new_static("features")
378                        ],
379                    ),
380                    properties: {
381                        #[allow(unused_mut)]
382                        let mut map = BTreeMap::new();
383                        map.insert(
384                            SmolStr::new_static("features"),
385                            LexObjectProperty::Array(LexArray {
386                                items: LexArrayItem::Union(LexRefUnion {
387                                    refs: vec![
388                                        CowStr::new_static("#link"), CowStr::new_static("#bold"),
389                                        CowStr::new_static("#italic"), CowStr::new_static("#code"),
390                                        CowStr::new_static("#codeBlock")
391                                    ],
392                                    ..Default::default()
393                                }),
394                                ..Default::default()
395                            }),
396                        );
397                        map.insert(
398                            SmolStr::new_static("index"),
399                            LexObjectProperty::Ref(LexRef {
400                                r#ref: CowStr::new_static("#byteSlice"),
401                                ..Default::default()
402                            }),
403                        );
404                        map
405                    },
406                    ..Default::default()
407                }),
408            );
409            map
410        },
411        ..Default::default()
412    }
413}
414
415pub mod byte_slice_state {
416
417    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
418    #[allow(unused)]
419    use ::core::marker::PhantomData;
420    mod sealed {
421        pub trait Sealed {}
422    }
423    /// State trait tracking which required fields have been set
424    pub trait State: sealed::Sealed {
425        type ByteStart;
426        type ByteEnd;
427    }
428    /// Empty state - all required fields are unset
429    pub struct Empty(());
430    impl sealed::Sealed for Empty {}
431    impl State for Empty {
432        type ByteStart = Unset;
433        type ByteEnd = Unset;
434    }
435    ///State transition - sets the `byte_start` field to Set
436    pub struct SetByteStart<S: State = Empty>(PhantomData<fn() -> S>);
437    impl<S: State> sealed::Sealed for SetByteStart<S> {}
438    impl<S: State> State for SetByteStart<S> {
439        type ByteStart = Set<members::byte_start>;
440        type ByteEnd = S::ByteEnd;
441    }
442    ///State transition - sets the `byte_end` field to Set
443    pub struct SetByteEnd<S: State = Empty>(PhantomData<fn() -> S>);
444    impl<S: State> sealed::Sealed for SetByteEnd<S> {}
445    impl<S: State> State for SetByteEnd<S> {
446        type ByteStart = S::ByteStart;
447        type ByteEnd = Set<members::byte_end>;
448    }
449    /// Marker types for field names
450    #[allow(non_camel_case_types)]
451    pub mod members {
452        ///Marker type for the `byte_start` field
453        pub struct byte_start(());
454        ///Marker type for the `byte_end` field
455        pub struct byte_end(());
456    }
457}
458
459/// Builder for constructing an instance of this type
460pub struct ByteSliceBuilder<'a, S: byte_slice_state::State> {
461    _state: PhantomData<fn() -> S>,
462    _fields: (Option<i64>, Option<i64>),
463    _lifetime: PhantomData<&'a ()>,
464}
465
466impl<'a> ByteSlice<'a> {
467    /// Create a new builder for this type
468    pub fn new() -> ByteSliceBuilder<'a, byte_slice_state::Empty> {
469        ByteSliceBuilder::new()
470    }
471}
472
473impl<'a> ByteSliceBuilder<'a, byte_slice_state::Empty> {
474    /// Create a new builder with all fields unset
475    pub fn new() -> Self {
476        ByteSliceBuilder {
477            _state: PhantomData,
478            _fields: (None, None),
479            _lifetime: PhantomData,
480        }
481    }
482}
483
484impl<'a, S> ByteSliceBuilder<'a, S>
485where
486    S: byte_slice_state::State,
487    S::ByteEnd: byte_slice_state::IsUnset,
488{
489    /// Set the `byteEnd` field (required)
490    pub fn byte_end(
491        mut self,
492        value: impl Into<i64>,
493    ) -> ByteSliceBuilder<'a, byte_slice_state::SetByteEnd<S>> {
494        self._fields.0 = Option::Some(value.into());
495        ByteSliceBuilder {
496            _state: PhantomData,
497            _fields: self._fields,
498            _lifetime: PhantomData,
499        }
500    }
501}
502
503impl<'a, S> ByteSliceBuilder<'a, S>
504where
505    S: byte_slice_state::State,
506    S::ByteStart: byte_slice_state::IsUnset,
507{
508    /// Set the `byteStart` field (required)
509    pub fn byte_start(
510        mut self,
511        value: impl Into<i64>,
512    ) -> ByteSliceBuilder<'a, byte_slice_state::SetByteStart<S>> {
513        self._fields.1 = Option::Some(value.into());
514        ByteSliceBuilder {
515            _state: PhantomData,
516            _fields: self._fields,
517            _lifetime: PhantomData,
518        }
519    }
520}
521
522impl<'a, S> ByteSliceBuilder<'a, S>
523where
524    S: byte_slice_state::State,
525    S::ByteStart: byte_slice_state::IsSet,
526    S::ByteEnd: byte_slice_state::IsSet,
527{
528    /// Build the final struct
529    pub fn build(self) -> ByteSlice<'a> {
530        ByteSlice {
531            byte_end: self._fields.0.unwrap(),
532            byte_start: self._fields.1.unwrap(),
533            extra_data: Default::default(),
534        }
535    }
536    /// Build the final struct with custom extra_data
537    pub fn build_with_data(
538        self,
539        extra_data: BTreeMap<
540            jacquard_common::deps::smol_str::SmolStr,
541            jacquard_common::types::value::Data<'a>,
542        >,
543    ) -> ByteSlice<'a> {
544        ByteSlice {
545            byte_end: self._fields.0.unwrap(),
546            byte_start: self._fields.1.unwrap(),
547            extra_data: Some(extra_data),
548        }
549    }
550}
551
552pub mod link_state {
553
554    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
555    #[allow(unused)]
556    use ::core::marker::PhantomData;
557    mod sealed {
558        pub trait Sealed {}
559    }
560    /// State trait tracking which required fields have been set
561    pub trait State: sealed::Sealed {
562        type Uri;
563    }
564    /// Empty state - all required fields are unset
565    pub struct Empty(());
566    impl sealed::Sealed for Empty {}
567    impl State for Empty {
568        type Uri = Unset;
569    }
570    ///State transition - sets the `uri` field to Set
571    pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
572    impl<S: State> sealed::Sealed for SetUri<S> {}
573    impl<S: State> State for SetUri<S> {
574        type Uri = Set<members::uri>;
575    }
576    /// Marker types for field names
577    #[allow(non_camel_case_types)]
578    pub mod members {
579        ///Marker type for the `uri` field
580        pub struct uri(());
581    }
582}
583
584/// Builder for constructing an instance of this type
585pub struct LinkBuilder<'a, S: link_state::State> {
586    _state: PhantomData<fn() -> S>,
587    _fields: (Option<UriValue<'a>>,),
588    _lifetime: PhantomData<&'a ()>,
589}
590
591impl<'a> Link<'a> {
592    /// Create a new builder for this type
593    pub fn new() -> LinkBuilder<'a, link_state::Empty> {
594        LinkBuilder::new()
595    }
596}
597
598impl<'a> LinkBuilder<'a, link_state::Empty> {
599    /// Create a new builder with all fields unset
600    pub fn new() -> Self {
601        LinkBuilder {
602            _state: PhantomData,
603            _fields: (None,),
604            _lifetime: PhantomData,
605        }
606    }
607}
608
609impl<'a, S> LinkBuilder<'a, S>
610where
611    S: link_state::State,
612    S::Uri: link_state::IsUnset,
613{
614    /// Set the `uri` field (required)
615    pub fn uri(
616        mut self,
617        value: impl Into<UriValue<'a>>,
618    ) -> LinkBuilder<'a, link_state::SetUri<S>> {
619        self._fields.0 = Option::Some(value.into());
620        LinkBuilder {
621            _state: PhantomData,
622            _fields: self._fields,
623            _lifetime: PhantomData,
624        }
625    }
626}
627
628impl<'a, S> LinkBuilder<'a, S>
629where
630    S: link_state::State,
631    S::Uri: link_state::IsSet,
632{
633    /// Build the final struct
634    pub fn build(self) -> Link<'a> {
635        Link {
636            uri: self._fields.0.unwrap(),
637            extra_data: Default::default(),
638        }
639    }
640    /// Build the final struct with custom extra_data
641    pub fn build_with_data(
642        self,
643        extra_data: BTreeMap<
644            jacquard_common::deps::smol_str::SmolStr,
645            jacquard_common::types::value::Data<'a>,
646        >,
647    ) -> Link<'a> {
648        Link {
649            uri: self._fields.0.unwrap(),
650            extra_data: Some(extra_data),
651        }
652    }
653}
654
655pub mod facet_state {
656
657    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
658    #[allow(unused)]
659    use ::core::marker::PhantomData;
660    mod sealed {
661        pub trait Sealed {}
662    }
663    /// State trait tracking which required fields have been set
664    pub trait State: sealed::Sealed {
665        type Features;
666        type Index;
667    }
668    /// Empty state - all required fields are unset
669    pub struct Empty(());
670    impl sealed::Sealed for Empty {}
671    impl State for Empty {
672        type Features = Unset;
673        type Index = Unset;
674    }
675    ///State transition - sets the `features` field to Set
676    pub struct SetFeatures<S: State = Empty>(PhantomData<fn() -> S>);
677    impl<S: State> sealed::Sealed for SetFeatures<S> {}
678    impl<S: State> State for SetFeatures<S> {
679        type Features = Set<members::features>;
680        type Index = S::Index;
681    }
682    ///State transition - sets the `index` field to Set
683    pub struct SetIndex<S: State = Empty>(PhantomData<fn() -> S>);
684    impl<S: State> sealed::Sealed for SetIndex<S> {}
685    impl<S: State> State for SetIndex<S> {
686        type Features = S::Features;
687        type Index = Set<members::index>;
688    }
689    /// Marker types for field names
690    #[allow(non_camel_case_types)]
691    pub mod members {
692        ///Marker type for the `features` field
693        pub struct features(());
694        ///Marker type for the `index` field
695        pub struct index(());
696    }
697}
698
699/// Builder for constructing an instance of this type
700pub struct FacetBuilder<'a, S: facet_state::State> {
701    _state: PhantomData<fn() -> S>,
702    _fields: (Option<Vec<FacetFeaturesItem<'a>>>, Option<facet::ByteSlice<'a>>),
703    _lifetime: PhantomData<&'a ()>,
704}
705
706impl<'a> Facet<'a> {
707    /// Create a new builder for this type
708    pub fn new() -> FacetBuilder<'a, facet_state::Empty> {
709        FacetBuilder::new()
710    }
711}
712
713impl<'a> FacetBuilder<'a, facet_state::Empty> {
714    /// Create a new builder with all fields unset
715    pub fn new() -> Self {
716        FacetBuilder {
717            _state: PhantomData,
718            _fields: (None, None),
719            _lifetime: PhantomData,
720        }
721    }
722}
723
724impl<'a, S> FacetBuilder<'a, S>
725where
726    S: facet_state::State,
727    S::Features: facet_state::IsUnset,
728{
729    /// Set the `features` field (required)
730    pub fn features(
731        mut self,
732        value: impl Into<Vec<FacetFeaturesItem<'a>>>,
733    ) -> FacetBuilder<'a, facet_state::SetFeatures<S>> {
734        self._fields.0 = Option::Some(value.into());
735        FacetBuilder {
736            _state: PhantomData,
737            _fields: self._fields,
738            _lifetime: PhantomData,
739        }
740    }
741}
742
743impl<'a, S> FacetBuilder<'a, S>
744where
745    S: facet_state::State,
746    S::Index: facet_state::IsUnset,
747{
748    /// Set the `index` field (required)
749    pub fn index(
750        mut self,
751        value: impl Into<facet::ByteSlice<'a>>,
752    ) -> FacetBuilder<'a, facet_state::SetIndex<S>> {
753        self._fields.1 = Option::Some(value.into());
754        FacetBuilder {
755            _state: PhantomData,
756            _fields: self._fields,
757            _lifetime: PhantomData,
758        }
759    }
760}
761
762impl<'a, S> FacetBuilder<'a, S>
763where
764    S: facet_state::State,
765    S::Features: facet_state::IsSet,
766    S::Index: facet_state::IsSet,
767{
768    /// Build the final struct
769    pub fn build(self) -> Facet<'a> {
770        Facet {
771            features: self._fields.0.unwrap(),
772            index: self._fields.1.unwrap(),
773            extra_data: Default::default(),
774        }
775    }
776    /// Build the final struct with custom extra_data
777    pub fn build_with_data(
778        self,
779        extra_data: BTreeMap<
780            jacquard_common::deps::smol_str::SmolStr,
781            jacquard_common::types::value::Data<'a>,
782        >,
783    ) -> Facet<'a> {
784        Facet {
785            features: self._fields.0.unwrap(),
786            index: self._fields.1.unwrap(),
787            extra_data: Some(extra_data),
788        }
789    }
790}