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