// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: sh.weaver.embed.video // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Caption<'a> { #[serde(borrow)] pub file: jacquard_common::types::blob::BlobRef<'a>, pub lang: jacquard_common::types::string::Language, } pub mod caption_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type File; type Lang; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type File = Unset; type Lang = Unset; } ///State transition - sets the `file` field to Set pub struct SetFile(PhantomData S>); impl sealed::Sealed for SetFile {} impl State for SetFile { type File = Set; type Lang = S::Lang; } ///State transition - sets the `lang` field to Set pub struct SetLang(PhantomData S>); impl sealed::Sealed for SetLang {} impl State for SetLang { type File = S::File; type Lang = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `file` field pub struct file(()); ///Marker type for the `lang` field pub struct lang(()); } } /// Builder for constructing an instance of this type pub struct CaptionBuilder<'a, S: caption_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Caption<'a> { /// Create a new builder for this type pub fn new() -> CaptionBuilder<'a, caption_state::Empty> { CaptionBuilder::new() } } impl<'a> CaptionBuilder<'a, caption_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { CaptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> CaptionBuilder<'a, S> where S: caption_state::State, S::File: caption_state::IsUnset, { /// Set the `file` field (required) pub fn file( mut self, value: impl Into>, ) -> CaptionBuilder<'a, caption_state::SetFile> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); CaptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> CaptionBuilder<'a, S> where S: caption_state::State, S::Lang: caption_state::IsUnset, { /// Set the `lang` field (required) pub fn lang( mut self, value: impl Into, ) -> CaptionBuilder<'a, caption_state::SetLang> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); CaptionBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> CaptionBuilder<'a, S> where S: caption_state::State, S::File: caption_state::IsSet, S::Lang: caption_state::IsSet, { /// Build the final struct pub fn build(self) -> Caption<'a> { Caption { file: self.__unsafe_private_named.0.unwrap(), lang: self.__unsafe_private_named.1.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Caption<'a> { Caption { file: self.__unsafe_private_named.0.unwrap(), lang: self.__unsafe_private_named.1.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_sh_weaver_embed_video() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("sh.weaver.embed.video"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("caption"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("lang"), ::jacquard_common::smol_str::SmolStr::new_static("file") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("file"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("lang"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Language, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![::jacquard_common::smol_str::SmolStr::new_static("videos")], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("videos"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#video"), }), min_length: None, max_length: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("video"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![::jacquard_common::smol_str::SmolStr::new_static("video")], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("alt"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: Some( ::jacquard_common::CowStr::new_static( "Alt text description of the video, for accessibility.", ), ), format: None, default: None, min_length: None, max_length: Some(10000usize), min_graphemes: None, max_graphemes: Some(1000usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("captions"), ::jacquard_lexicon::lexicon::LexObjectProperty::Array(::jacquard_lexicon::lexicon::LexArray { description: None, items: ::jacquard_lexicon::lexicon::LexArrayItem::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#caption"), }), min_length: None, max_length: Some(20usize), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "dimensions", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("app.bsky.embed.defs#aspectRatio"), ::jacquard_common::CowStr::new_static("sh.weaver.embed.defs#percentSize"), ::jacquard_common::CowStr::new_static("sh.weaver.embed.defs#pixelSize") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(128usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("video"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("view"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("cid"), ::jacquard_common::smol_str::SmolStr::new_static("playlist") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("alt"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(10000usize), min_graphemes: None, max_graphemes: Some(1000usize), r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("cid"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Cid, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "dimensions", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("app.bsky.embed.defs#aspectRatio"), ::jacquard_common::CowStr::new_static("sh.weaver.embed.defs#percentSize"), ::jacquard_common::CowStr::new_static("sh.weaver.embed.defs#pixelSize") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(128usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("playlist"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Uri, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "thumbnail", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: Some( ::jacquard_lexicon::lexicon::LexStringFormat::Uri, ), default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map }, }), ); map }, } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Caption<'a> { fn nsid() -> &'static str { "sh.weaver.embed.video" } fn def_name() -> &'static str { "caption" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_embed_video() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct VideoRecord<'a> { #[serde(borrow)] pub videos: Vec>, } pub mod video_record_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Videos; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Videos = Unset; } ///State transition - sets the `videos` field to Set pub struct SetVideos(PhantomData S>); impl sealed::Sealed for SetVideos {} impl State for SetVideos { type Videos = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `videos` field pub struct videos(()); } } /// Builder for constructing an instance of this type pub struct VideoRecordBuilder<'a, S: video_record_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> VideoRecord<'a> { /// Create a new builder for this type pub fn new() -> VideoRecordBuilder<'a, video_record_state::Empty> { VideoRecordBuilder::new() } } impl<'a> VideoRecordBuilder<'a, video_record_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { VideoRecordBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None,), _phantom: ::core::marker::PhantomData, } } } impl<'a, S> VideoRecordBuilder<'a, S> where S: video_record_state::State, S::Videos: video_record_state::IsUnset, { /// Set the `videos` field (required) pub fn videos( mut self, value: impl Into>>, ) -> VideoRecordBuilder<'a, video_record_state::SetVideos> { self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); VideoRecordBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> VideoRecordBuilder<'a, S> where S: video_record_state::State, S::Videos: video_record_state::IsSet, { /// Build the final struct pub fn build(self) -> VideoRecord<'a> { VideoRecord { videos: self.__unsafe_private_named.0.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> VideoRecord<'a> { VideoRecord { videos: self.__unsafe_private_named.0.unwrap(), extra_data: Some(extra_data), } } } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for VideoRecord<'a> { fn nsid() -> &'static str { "sh.weaver.embed.video" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_embed_video() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Video<'a> { /// Alt text description of the video, for accessibility. #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub alt: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub captions: std::option::Option>>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub dimensions: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub name: std::option::Option>, /// The mp4 video file. May be up to 100mb, formerly limited to 50mb. #[serde(borrow)] pub video: jacquard_common::types::blob::BlobRef<'a>, } pub mod video_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Video; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Video = Unset; } ///State transition - sets the `video` field to Set pub struct SetVideo(PhantomData S>); impl sealed::Sealed for SetVideo {} impl State for SetVideo { type Video = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `video` field pub struct video(()); } } /// Builder for constructing an instance of this type pub struct VideoBuilder<'a, S: video_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Video<'a> { /// Create a new builder for this type pub fn new() -> VideoBuilder<'a, video_state::Empty> { VideoBuilder::new() } } impl<'a> VideoBuilder<'a, video_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { VideoBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: video_state::State> VideoBuilder<'a, S> { /// Set the `alt` field (optional) pub fn alt(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `alt` field to an Option value (optional) pub fn maybe_alt(mut self, value: Option>) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S: video_state::State> VideoBuilder<'a, S> { /// Set the `captions` field (optional) pub fn captions( mut self, value: impl Into>>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `captions` field to an Option value (optional) pub fn maybe_captions( mut self, value: Option>>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: video_state::State> VideoBuilder<'a, S> { /// Set the `dimensions` field (optional) pub fn dimensions(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `dimensions` field to an Option value (optional) pub fn maybe_dimensions(mut self, value: Option>) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S: video_state::State> VideoBuilder<'a, S> { /// Set the `name` field (optional) pub fn name( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `name` field to an Option value (optional) pub fn maybe_name(mut self, value: Option>) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S> VideoBuilder<'a, S> where S: video_state::State, S::Video: video_state::IsUnset, { /// Set the `video` field (required) pub fn video( mut self, value: impl Into>, ) -> VideoBuilder<'a, video_state::SetVideo> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); VideoBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S> VideoBuilder<'a, S> where S: video_state::State, S::Video: video_state::IsSet, { /// Build the final struct pub fn build(self) -> Video<'a> { Video { alt: self.__unsafe_private_named.0, captions: self.__unsafe_private_named.1, dimensions: self.__unsafe_private_named.2, name: self.__unsafe_private_named.3, video: self.__unsafe_private_named.4.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Video<'a> { Video { alt: self.__unsafe_private_named.0, captions: self.__unsafe_private_named.1, dimensions: self.__unsafe_private_named.2, name: self.__unsafe_private_named.3, video: self.__unsafe_private_named.4.unwrap(), extra_data: Some(extra_data), } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum VideoDimensions<'a> { #[serde(rename = "app.bsky.embed.defs#aspectRatio")] AspectRatio(Box>), #[serde(rename = "sh.weaver.embed.defs#percentSize")] PercentSize(Box>), #[serde(rename = "sh.weaver.embed.defs#pixelSize")] PixelSize(Box>), } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Video<'a> { fn nsid() -> &'static str { "sh.weaver.embed.video" } fn def_name() -> &'static str { "video" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_embed_video() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.alt { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "alt", ), max: 10000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.alt { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 1000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "alt", ), max: 1000usize, actual: count, }); } } } if let Some(ref value) = self.captions { #[allow(unused_comparisons)] if value.len() > 20usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "captions", ), max: 20usize, actual: value.len(), }); } } if let Some(ref value) = self.name { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 128usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), max: 128usize, actual: ::len(value.as_ref()), }); } } Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct View<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub alt: std::option::Option>, #[serde(borrow)] pub cid: jacquard_common::types::string::Cid<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub dimensions: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub name: std::option::Option>, #[serde(borrow)] pub playlist: jacquard_common::types::string::Uri<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub thumbnail: std::option::Option>, } pub mod view_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Playlist; type Cid; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Playlist = Unset; type Cid = Unset; } ///State transition - sets the `playlist` field to Set pub struct SetPlaylist(PhantomData S>); impl sealed::Sealed for SetPlaylist {} impl State for SetPlaylist { type Playlist = Set; type Cid = S::Cid; } ///State transition - sets the `cid` field to Set pub struct SetCid(PhantomData S>); impl sealed::Sealed for SetCid {} impl State for SetCid { type Playlist = S::Playlist; type Cid = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `playlist` field pub struct playlist(()); ///Marker type for the `cid` field pub struct cid(()); } } /// Builder for constructing an instance of this type pub struct ViewBuilder<'a, S: view_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> View<'a> { /// Create a new builder for this type pub fn new() -> ViewBuilder<'a, view_state::Empty> { ViewBuilder::new() } } impl<'a> ViewBuilder<'a, view_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { ViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: view_state::State> ViewBuilder<'a, S> { /// Set the `alt` field (optional) pub fn alt(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `alt` field to an Option value (optional) pub fn maybe_alt(mut self, value: Option>) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S> ViewBuilder<'a, S> where S: view_state::State, S::Cid: view_state::IsUnset, { /// Set the `cid` field (required) pub fn cid( mut self, value: impl Into>, ) -> ViewBuilder<'a, view_state::SetCid> { self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); ViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: view_state::State> ViewBuilder<'a, S> { /// Set the `dimensions` field (optional) pub fn dimensions(mut self, value: impl Into>>) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `dimensions` field to an Option value (optional) pub fn maybe_dimensions(mut self, value: Option>) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S: view_state::State> ViewBuilder<'a, S> { /// Set the `name` field (optional) pub fn name( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.3 = value.into(); self } /// Set the `name` field to an Option value (optional) pub fn maybe_name(mut self, value: Option>) -> Self { self.__unsafe_private_named.3 = value; self } } impl<'a, S> ViewBuilder<'a, S> where S: view_state::State, S::Playlist: view_state::IsUnset, { /// Set the `playlist` field (required) pub fn playlist( mut self, value: impl Into>, ) -> ViewBuilder<'a, view_state::SetPlaylist> { self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into()); ViewBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: view_state::State> ViewBuilder<'a, S> { /// Set the `thumbnail` field (optional) pub fn thumbnail( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `thumbnail` field to an Option value (optional) pub fn maybe_thumbnail( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S> ViewBuilder<'a, S> where S: view_state::State, S::Playlist: view_state::IsSet, S::Cid: view_state::IsSet, { /// Build the final struct pub fn build(self) -> View<'a> { View { alt: self.__unsafe_private_named.0, cid: self.__unsafe_private_named.1.unwrap(), dimensions: self.__unsafe_private_named.2, name: self.__unsafe_private_named.3, playlist: self.__unsafe_private_named.4.unwrap(), thumbnail: self.__unsafe_private_named.5, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> View<'a> { View { alt: self.__unsafe_private_named.0, cid: self.__unsafe_private_named.1.unwrap(), dimensions: self.__unsafe_private_named.2, name: self.__unsafe_private_named.3, playlist: self.__unsafe_private_named.4.unwrap(), thumbnail: self.__unsafe_private_named.5, extra_data: Some(extra_data), } } } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum ViewDimensions<'a> { #[serde(rename = "app.bsky.embed.defs#aspectRatio")] AspectRatio(Box>), #[serde(rename = "sh.weaver.embed.defs#percentSize")] PercentSize(Box>), #[serde(rename = "sh.weaver.embed.defs#pixelSize")] PixelSize(Box>), } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for View<'a> { fn nsid() -> &'static str { "sh.weaver.embed.video" } fn def_name() -> &'static str { "view" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_sh_weaver_embed_video() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.alt { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "alt", ), max: 10000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.alt { { let count = ::unicode_segmentation::UnicodeSegmentation::graphemes( value.as_ref(), true, ) .count(); if count > 1000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxGraphemes { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "alt", ), max: 1000usize, actual: count, }); } } } if let Some(ref value) = self.name { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 128usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), max: 128usize, actual: ::len(value.as_ref()), }); } } Ok(()) } }