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