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