atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: app.bsky.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/// 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.
9#[jacquard_derive::lexicon]
10#[derive(
11 serde::Serialize,
12 serde::Deserialize,
13 Debug,
14 Clone,
15 PartialEq,
16 Eq,
17 jacquard_derive::IntoStatic
18)]
19#[serde(rename_all = "camelCase")]
20pub struct ByteSlice<'a> {
21 pub byte_end: i64,
22 pub byte_start: i64,
23}
24
25pub mod byte_slice_state {
26
27 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
28 #[allow(unused)]
29 use ::core::marker::PhantomData;
30 mod sealed {
31 pub trait Sealed {}
32 }
33 /// State trait tracking which required fields have been set
34 pub trait State: sealed::Sealed {
35 type ByteStart;
36 type ByteEnd;
37 }
38 /// Empty state - all required fields are unset
39 pub struct Empty(());
40 impl sealed::Sealed for Empty {}
41 impl State for Empty {
42 type ByteStart = Unset;
43 type ByteEnd = Unset;
44 }
45 ///State transition - sets the `byte_start` field to Set
46 pub struct SetByteStart<S: State = Empty>(PhantomData<fn() -> S>);
47 impl<S: State> sealed::Sealed for SetByteStart<S> {}
48 impl<S: State> State for SetByteStart<S> {
49 type ByteStart = Set<members::byte_start>;
50 type ByteEnd = S::ByteEnd;
51 }
52 ///State transition - sets the `byte_end` field to Set
53 pub struct SetByteEnd<S: State = Empty>(PhantomData<fn() -> S>);
54 impl<S: State> sealed::Sealed for SetByteEnd<S> {}
55 impl<S: State> State for SetByteEnd<S> {
56 type ByteStart = S::ByteStart;
57 type ByteEnd = Set<members::byte_end>;
58 }
59 /// Marker types for field names
60 #[allow(non_camel_case_types)]
61 pub mod members {
62 ///Marker type for the `byte_start` field
63 pub struct byte_start(());
64 ///Marker type for the `byte_end` field
65 pub struct byte_end(());
66 }
67}
68
69/// Builder for constructing an instance of this type
70pub struct ByteSliceBuilder<'a, S: byte_slice_state::State> {
71 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
72 __unsafe_private_named: (::core::option::Option<i64>, ::core::option::Option<i64>),
73 _phantom: ::core::marker::PhantomData<&'a ()>,
74}
75
76impl<'a> ByteSlice<'a> {
77 /// Create a new builder for this type
78 pub fn new() -> ByteSliceBuilder<'a, byte_slice_state::Empty> {
79 ByteSliceBuilder::new()
80 }
81}
82
83impl<'a> ByteSliceBuilder<'a, byte_slice_state::Empty> {
84 /// Create a new builder with all fields unset
85 pub fn new() -> Self {
86 ByteSliceBuilder {
87 _phantom_state: ::core::marker::PhantomData,
88 __unsafe_private_named: (None, None),
89 _phantom: ::core::marker::PhantomData,
90 }
91 }
92}
93
94impl<'a, S> ByteSliceBuilder<'a, S>
95where
96 S: byte_slice_state::State,
97 S::ByteEnd: byte_slice_state::IsUnset,
98{
99 /// Set the `byteEnd` field (required)
100 pub fn byte_end(
101 mut self,
102 value: impl Into<i64>,
103 ) -> ByteSliceBuilder<'a, byte_slice_state::SetByteEnd<S>> {
104 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
105 ByteSliceBuilder {
106 _phantom_state: ::core::marker::PhantomData,
107 __unsafe_private_named: self.__unsafe_private_named,
108 _phantom: ::core::marker::PhantomData,
109 }
110 }
111}
112
113impl<'a, S> ByteSliceBuilder<'a, S>
114where
115 S: byte_slice_state::State,
116 S::ByteStart: byte_slice_state::IsUnset,
117{
118 /// Set the `byteStart` field (required)
119 pub fn byte_start(
120 mut self,
121 value: impl Into<i64>,
122 ) -> ByteSliceBuilder<'a, byte_slice_state::SetByteStart<S>> {
123 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
124 ByteSliceBuilder {
125 _phantom_state: ::core::marker::PhantomData,
126 __unsafe_private_named: self.__unsafe_private_named,
127 _phantom: ::core::marker::PhantomData,
128 }
129 }
130}
131
132impl<'a, S> ByteSliceBuilder<'a, S>
133where
134 S: byte_slice_state::State,
135 S::ByteStart: byte_slice_state::IsSet,
136 S::ByteEnd: byte_slice_state::IsSet,
137{
138 /// Build the final struct
139 pub fn build(self) -> ByteSlice<'a> {
140 ByteSlice {
141 byte_end: self.__unsafe_private_named.0.unwrap(),
142 byte_start: self.__unsafe_private_named.1.unwrap(),
143 extra_data: Default::default(),
144 }
145 }
146 /// Build the final struct with custom extra_data
147 pub fn build_with_data(
148 self,
149 extra_data: std::collections::BTreeMap<
150 jacquard_common::smol_str::SmolStr,
151 jacquard_common::types::value::Data<'a>,
152 >,
153 ) -> ByteSlice<'a> {
154 ByteSlice {
155 byte_end: self.__unsafe_private_named.0.unwrap(),
156 byte_start: self.__unsafe_private_named.1.unwrap(),
157 extra_data: Some(extra_data),
158 }
159 }
160}
161
162fn lexicon_doc_app_bsky_richtext_facet() -> ::jacquard_lexicon::lexicon::LexiconDoc<
163 'static,
164> {
165 ::jacquard_lexicon::lexicon::LexiconDoc {
166 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
167 id: ::jacquard_common::CowStr::new_static("app.bsky.richtext.facet"),
168 revision: None,
169 description: None,
170 defs: {
171 let mut map = ::alloc::collections::BTreeMap::new();
172 map.insert(
173 ::jacquard_common::smol_str::SmolStr::new_static("byteSlice"),
174 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
175 description: Some(
176 ::jacquard_common::CowStr::new_static(
177 "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.",
178 ),
179 ),
180 required: Some(
181 vec![
182 ::jacquard_common::smol_str::SmolStr::new_static("byteStart"),
183 ::jacquard_common::smol_str::SmolStr::new_static("byteEnd")
184 ],
185 ),
186 nullable: None,
187 properties: {
188 #[allow(unused_mut)]
189 let mut map = ::alloc::collections::BTreeMap::new();
190 map.insert(
191 ::jacquard_common::smol_str::SmolStr::new_static("byteEnd"),
192 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
193 description: None,
194 default: None,
195 minimum: Some(0i64),
196 maximum: None,
197 r#enum: None,
198 r#const: None,
199 }),
200 );
201 map.insert(
202 ::jacquard_common::smol_str::SmolStr::new_static(
203 "byteStart",
204 ),
205 ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
206 description: None,
207 default: None,
208 minimum: Some(0i64),
209 maximum: None,
210 r#enum: None,
211 r#const: None,
212 }),
213 );
214 map
215 },
216 }),
217 );
218 map.insert(
219 ::jacquard_common::smol_str::SmolStr::new_static("link"),
220 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
221 description: Some(
222 ::jacquard_common::CowStr::new_static(
223 "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.",
224 ),
225 ),
226 required: Some(
227 vec![::jacquard_common::smol_str::SmolStr::new_static("uri")],
228 ),
229 nullable: None,
230 properties: {
231 #[allow(unused_mut)]
232 let mut map = ::alloc::collections::BTreeMap::new();
233 map.insert(
234 ::jacquard_common::smol_str::SmolStr::new_static("uri"),
235 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
236 description: None,
237 format: Some(
238 ::jacquard_lexicon::lexicon::LexStringFormat::Uri,
239 ),
240 default: None,
241 min_length: None,
242 max_length: None,
243 min_graphemes: None,
244 max_graphemes: None,
245 r#enum: None,
246 r#const: None,
247 known_values: None,
248 }),
249 );
250 map
251 },
252 }),
253 );
254 map.insert(
255 ::jacquard_common::smol_str::SmolStr::new_static("main"),
256 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
257 description: Some(
258 ::jacquard_common::CowStr::new_static(
259 "Annotation of a sub-string within rich text.",
260 ),
261 ),
262 required: Some(
263 vec![
264 ::jacquard_common::smol_str::SmolStr::new_static("index"),
265 ::jacquard_common::smol_str::SmolStr::new_static("features")
266 ],
267 ),
268 nullable: None,
269 properties: {
270 #[allow(unused_mut)]
271 let mut map = ::alloc::collections::BTreeMap::new();
272 map.insert(
273 ::jacquard_common::smol_str::SmolStr::new_static("features"),
274 ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray {
275 description: None,
276 items: ::jacquard_lexicon::lexicon::LexArrayItem::Union(::jacquard_lexicon::lexicon::LexRefUnion {
277 description: None,
278 refs: vec![
279 ::jacquard_common::CowStr::new_static("#mention"),
280 ::jacquard_common::CowStr::new_static("#link"),
281 ::jacquard_common::CowStr::new_static("#tag")
282 ],
283 closed: None,
284 }),
285 min_length: None,
286 max_length: None,
287 }),
288 );
289 map.insert(
290 ::jacquard_common::smol_str::SmolStr::new_static("index"),
291 ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef {
292 description: None,
293 r#ref: ::jacquard_common::CowStr::new_static("#byteSlice"),
294 }),
295 );
296 map
297 },
298 }),
299 );
300 map.insert(
301 ::jacquard_common::smol_str::SmolStr::new_static("mention"),
302 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
303 description: Some(
304 ::jacquard_common::CowStr::new_static(
305 "Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.",
306 ),
307 ),
308 required: Some(
309 vec![::jacquard_common::smol_str::SmolStr::new_static("did")],
310 ),
311 nullable: None,
312 properties: {
313 #[allow(unused_mut)]
314 let mut map = ::alloc::collections::BTreeMap::new();
315 map.insert(
316 ::jacquard_common::smol_str::SmolStr::new_static("did"),
317 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
318 description: None,
319 format: Some(
320 ::jacquard_lexicon::lexicon::LexStringFormat::Did,
321 ),
322 default: None,
323 min_length: None,
324 max_length: None,
325 min_graphemes: None,
326 max_graphemes: None,
327 r#enum: None,
328 r#const: None,
329 known_values: None,
330 }),
331 );
332 map
333 },
334 }),
335 );
336 map.insert(
337 ::jacquard_common::smol_str::SmolStr::new_static("tag"),
338 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
339 description: Some(
340 ::jacquard_common::CowStr::new_static(
341 "Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').",
342 ),
343 ),
344 required: Some(
345 vec![::jacquard_common::smol_str::SmolStr::new_static("tag")],
346 ),
347 nullable: None,
348 properties: {
349 #[allow(unused_mut)]
350 let mut map = ::alloc::collections::BTreeMap::new();
351 map.insert(
352 ::jacquard_common::smol_str::SmolStr::new_static("tag"),
353 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
354 description: None,
355 format: None,
356 default: None,
357 min_length: None,
358 max_length: Some(640usize),
359 min_graphemes: None,
360 max_graphemes: Some(64usize),
361 r#enum: None,
362 r#const: None,
363 known_values: None,
364 }),
365 );
366 map
367 },
368 }),
369 );
370 map
371 },
372 }
373}
374
375impl<'a> ::jacquard_lexicon::schema::LexiconSchema for ByteSlice<'a> {
376 fn nsid() -> &'static str {
377 "app.bsky.richtext.facet"
378 }
379 fn def_name() -> &'static str {
380 "byteSlice"
381 }
382 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
383 lexicon_doc_app_bsky_richtext_facet()
384 }
385 fn validate(
386 &self,
387 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
388 {
389 let value = &self.byte_end;
390 if *value < 0i64 {
391 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
392 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
393 "byte_end",
394 ),
395 min: 0i64,
396 actual: *value,
397 });
398 }
399 }
400 {
401 let value = &self.byte_start;
402 if *value < 0i64 {
403 return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
404 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
405 "byte_start",
406 ),
407 min: 0i64,
408 actual: *value,
409 });
410 }
411 }
412 Ok(())
413 }
414}
415
416/// Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.
417#[jacquard_derive::lexicon]
418#[derive(
419 serde::Serialize,
420 serde::Deserialize,
421 Debug,
422 Clone,
423 PartialEq,
424 Eq,
425 jacquard_derive::IntoStatic
426)]
427#[serde(rename_all = "camelCase")]
428pub struct Link<'a> {
429 #[serde(borrow)]
430 pub uri: jacquard_common::types::string::Uri<'a>,
431}
432
433pub mod link_state {
434
435 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
436 #[allow(unused)]
437 use ::core::marker::PhantomData;
438 mod sealed {
439 pub trait Sealed {}
440 }
441 /// State trait tracking which required fields have been set
442 pub trait State: sealed::Sealed {
443 type Uri;
444 }
445 /// Empty state - all required fields are unset
446 pub struct Empty(());
447 impl sealed::Sealed for Empty {}
448 impl State for Empty {
449 type Uri = Unset;
450 }
451 ///State transition - sets the `uri` field to Set
452 pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
453 impl<S: State> sealed::Sealed for SetUri<S> {}
454 impl<S: State> State for SetUri<S> {
455 type Uri = Set<members::uri>;
456 }
457 /// Marker types for field names
458 #[allow(non_camel_case_types)]
459 pub mod members {
460 ///Marker type for the `uri` field
461 pub struct uri(());
462 }
463}
464
465/// Builder for constructing an instance of this type
466pub struct LinkBuilder<'a, S: link_state::State> {
467 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
468 __unsafe_private_named: (
469 ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
470 ),
471 _phantom: ::core::marker::PhantomData<&'a ()>,
472}
473
474impl<'a> Link<'a> {
475 /// Create a new builder for this type
476 pub fn new() -> LinkBuilder<'a, link_state::Empty> {
477 LinkBuilder::new()
478 }
479}
480
481impl<'a> LinkBuilder<'a, link_state::Empty> {
482 /// Create a new builder with all fields unset
483 pub fn new() -> Self {
484 LinkBuilder {
485 _phantom_state: ::core::marker::PhantomData,
486 __unsafe_private_named: (None,),
487 _phantom: ::core::marker::PhantomData,
488 }
489 }
490}
491
492impl<'a, S> LinkBuilder<'a, S>
493where
494 S: link_state::State,
495 S::Uri: link_state::IsUnset,
496{
497 /// Set the `uri` field (required)
498 pub fn uri(
499 mut self,
500 value: impl Into<jacquard_common::types::string::Uri<'a>>,
501 ) -> LinkBuilder<'a, link_state::SetUri<S>> {
502 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
503 LinkBuilder {
504 _phantom_state: ::core::marker::PhantomData,
505 __unsafe_private_named: self.__unsafe_private_named,
506 _phantom: ::core::marker::PhantomData,
507 }
508 }
509}
510
511impl<'a, S> LinkBuilder<'a, S>
512where
513 S: link_state::State,
514 S::Uri: link_state::IsSet,
515{
516 /// Build the final struct
517 pub fn build(self) -> Link<'a> {
518 Link {
519 uri: self.__unsafe_private_named.0.unwrap(),
520 extra_data: Default::default(),
521 }
522 }
523 /// Build the final struct with custom extra_data
524 pub fn build_with_data(
525 self,
526 extra_data: std::collections::BTreeMap<
527 jacquard_common::smol_str::SmolStr,
528 jacquard_common::types::value::Data<'a>,
529 >,
530 ) -> Link<'a> {
531 Link {
532 uri: self.__unsafe_private_named.0.unwrap(),
533 extra_data: Some(extra_data),
534 }
535 }
536}
537
538impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Link<'a> {
539 fn nsid() -> &'static str {
540 "app.bsky.richtext.facet"
541 }
542 fn def_name() -> &'static str {
543 "link"
544 }
545 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
546 lexicon_doc_app_bsky_richtext_facet()
547 }
548 fn validate(
549 &self,
550 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
551 Ok(())
552 }
553}
554
555/// Annotation of a sub-string within rich text.
556#[jacquard_derive::lexicon]
557#[derive(
558 serde::Serialize,
559 serde::Deserialize,
560 Debug,
561 Clone,
562 PartialEq,
563 Eq,
564 jacquard_derive::IntoStatic
565)]
566#[serde(rename_all = "camelCase")]
567pub struct Facet<'a> {
568 #[serde(borrow)]
569 pub features: Vec<FacetFeaturesItem<'a>>,
570 #[serde(borrow)]
571 pub index: crate::app_bsky::richtext::facet::ByteSlice<'a>,
572}
573
574pub mod facet_state {
575
576 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
577 #[allow(unused)]
578 use ::core::marker::PhantomData;
579 mod sealed {
580 pub trait Sealed {}
581 }
582 /// State trait tracking which required fields have been set
583 pub trait State: sealed::Sealed {
584 type Index;
585 type Features;
586 }
587 /// Empty state - all required fields are unset
588 pub struct Empty(());
589 impl sealed::Sealed for Empty {}
590 impl State for Empty {
591 type Index = Unset;
592 type Features = Unset;
593 }
594 ///State transition - sets the `index` field to Set
595 pub struct SetIndex<S: State = Empty>(PhantomData<fn() -> S>);
596 impl<S: State> sealed::Sealed for SetIndex<S> {}
597 impl<S: State> State for SetIndex<S> {
598 type Index = Set<members::index>;
599 type Features = S::Features;
600 }
601 ///State transition - sets the `features` field to Set
602 pub struct SetFeatures<S: State = Empty>(PhantomData<fn() -> S>);
603 impl<S: State> sealed::Sealed for SetFeatures<S> {}
604 impl<S: State> State for SetFeatures<S> {
605 type Index = S::Index;
606 type Features = Set<members::features>;
607 }
608 /// Marker types for field names
609 #[allow(non_camel_case_types)]
610 pub mod members {
611 ///Marker type for the `index` field
612 pub struct index(());
613 ///Marker type for the `features` field
614 pub struct features(());
615 }
616}
617
618/// Builder for constructing an instance of this type
619pub struct FacetBuilder<'a, S: facet_state::State> {
620 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
621 __unsafe_private_named: (
622 ::core::option::Option<Vec<FacetFeaturesItem<'a>>>,
623 ::core::option::Option<crate::app_bsky::richtext::facet::ByteSlice<'a>>,
624 ),
625 _phantom: ::core::marker::PhantomData<&'a ()>,
626}
627
628impl<'a> Facet<'a> {
629 /// Create a new builder for this type
630 pub fn new() -> FacetBuilder<'a, facet_state::Empty> {
631 FacetBuilder::new()
632 }
633}
634
635impl<'a> FacetBuilder<'a, facet_state::Empty> {
636 /// Create a new builder with all fields unset
637 pub fn new() -> Self {
638 FacetBuilder {
639 _phantom_state: ::core::marker::PhantomData,
640 __unsafe_private_named: (None, None),
641 _phantom: ::core::marker::PhantomData,
642 }
643 }
644}
645
646impl<'a, S> FacetBuilder<'a, S>
647where
648 S: facet_state::State,
649 S::Features: facet_state::IsUnset,
650{
651 /// Set the `features` field (required)
652 pub fn features(
653 mut self,
654 value: impl Into<Vec<FacetFeaturesItem<'a>>>,
655 ) -> FacetBuilder<'a, facet_state::SetFeatures<S>> {
656 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
657 FacetBuilder {
658 _phantom_state: ::core::marker::PhantomData,
659 __unsafe_private_named: self.__unsafe_private_named,
660 _phantom: ::core::marker::PhantomData,
661 }
662 }
663}
664
665impl<'a, S> FacetBuilder<'a, S>
666where
667 S: facet_state::State,
668 S::Index: facet_state::IsUnset,
669{
670 /// Set the `index` field (required)
671 pub fn index(
672 mut self,
673 value: impl Into<crate::app_bsky::richtext::facet::ByteSlice<'a>>,
674 ) -> FacetBuilder<'a, facet_state::SetIndex<S>> {
675 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
676 FacetBuilder {
677 _phantom_state: ::core::marker::PhantomData,
678 __unsafe_private_named: self.__unsafe_private_named,
679 _phantom: ::core::marker::PhantomData,
680 }
681 }
682}
683
684impl<'a, S> FacetBuilder<'a, S>
685where
686 S: facet_state::State,
687 S::Index: facet_state::IsSet,
688 S::Features: facet_state::IsSet,
689{
690 /// Build the final struct
691 pub fn build(self) -> Facet<'a> {
692 Facet {
693 features: self.__unsafe_private_named.0.unwrap(),
694 index: self.__unsafe_private_named.1.unwrap(),
695 extra_data: Default::default(),
696 }
697 }
698 /// Build the final struct with custom extra_data
699 pub fn build_with_data(
700 self,
701 extra_data: std::collections::BTreeMap<
702 jacquard_common::smol_str::SmolStr,
703 jacquard_common::types::value::Data<'a>,
704 >,
705 ) -> Facet<'a> {
706 Facet {
707 features: self.__unsafe_private_named.0.unwrap(),
708 index: self.__unsafe_private_named.1.unwrap(),
709 extra_data: Some(extra_data),
710 }
711 }
712}
713
714#[jacquard_derive::open_union]
715#[derive(
716 serde::Serialize,
717 serde::Deserialize,
718 Debug,
719 Clone,
720 PartialEq,
721 Eq,
722 jacquard_derive::IntoStatic
723)]
724#[serde(tag = "$type")]
725#[serde(bound(deserialize = "'de: 'a"))]
726pub enum FacetFeaturesItem<'a> {
727 #[serde(rename = "app.bsky.richtext.facet#mention")]
728 Mention(Box<crate::app_bsky::richtext::facet::Mention<'a>>),
729 #[serde(rename = "app.bsky.richtext.facet#link")]
730 Link(Box<crate::app_bsky::richtext::facet::Link<'a>>),
731 #[serde(rename = "app.bsky.richtext.facet#tag")]
732 Tag(Box<crate::app_bsky::richtext::facet::Tag<'a>>),
733}
734
735impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Facet<'a> {
736 fn nsid() -> &'static str {
737 "app.bsky.richtext.facet"
738 }
739 fn def_name() -> &'static str {
740 "main"
741 }
742 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
743 lexicon_doc_app_bsky_richtext_facet()
744 }
745 fn validate(
746 &self,
747 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
748 Ok(())
749 }
750}
751
752/// Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.
753#[jacquard_derive::lexicon]
754#[derive(
755 serde::Serialize,
756 serde::Deserialize,
757 Debug,
758 Clone,
759 PartialEq,
760 Eq,
761 jacquard_derive::IntoStatic
762)]
763#[serde(rename_all = "camelCase")]
764pub struct Mention<'a> {
765 #[serde(borrow)]
766 pub did: jacquard_common::types::string::Did<'a>,
767}
768
769pub mod mention_state {
770
771 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
772 #[allow(unused)]
773 use ::core::marker::PhantomData;
774 mod sealed {
775 pub trait Sealed {}
776 }
777 /// State trait tracking which required fields have been set
778 pub trait State: sealed::Sealed {
779 type Did;
780 }
781 /// Empty state - all required fields are unset
782 pub struct Empty(());
783 impl sealed::Sealed for Empty {}
784 impl State for Empty {
785 type Did = Unset;
786 }
787 ///State transition - sets the `did` field to Set
788 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
789 impl<S: State> sealed::Sealed for SetDid<S> {}
790 impl<S: State> State for SetDid<S> {
791 type Did = Set<members::did>;
792 }
793 /// Marker types for field names
794 #[allow(non_camel_case_types)]
795 pub mod members {
796 ///Marker type for the `did` field
797 pub struct did(());
798 }
799}
800
801/// Builder for constructing an instance of this type
802pub struct MentionBuilder<'a, S: mention_state::State> {
803 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
804 __unsafe_private_named: (
805 ::core::option::Option<jacquard_common::types::string::Did<'a>>,
806 ),
807 _phantom: ::core::marker::PhantomData<&'a ()>,
808}
809
810impl<'a> Mention<'a> {
811 /// Create a new builder for this type
812 pub fn new() -> MentionBuilder<'a, mention_state::Empty> {
813 MentionBuilder::new()
814 }
815}
816
817impl<'a> MentionBuilder<'a, mention_state::Empty> {
818 /// Create a new builder with all fields unset
819 pub fn new() -> Self {
820 MentionBuilder {
821 _phantom_state: ::core::marker::PhantomData,
822 __unsafe_private_named: (None,),
823 _phantom: ::core::marker::PhantomData,
824 }
825 }
826}
827
828impl<'a, S> MentionBuilder<'a, S>
829where
830 S: mention_state::State,
831 S::Did: mention_state::IsUnset,
832{
833 /// Set the `did` field (required)
834 pub fn did(
835 mut self,
836 value: impl Into<jacquard_common::types::string::Did<'a>>,
837 ) -> MentionBuilder<'a, mention_state::SetDid<S>> {
838 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
839 MentionBuilder {
840 _phantom_state: ::core::marker::PhantomData,
841 __unsafe_private_named: self.__unsafe_private_named,
842 _phantom: ::core::marker::PhantomData,
843 }
844 }
845}
846
847impl<'a, S> MentionBuilder<'a, S>
848where
849 S: mention_state::State,
850 S::Did: mention_state::IsSet,
851{
852 /// Build the final struct
853 pub fn build(self) -> Mention<'a> {
854 Mention {
855 did: self.__unsafe_private_named.0.unwrap(),
856 extra_data: Default::default(),
857 }
858 }
859 /// Build the final struct with custom extra_data
860 pub fn build_with_data(
861 self,
862 extra_data: std::collections::BTreeMap<
863 jacquard_common::smol_str::SmolStr,
864 jacquard_common::types::value::Data<'a>,
865 >,
866 ) -> Mention<'a> {
867 Mention {
868 did: self.__unsafe_private_named.0.unwrap(),
869 extra_data: Some(extra_data),
870 }
871 }
872}
873
874impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Mention<'a> {
875 fn nsid() -> &'static str {
876 "app.bsky.richtext.facet"
877 }
878 fn def_name() -> &'static str {
879 "mention"
880 }
881 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
882 lexicon_doc_app_bsky_richtext_facet()
883 }
884 fn validate(
885 &self,
886 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
887 Ok(())
888 }
889}
890
891/// Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').
892#[jacquard_derive::lexicon]
893#[derive(
894 serde::Serialize,
895 serde::Deserialize,
896 Debug,
897 Clone,
898 PartialEq,
899 Eq,
900 jacquard_derive::IntoStatic,
901 Default
902)]
903#[serde(rename_all = "camelCase")]
904pub struct Tag<'a> {
905 #[serde(borrow)]
906 pub tag: jacquard_common::CowStr<'a>,
907}
908
909impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Tag<'a> {
910 fn nsid() -> &'static str {
911 "app.bsky.richtext.facet"
912 }
913 fn def_name() -> &'static str {
914 "tag"
915 }
916 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
917 lexicon_doc_app_bsky_richtext_facet()
918 }
919 fn validate(
920 &self,
921 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
922 {
923 let value = &self.tag;
924 #[allow(unused_comparisons)]
925 if <str>::len(value.as_ref()) > 640usize {
926 return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
927 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
928 "tag",
929 ),
930 max: 640usize,
931 actual: <str>::len(value.as_ref()),
932 });
933 }
934 }
935 {
936 let value = &self.tag;
937 {
938 let count = ::unicode_segmentation::UnicodeSegmentation::graphemes(
939 value.as_ref(),
940 true,
941 )
942 .count();
943 if count > 64usize {
944 return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes {
945 path: ::jacquard_lexicon::validation::ValidationPath::from_field(
946 "tag",
947 ),
948 max: 64usize,
949 actual: count,
950 });
951 }
952 }
953 }
954 Ok(())
955 }
956}