#[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 {}
}
pub trait State: sealed::Sealed {
type Lang;
type File;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Lang = Unset;
type File = Unset;
}
pub struct SetLang<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLang<S> {}
impl<S: State> State for SetLang<S> {
type Lang = Set<members::lang>;
type File = S::File;
}
pub struct SetFile<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetFile<S> {}
impl<S: State> State for SetFile<S> {
type Lang = S::Lang;
type File = Set<members::file>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct lang(());
pub struct file(());
}
}
pub struct CaptionBuilder<'a, S: caption_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
::core::option::Option<jacquard_common::types::string::Language>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Caption<'a> {
pub fn new() -> CaptionBuilder<'a, caption_state::Empty> {
CaptionBuilder::new()
}
}
impl<'a> CaptionBuilder<'a, caption_state::Empty> {
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,
{
pub fn file(
mut self,
value: impl Into<jacquard_common::types::blob::BlobRef<'a>>,
) -> CaptionBuilder<'a, caption_state::SetFile<S>> {
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,
{
pub fn lang(
mut self,
value: impl Into<jacquard_common::types::string::Language>,
) -> CaptionBuilder<'a, caption_state::SetLang<S>> {
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::Lang: caption_state::IsSet,
S::File: caption_state::IsSet,
{
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(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::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::deps::smol_str::SmolStr::new_static("caption"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("lang"),
::jacquard_common::deps::smol_str::SmolStr::new_static("file")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::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::deps::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::deps::smol_str::SmolStr::new_static("main"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("videos")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::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::deps::smol_str::SmolStr::new_static("video"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("video")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::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::deps::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::deps::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::deps::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::deps::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::deps::smol_str::SmolStr::new_static("view"),
::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
description: None,
required: Some(
vec![
::jacquard_common::deps::smol_str::SmolStr::new_static("cid"),
::jacquard_common::deps::smol_str::SmolStr::new_static("playlist")
],
),
nullable: None,
properties: {
#[allow(unused_mut)]
let mut map = ::alloc::collections::BTreeMap::new();
map.insert(
::jacquard_common::deps::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::deps::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::deps::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::deps::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::deps::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::deps::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> {
{
let value = &self.file;
{
let size = value.blob().size;
if size > 20000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobTooLarge {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"file",
),
max: 20000usize,
actual: size,
});
}
}
}
{
let value = &self.file;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["text/vtt"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"file",
),
accepted: vec!["text/vtt".to_string()],
actual: mime.to_string(),
});
}
}
}
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<crate::sh_weaver::embed::video::Video<'a>>,
}
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 {}
}
pub trait State: sealed::Sealed {
type Videos;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Videos = Unset;
}
pub struct SetVideos<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetVideos<S> {}
impl<S: State> State for SetVideos<S> {
type Videos = Set<members::videos>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct videos(());
}
}
pub struct VideoRecordBuilder<'a, S: video_record_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<Vec<crate::sh_weaver::embed::video::Video<'a>>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> VideoRecord<'a> {
pub fn new() -> VideoRecordBuilder<'a, video_record_state::Empty> {
VideoRecordBuilder::new()
}
}
impl<'a> VideoRecordBuilder<'a, video_record_state::Empty> {
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,
{
pub fn videos(
mut self,
value: impl Into<Vec<crate::sh_weaver::embed::video::Video<'a>>>,
) -> VideoRecordBuilder<'a, video_record_state::SetVideos<S>> {
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,
{
pub fn build(self) -> VideoRecord<'a> {
VideoRecord {
videos: self.__unsafe_private_named.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::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> {
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub alt: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub captions: std::option::Option<Vec<crate::sh_weaver::embed::video::Caption<'a>>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub dimensions: std::option::Option<VideoDimensions<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub name: std::option::Option<jacquard_common::CowStr<'a>>,
#[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 {}
}
pub trait State: sealed::Sealed {
type Video;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Video = Unset;
}
pub struct SetVideo<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetVideo<S> {}
impl<S: State> State for SetVideo<S> {
type Video = Set<members::video>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct video(());
}
}
pub struct VideoBuilder<'a, S: video_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<Vec<crate::sh_weaver::embed::video::Caption<'a>>>,
::core::option::Option<VideoDimensions<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::blob::BlobRef<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> Video<'a> {
pub fn new() -> VideoBuilder<'a, video_state::Empty> {
VideoBuilder::new()
}
}
impl<'a> VideoBuilder<'a, video_state::Empty> {
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> {
pub fn alt(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S: video_state::State> VideoBuilder<'a, S> {
pub fn captions(
mut self,
value: impl Into<Option<Vec<crate::sh_weaver::embed::video::Caption<'a>>>>,
) -> Self {
self.__unsafe_private_named.1 = value.into();
self
}
pub fn maybe_captions(
mut self,
value: Option<Vec<crate::sh_weaver::embed::video::Caption<'a>>>,
) -> Self {
self.__unsafe_private_named.1 = value;
self
}
}
impl<'a, S: video_state::State> VideoBuilder<'a, S> {
pub fn dimensions(mut self, value: impl Into<Option<VideoDimensions<'a>>>) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_dimensions(mut self, value: Option<VideoDimensions<'a>>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: video_state::State> VideoBuilder<'a, S> {
pub fn name(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_name(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> VideoBuilder<'a, S>
where
S: video_state::State,
S::Video: video_state::IsUnset,
{
pub fn video(
mut self,
value: impl Into<jacquard_common::types::blob::BlobRef<'a>>,
) -> VideoBuilder<'a, video_state::SetVideo<S>> {
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,
{
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(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::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<crate::app_bsky::embed::AspectRatio<'a>>),
#[serde(rename = "sh.weaver.embed.defs#percentSize")]
PercentSize(Box<crate::sh_weaver::embed::PercentSize<'a>>),
#[serde(rename = "sh.weaver.embed.defs#pixelSize")]
PixelSize(Box<crate::sh_weaver::embed::PixelSize<'a>>),
}
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 <str>::len(value.as_ref()) > 10000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"alt",
),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.alt {
{
let count = jacquard_common::deps::codegen::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 <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"name",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.video;
{
let size = value.blob().size;
if size > 100000000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobTooLarge {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"video",
),
max: 100000000usize,
actual: size,
});
}
}
}
{
let value = &self.video;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["video/mp4"];
let matched = accepted
.iter()
.any(|pattern| {
if *pattern == "*/*" {
true
} else if pattern.ends_with("/*") {
let prefix = &pattern[..pattern.len() - 2];
mime.starts_with(prefix)
&& mime.as_bytes().get(prefix.len()) == Some(&b'/')
} else {
mime == *pattern
}
});
if !matched {
return Err(::jacquard_lexicon::validation::ConstraintError::BlobMimeTypeNotAccepted {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"video",
),
accepted: vec!["video/mp4".to_string()],
actual: mime.to_string(),
});
}
}
}
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<jacquard_common::CowStr<'a>>,
#[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<ViewDimensions<'a>>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub name: std::option::Option<jacquard_common::CowStr<'a>>,
#[serde(borrow)]
pub playlist: jacquard_common::types::string::UriValue<'a>,
#[serde(skip_serializing_if = "std::option::Option::is_none")]
#[serde(borrow)]
pub thumbnail: std::option::Option<jacquard_common::types::string::UriValue<'a>>,
}
pub mod view_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Playlist;
type Cid;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Playlist = Unset;
type Cid = Unset;
}
pub struct SetPlaylist<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetPlaylist<S> {}
impl<S: State> State for SetPlaylist<S> {
type Playlist = Set<members::playlist>;
type Cid = S::Cid;
}
pub struct SetCid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCid<S> {}
impl<S: State> State for SetCid<S> {
type Playlist = S::Playlist;
type Cid = Set<members::cid>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct playlist(());
pub struct cid(());
}
}
pub struct ViewBuilder<'a, S: view_state::State> {
_phantom_state: ::core::marker::PhantomData<fn() -> S>,
__unsafe_private_named: (
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::Cid<'a>>,
::core::option::Option<ViewDimensions<'a>>,
::core::option::Option<jacquard_common::CowStr<'a>>,
::core::option::Option<jacquard_common::types::string::UriValue<'a>>,
::core::option::Option<jacquard_common::types::string::UriValue<'a>>,
),
_phantom: ::core::marker::PhantomData<&'a ()>,
}
impl<'a> View<'a> {
pub fn new() -> ViewBuilder<'a, view_state::Empty> {
ViewBuilder::new()
}
}
impl<'a> ViewBuilder<'a, view_state::Empty> {
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> {
pub fn alt(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
self.__unsafe_private_named.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.0 = value;
self
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Cid: view_state::IsUnset,
{
pub fn cid(
mut self,
value: impl Into<jacquard_common::types::string::Cid<'a>>,
) -> ViewBuilder<'a, view_state::SetCid<S>> {
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> {
pub fn dimensions(mut self, value: impl Into<Option<ViewDimensions<'a>>>) -> Self {
self.__unsafe_private_named.2 = value.into();
self
}
pub fn maybe_dimensions(mut self, value: Option<ViewDimensions<'a>>) -> Self {
self.__unsafe_private_named.2 = value;
self
}
}
impl<'a, S: view_state::State> ViewBuilder<'a, S> {
pub fn name(
mut self,
value: impl Into<Option<jacquard_common::CowStr<'a>>>,
) -> Self {
self.__unsafe_private_named.3 = value.into();
self
}
pub fn maybe_name(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
self.__unsafe_private_named.3 = value;
self
}
}
impl<'a, S> ViewBuilder<'a, S>
where
S: view_state::State,
S::Playlist: view_state::IsUnset,
{
pub fn playlist(
mut self,
value: impl Into<jacquard_common::types::string::UriValue<'a>>,
) -> ViewBuilder<'a, view_state::SetPlaylist<S>> {
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> {
pub fn thumbnail(
mut self,
value: impl Into<Option<jacquard_common::types::string::UriValue<'a>>>,
) -> Self {
self.__unsafe_private_named.5 = value.into();
self
}
pub fn maybe_thumbnail(
mut self,
value: Option<jacquard_common::types::string::UriValue<'a>>,
) -> 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,
{
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(),
}
}
pub fn build_with_data(
self,
extra_data: std::collections::BTreeMap<
jacquard_common::deps::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<crate::app_bsky::embed::AspectRatio<'a>>),
#[serde(rename = "sh.weaver.embed.defs#percentSize")]
PercentSize(Box<crate::sh_weaver::embed::PercentSize<'a>>),
#[serde(rename = "sh.weaver.embed.defs#pixelSize")]
PixelSize(Box<crate::sh_weaver::embed::PixelSize<'a>>),
}
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 <str>::len(value.as_ref()) > 10000usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"alt",
),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.alt {
{
let count = jacquard_common::deps::codegen::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 <str>::len(value.as_ref()) > 128usize {
return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength {
path: ::jacquard_lexicon::validation::ValidationPath::from_field(
"name",
),
max: 128usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}