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