#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_protoimsg::chat::message;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct AspectRatio<'a> {
pub height: i64,
pub width: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Blockquote<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Bold<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ByteSlice<'a> {
pub byte_end: i64,
pub byte_start: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CodeBlock<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub lang: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CodeInline<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ExternalEmbed<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub description: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub thumb: Option<BlobRef<'a>>,
#[serde(borrow)]
pub title: CowStr<'a>,
#[serde(borrow)]
pub uri: UriValue<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ImageEmbed<'a> {
#[serde(borrow)]
pub images: Vec<message::ImageItem<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ImageItem<'a> {
#[serde(borrow)]
pub alt: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub aspect_ratio: Option<message::AspectRatio<'a>>,
#[serde(borrow)]
pub image: BlobRef<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Italic<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Link<'a> {
#[serde(borrow)]
pub uri: UriValue<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", rename = "app.protoimsg.chat.message", tag = "$type")]
pub struct Message<'a> {
#[serde(borrow)]
pub channel: AtUri<'a>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub embed: Option<MessageEmbed<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub facets: Option<Vec<message::RichTextFacet<'a>>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub reply: Option<message::ReplyRef<'a>>,
#[serde(borrow)]
pub text: CowStr<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum MessageEmbed<'a> {
#[serde(rename = "app.protoimsg.chat.message#imageEmbed")]
ImageEmbed(Box<message::ImageEmbed<'a>>),
#[serde(rename = "app.protoimsg.chat.message#videoEmbed")]
VideoEmbed(Box<message::VideoEmbed<'a>>),
#[serde(rename = "app.protoimsg.chat.message#externalEmbed")]
ExternalEmbed(Box<message::ExternalEmbed<'a>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MessageGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Message<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Mention<'a> {
#[serde(borrow)]
pub did: Did<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ReplyRef<'a> {
#[serde(borrow)]
pub parent: AtUri<'a>,
#[serde(borrow)]
pub root: AtUri<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RichTextFacet<'a> {
#[serde(borrow)]
pub features: Vec<RichTextFacetFeaturesItem<'a>>,
#[serde(borrow)]
pub index: message::ByteSlice<'a>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
pub enum RichTextFacetFeaturesItem<'a> {
#[serde(rename = "app.protoimsg.chat.message#mention")]
Mention(Box<message::Mention<'a>>),
#[serde(rename = "app.protoimsg.chat.message#link")]
Link(Box<message::Link<'a>>),
#[serde(rename = "app.protoimsg.chat.message#tag")]
Tag(Box<message::Tag<'a>>),
#[serde(rename = "app.protoimsg.chat.message#bold")]
Bold(Box<message::Bold<'a>>),
#[serde(rename = "app.protoimsg.chat.message#italic")]
Italic(Box<message::Italic<'a>>),
#[serde(rename = "app.protoimsg.chat.message#strikethrough")]
Strikethrough(Box<message::Strikethrough<'a>>),
#[serde(rename = "app.protoimsg.chat.message#codeInline")]
CodeInline(Box<message::CodeInline<'a>>),
#[serde(rename = "app.protoimsg.chat.message#codeBlock")]
CodeBlock(Box<message::CodeBlock<'a>>),
#[serde(rename = "app.protoimsg.chat.message#blockquote")]
Blockquote(Box<message::Blockquote<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Strikethrough<'a> {}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Tag<'a> {
#[serde(borrow)]
pub tag: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct VideoEmbed<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub alt: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub aspect_ratio: Option<message::AspectRatio<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub thumbnail: Option<BlobRef<'a>>,
#[serde(borrow)]
pub video: BlobRef<'a>,
}
impl<'a> Message<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, MessageRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for AspectRatio<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"aspectRatio"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.height;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("height"),
min: 1i64,
actual: *value,
});
}
}
{
let value = &self.width;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("width"),
min: 1i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Blockquote<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"blockquote"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Bold<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"bold"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for ByteSlice<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"byteSlice"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.byte_end;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("byte_end"),
min: 0i64,
actual: *value,
});
}
}
{
let value = &self.byte_start;
if *value < 0i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("byte_start"),
min: 0i64,
actual: *value,
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for CodeBlock<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"codeBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.lang {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("lang"),
max: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for CodeInline<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"codeInline"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for ExternalEmbed<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"externalEmbed"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.description {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 1000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("description"),
max: 1000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.thumb {
{
let size = value.blob().size;
if size > 1000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("thumb"),
max: 1000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.thumb {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
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(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("thumb"),
accepted: vec![
"image/png".to_string(), "image/jpeg".to_string()
],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.title;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 300usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("title"),
max: 300usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ImageEmbed<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"imageEmbed"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.images;
#[allow(unused_comparisons)]
if value.len() > 4usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("images"),
max: 4usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<'a> LexiconSchema for ImageItem<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"imageItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.alt;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("alt"),
max: 2000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.image;
{
let size = value.blob().size;
if size > 1000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("image"),
max: 1000000usize,
actual: size,
});
}
}
}
{
let value = &self.image;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &[
"image/png",
"image/jpeg",
"image/gif",
"image/webp",
];
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(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("image"),
accepted: vec![
"image/png".to_string(), "image/jpeg".to_string(),
"image/gif".to_string(), "image/webp".to_string()
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Italic<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"italic"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Link<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"link"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct MessageRecord;
impl XrpcResp for MessageRecord {
const NSID: &'static str = "app.protoimsg.chat.message";
const ENCODING: &'static str = "application/json";
type Output<'de> = MessageGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<MessageGetRecordOutput<'_>> for Message<'_> {
fn from(output: MessageGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Message<'_> {
const NSID: &'static str = "app.protoimsg.chat.message";
type Record = MessageRecord;
}
impl Collection for MessageRecord {
const NSID: &'static str = "app.protoimsg.chat.message";
type Record = MessageRecord;
}
impl<'a> LexiconSchema for Message<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 3000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 3000usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.text;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 1000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for Mention<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"mention"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for ReplyRef<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"replyRef"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for RichTextFacet<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"richTextFacet"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Strikethrough<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"strikethrough"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Tag<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"tag"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.tag;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 640usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("tag"),
max: 640usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.tag;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 64usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("tag"),
max: 64usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<'a> LexiconSchema for VideoEmbed<'a> {
fn nsid() -> &'static str {
"app.protoimsg.chat.message"
}
fn def_name() -> &'static str {
"videoEmbed"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_app_protoimsg_chat_message()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.alt {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("alt"),
max: 2000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.thumbnail {
{
let size = value.blob().size;
if size > 1000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("thumbnail"),
max: 1000000usize,
actual: size,
});
}
}
}
if let Some(ref value) = self.thumbnail {
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["image/png", "image/jpeg"];
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(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("thumbnail"),
accepted: vec![
"image/png".to_string(), "image/jpeg".to_string()
],
actual: mime.to_string(),
});
}
}
}
{
let value = &self.video;
{
let size = value.blob().size;
if size > 50000000usize {
return Err(ConstraintError::BlobTooLarge {
path: ValidationPath::from_field("video"),
max: 50000000usize,
actual: size,
});
}
}
}
{
let value = &self.video;
{
let mime = value.blob().mime_type.as_str();
let accepted: &[&str] = &["video/mp4", "video/webm"];
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(ConstraintError::BlobMimeTypeNotAccepted {
path: ValidationPath::from_field("video"),
accepted: vec![
"video/mp4".to_string(), "video/webm".to_string()
],
actual: mime.to_string(),
});
}
}
}
Ok(())
}
}
pub mod aspect_ratio_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 Height;
type Width;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Height = Unset;
type Width = Unset;
}
pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHeight<S> {}
impl<S: State> State for SetHeight<S> {
type Height = Set<members::height>;
type Width = S::Width;
}
pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWidth<S> {}
impl<S: State> State for SetWidth<S> {
type Height = S::Height;
type Width = Set<members::width>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct height(());
pub struct width(());
}
}
pub struct AspectRatioBuilder<'a, S: aspect_ratio_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> AspectRatio<'a> {
pub fn new() -> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
AspectRatioBuilder::new()
}
}
impl<'a> AspectRatioBuilder<'a, aspect_ratio_state::Empty> {
pub fn new() -> Self {
AspectRatioBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> AspectRatioBuilder<'a, S>
where
S: aspect_ratio_state::State,
S::Height: aspect_ratio_state::IsUnset,
{
pub fn height(
mut self,
value: impl Into<i64>,
) -> AspectRatioBuilder<'a, aspect_ratio_state::SetHeight<S>> {
self._fields.0 = Option::Some(value.into());
AspectRatioBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AspectRatioBuilder<'a, S>
where
S: aspect_ratio_state::State,
S::Width: aspect_ratio_state::IsUnset,
{
pub fn width(
mut self,
value: impl Into<i64>,
) -> AspectRatioBuilder<'a, aspect_ratio_state::SetWidth<S>> {
self._fields.1 = Option::Some(value.into());
AspectRatioBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> AspectRatioBuilder<'a, S>
where
S: aspect_ratio_state::State,
S::Height: aspect_ratio_state::IsSet,
S::Width: aspect_ratio_state::IsSet,
{
pub fn build(self) -> AspectRatio<'a> {
AspectRatio {
height: self._fields.0.unwrap(),
width: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> AspectRatio<'a> {
AspectRatio {
height: self._fields.0.unwrap(),
width: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_app_protoimsg_chat_message() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("app.protoimsg.chat.message"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("aspectRatio"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Width and height for layout before media loads.",
),
),
required: Some(
vec![SmolStr::new_static("width"), SmolStr::new_static("height")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("blockquote"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for a block quotation."),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("bold"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for bold text."),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("byteSlice"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text.",
),
),
required: Some(
vec![
SmolStr::new_static("byteStart"),
SmolStr::new_static("byteEnd")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("byteEnd"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("byteStart"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(0i64),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codeBlock"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Facet feature for a code block. The text contains the code content.",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("lang"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Programming language for syntax highlighting.",
),
),
max_length: Some(50usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codeInline"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for inline code."),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("externalEmbed"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("External link card.")),
required: Some(
vec![SmolStr::new_static("uri"), SmolStr::new_static("title")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("description"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Description or summary."),
),
max_length: Some(1000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("thumb"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("title"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Title of the external content."),
),
max_length: Some(300usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("URL of the external content."),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("imageEmbed"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Embedded images.")),
required: Some(vec![SmolStr::new_static("images")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("images"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#imageItem"),
..Default::default()
}),
max_length: Some(4usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("imageItem"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("A single embedded image.")),
required: Some(
vec![SmolStr::new_static("image"), SmolStr::new_static("alt")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Alt text for accessibility."),
),
max_length: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("aspectRatio"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#aspectRatio"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("image"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("italic"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for italic text."),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("link"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.",
),
),
required: Some(vec![SmolStr::new_static("uri")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("uri"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"A chat message. Lives in the sender's repo, points to a channel.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("channel"), SmolStr::new_static("text"),
SmolStr::new_static("createdAt")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("channel"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the channel record this message belongs to.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("createdAt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Timestamp of message creation."),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("embed"),
LexObjectProperty::Union(LexRefUnion {
description: Some(
CowStr::new_static("Embedded media or link card."),
),
refs: vec![
CowStr::new_static("#imageEmbed"),
CowStr::new_static("#videoEmbed"),
CowStr::new_static("#externalEmbed")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Rich text annotations (mentions, links, tags, formatting). Extends the Bluesky facet convention with additional formatting features.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#richTextFacet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("reply"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#replyRef"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Message text content."),
),
max_length: Some(3000usize),
max_graphemes: Some(1000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mention"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.",
),
),
required: Some(vec![SmolStr::new_static("did")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("replyRef"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Thread reply reference with root and parent for efficient deep thread traversal.",
),
),
required: Some(
vec![SmolStr::new_static("root"), SmolStr::new_static("parent")],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("parent"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the direct parent message being replied to.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("root"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"AT-URI of the root message in the thread.",
),
),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("richTextFacet"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Annotation of a sub-string within rich text.",
),
),
required: Some(
vec![
SmolStr::new_static("index"), SmolStr::new_static("features")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("features"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#mention"), CowStr::new_static("#link"),
CowStr::new_static("#tag"), CowStr::new_static("#bold"),
CowStr::new_static("#italic"),
CowStr::new_static("#strikethrough"),
CowStr::new_static("#codeInline"),
CowStr::new_static("#codeBlock"),
CowStr::new_static("#blockquote")
],
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("index"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#byteSlice"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("strikethrough"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static("Facet feature for strikethrough text."),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tag"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not.",
),
),
required: Some(vec![SmolStr::new_static("tag")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("tag"),
LexObjectProperty::String(LexString {
max_length: Some(640usize),
max_graphemes: Some(64usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("videoEmbed"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("Embedded video.")),
required: Some(vec![SmolStr::new_static("video")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alt"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Alt text for accessibility."),
),
max_length: Some(2000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("aspectRatio"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#aspectRatio"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("thumbnail"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map.insert(
SmolStr::new_static("video"),
LexObjectProperty::Blob(LexBlob { ..Default::default() }),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod byte_slice_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 ByteEnd;
type ByteStart;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ByteEnd = Unset;
type ByteStart = Unset;
}
pub struct SetByteEnd<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetByteEnd<S> {}
impl<S: State> State for SetByteEnd<S> {
type ByteEnd = Set<members::byte_end>;
type ByteStart = S::ByteStart;
}
pub struct SetByteStart<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetByteStart<S> {}
impl<S: State> State for SetByteStart<S> {
type ByteEnd = S::ByteEnd;
type ByteStart = Set<members::byte_start>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct byte_end(());
pub struct byte_start(());
}
}
pub struct ByteSliceBuilder<'a, S: byte_slice_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ByteSlice<'a> {
pub fn new() -> ByteSliceBuilder<'a, byte_slice_state::Empty> {
ByteSliceBuilder::new()
}
}
impl<'a> ByteSliceBuilder<'a, byte_slice_state::Empty> {
pub fn new() -> Self {
ByteSliceBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ByteSliceBuilder<'a, S>
where
S: byte_slice_state::State,
S::ByteEnd: byte_slice_state::IsUnset,
{
pub fn byte_end(
mut self,
value: impl Into<i64>,
) -> ByteSliceBuilder<'a, byte_slice_state::SetByteEnd<S>> {
self._fields.0 = Option::Some(value.into());
ByteSliceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ByteSliceBuilder<'a, S>
where
S: byte_slice_state::State,
S::ByteStart: byte_slice_state::IsUnset,
{
pub fn byte_start(
mut self,
value: impl Into<i64>,
) -> ByteSliceBuilder<'a, byte_slice_state::SetByteStart<S>> {
self._fields.1 = Option::Some(value.into());
ByteSliceBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ByteSliceBuilder<'a, S>
where
S: byte_slice_state::State,
S::ByteEnd: byte_slice_state::IsSet,
S::ByteStart: byte_slice_state::IsSet,
{
pub fn build(self) -> ByteSlice<'a> {
ByteSlice {
byte_end: self._fields.0.unwrap(),
byte_start: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ByteSlice<'a> {
ByteSlice {
byte_end: self._fields.0.unwrap(),
byte_start: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod external_embed_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 Title;
type Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Title = Unset;
type Uri = Unset;
}
pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTitle<S> {}
impl<S: State> State for SetTitle<S> {
type Title = Set<members::title>;
type Uri = S::Uri;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Title = S::Title;
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct title(());
pub struct uri(());
}
}
pub struct ExternalEmbedBuilder<'a, S: external_embed_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<BlobRef<'a>>,
Option<CowStr<'a>>,
Option<UriValue<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ExternalEmbed<'a> {
pub fn new() -> ExternalEmbedBuilder<'a, external_embed_state::Empty> {
ExternalEmbedBuilder::new()
}
}
impl<'a> ExternalEmbedBuilder<'a, external_embed_state::Empty> {
pub fn new() -> Self {
ExternalEmbedBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: external_embed_state::State> ExternalEmbedBuilder<'a, S> {
pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: external_embed_state::State> ExternalEmbedBuilder<'a, S> {
pub fn thumb(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_thumb(mut self, value: Option<BlobRef<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> ExternalEmbedBuilder<'a, S>
where
S: external_embed_state::State,
S::Title: external_embed_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<CowStr<'a>>,
) -> ExternalEmbedBuilder<'a, external_embed_state::SetTitle<S>> {
self._fields.2 = Option::Some(value.into());
ExternalEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ExternalEmbedBuilder<'a, S>
where
S: external_embed_state::State,
S::Uri: external_embed_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<'a>>,
) -> ExternalEmbedBuilder<'a, external_embed_state::SetUri<S>> {
self._fields.3 = Option::Some(value.into());
ExternalEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ExternalEmbedBuilder<'a, S>
where
S: external_embed_state::State,
S::Title: external_embed_state::IsSet,
S::Uri: external_embed_state::IsSet,
{
pub fn build(self) -> ExternalEmbed<'a> {
ExternalEmbed {
description: self._fields.0,
thumb: self._fields.1,
title: self._fields.2.unwrap(),
uri: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ExternalEmbed<'a> {
ExternalEmbed {
description: self._fields.0,
thumb: self._fields.1,
title: self._fields.2.unwrap(),
uri: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod image_embed_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 Images;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Images = Unset;
}
pub struct SetImages<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetImages<S> {}
impl<S: State> State for SetImages<S> {
type Images = Set<members::images>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct images(());
}
}
pub struct ImageEmbedBuilder<'a, S: image_embed_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<message::ImageItem<'a>>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ImageEmbed<'a> {
pub fn new() -> ImageEmbedBuilder<'a, image_embed_state::Empty> {
ImageEmbedBuilder::new()
}
}
impl<'a> ImageEmbedBuilder<'a, image_embed_state::Empty> {
pub fn new() -> Self {
ImageEmbedBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ImageEmbedBuilder<'a, S>
where
S: image_embed_state::State,
S::Images: image_embed_state::IsUnset,
{
pub fn images(
mut self,
value: impl Into<Vec<message::ImageItem<'a>>>,
) -> ImageEmbedBuilder<'a, image_embed_state::SetImages<S>> {
self._fields.0 = Option::Some(value.into());
ImageEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ImageEmbedBuilder<'a, S>
where
S: image_embed_state::State,
S::Images: image_embed_state::IsSet,
{
pub fn build(self) -> ImageEmbed<'a> {
ImageEmbed {
images: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ImageEmbed<'a> {
ImageEmbed {
images: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod image_item_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 Image;
type Alt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Image = Unset;
type Alt = Unset;
}
pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetImage<S> {}
impl<S: State> State for SetImage<S> {
type Image = Set<members::image>;
type Alt = S::Alt;
}
pub struct SetAlt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAlt<S> {}
impl<S: State> State for SetAlt<S> {
type Image = S::Image;
type Alt = Set<members::alt>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct image(());
pub struct alt(());
}
}
pub struct ImageItemBuilder<'a, S: image_item_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<message::AspectRatio<'a>>, Option<BlobRef<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ImageItem<'a> {
pub fn new() -> ImageItemBuilder<'a, image_item_state::Empty> {
ImageItemBuilder::new()
}
}
impl<'a> ImageItemBuilder<'a, image_item_state::Empty> {
pub fn new() -> Self {
ImageItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ImageItemBuilder<'a, S>
where
S: image_item_state::State,
S::Alt: image_item_state::IsUnset,
{
pub fn alt(
mut self,
value: impl Into<CowStr<'a>>,
) -> ImageItemBuilder<'a, image_item_state::SetAlt<S>> {
self._fields.0 = Option::Some(value.into());
ImageItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: image_item_state::State> ImageItemBuilder<'a, S> {
pub fn aspect_ratio(
mut self,
value: impl Into<Option<message::AspectRatio<'a>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_aspect_ratio(
mut self,
value: Option<message::AspectRatio<'a>>,
) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> ImageItemBuilder<'a, S>
where
S: image_item_state::State,
S::Image: image_item_state::IsUnset,
{
pub fn image(
mut self,
value: impl Into<BlobRef<'a>>,
) -> ImageItemBuilder<'a, image_item_state::SetImage<S>> {
self._fields.2 = Option::Some(value.into());
ImageItemBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ImageItemBuilder<'a, S>
where
S: image_item_state::State,
S::Image: image_item_state::IsSet,
S::Alt: image_item_state::IsSet,
{
pub fn build(self) -> ImageItem<'a> {
ImageItem {
alt: self._fields.0.unwrap(),
aspect_ratio: self._fields.1,
image: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ImageItem<'a> {
ImageItem {
alt: self._fields.0.unwrap(),
aspect_ratio: self._fields.1,
image: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod link_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 Uri;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
}
pub struct SetUri<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetUri<S> {}
impl<S: State> State for SetUri<S> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct LinkBuilder<'a, S: link_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<UriValue<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Link<'a> {
pub fn new() -> LinkBuilder<'a, link_state::Empty> {
LinkBuilder::new()
}
}
impl<'a> LinkBuilder<'a, link_state::Empty> {
pub fn new() -> Self {
LinkBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> LinkBuilder<'a, S>
where
S: link_state::State,
S::Uri: link_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<'a>>,
) -> LinkBuilder<'a, link_state::SetUri<S>> {
self._fields.0 = Option::Some(value.into());
LinkBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> LinkBuilder<'a, S>
where
S: link_state::State,
S::Uri: link_state::IsSet,
{
pub fn build(self) -> Link<'a> {
Link {
uri: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Link<'a> {
Link {
uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod message_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 Channel;
type Text;
type CreatedAt;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Channel = Unset;
type Text = Unset;
type CreatedAt = Unset;
}
pub struct SetChannel<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetChannel<S> {}
impl<S: State> State for SetChannel<S> {
type Channel = Set<members::channel>;
type Text = S::Text;
type CreatedAt = S::CreatedAt;
}
pub struct SetText<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetText<S> {}
impl<S: State> State for SetText<S> {
type Channel = S::Channel;
type Text = Set<members::text>;
type CreatedAt = S::CreatedAt;
}
pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
impl<S: State> State for SetCreatedAt<S> {
type Channel = S::Channel;
type Text = S::Text;
type CreatedAt = Set<members::created_at>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct channel(());
pub struct text(());
pub struct created_at(());
}
}
pub struct MessageBuilder<'a, S: message_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<AtUri<'a>>,
Option<Datetime>,
Option<MessageEmbed<'a>>,
Option<Vec<message::RichTextFacet<'a>>>,
Option<message::ReplyRef<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Message<'a> {
pub fn new() -> MessageBuilder<'a, message_state::Empty> {
MessageBuilder::new()
}
}
impl<'a> MessageBuilder<'a, message_state::Empty> {
pub fn new() -> Self {
MessageBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> MessageBuilder<'a, S>
where
S: message_state::State,
S::Channel: message_state::IsUnset,
{
pub fn channel(
mut self,
value: impl Into<AtUri<'a>>,
) -> MessageBuilder<'a, message_state::SetChannel<S>> {
self._fields.0 = Option::Some(value.into());
MessageBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MessageBuilder<'a, S>
where
S: message_state::State,
S::CreatedAt: message_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> MessageBuilder<'a, message_state::SetCreatedAt<S>> {
self._fields.1 = Option::Some(value.into());
MessageBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: message_state::State> MessageBuilder<'a, S> {
pub fn embed(mut self, value: impl Into<Option<MessageEmbed<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_embed(mut self, value: Option<MessageEmbed<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S: message_state::State> MessageBuilder<'a, S> {
pub fn facets(
mut self,
value: impl Into<Option<Vec<message::RichTextFacet<'a>>>>,
) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_facets(
mut self,
value: Option<Vec<message::RichTextFacet<'a>>>,
) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S: message_state::State> MessageBuilder<'a, S> {
pub fn reply(mut self, value: impl Into<Option<message::ReplyRef<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_reply(mut self, value: Option<message::ReplyRef<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> MessageBuilder<'a, S>
where
S: message_state::State,
S::Text: message_state::IsUnset,
{
pub fn text(
mut self,
value: impl Into<CowStr<'a>>,
) -> MessageBuilder<'a, message_state::SetText<S>> {
self._fields.5 = Option::Some(value.into());
MessageBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MessageBuilder<'a, S>
where
S: message_state::State,
S::Channel: message_state::IsSet,
S::Text: message_state::IsSet,
S::CreatedAt: message_state::IsSet,
{
pub fn build(self) -> Message<'a> {
Message {
channel: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
embed: self._fields.2,
facets: self._fields.3,
reply: self._fields.4,
text: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Message<'a> {
Message {
channel: self._fields.0.unwrap(),
created_at: self._fields.1.unwrap(),
embed: self._fields.2,
facets: self._fields.3,
reply: self._fields.4,
text: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod mention_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 Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Did = Unset;
}
pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetDid<S> {}
impl<S: State> State for SetDid<S> {
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct MentionBuilder<'a, S: mention_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Did<'a>>,),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Mention<'a> {
pub fn new() -> MentionBuilder<'a, mention_state::Empty> {
MentionBuilder::new()
}
}
impl<'a> MentionBuilder<'a, mention_state::Empty> {
pub fn new() -> Self {
MentionBuilder {
_state: PhantomData,
_fields: (None,),
_lifetime: PhantomData,
}
}
}
impl<'a, S> MentionBuilder<'a, S>
where
S: mention_state::State,
S::Did: mention_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<'a>>,
) -> MentionBuilder<'a, mention_state::SetDid<S>> {
self._fields.0 = Option::Some(value.into());
MentionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MentionBuilder<'a, S>
where
S: mention_state::State,
S::Did: mention_state::IsSet,
{
pub fn build(self) -> Mention<'a> {
Mention {
did: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Mention<'a> {
Mention {
did: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod reply_ref_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 Parent;
type Root;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Parent = Unset;
type Root = Unset;
}
pub struct SetParent<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetParent<S> {}
impl<S: State> State for SetParent<S> {
type Parent = Set<members::parent>;
type Root = S::Root;
}
pub struct SetRoot<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRoot<S> {}
impl<S: State> State for SetRoot<S> {
type Parent = S::Parent;
type Root = Set<members::root>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct parent(());
pub struct root(());
}
}
pub struct ReplyRefBuilder<'a, S: reply_ref_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<AtUri<'a>>, Option<AtUri<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> ReplyRef<'a> {
pub fn new() -> ReplyRefBuilder<'a, reply_ref_state::Empty> {
ReplyRefBuilder::new()
}
}
impl<'a> ReplyRefBuilder<'a, reply_ref_state::Empty> {
pub fn new() -> Self {
ReplyRefBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReplyRefBuilder<'a, S>
where
S: reply_ref_state::State,
S::Parent: reply_ref_state::IsUnset,
{
pub fn parent(
mut self,
value: impl Into<AtUri<'a>>,
) -> ReplyRefBuilder<'a, reply_ref_state::SetParent<S>> {
self._fields.0 = Option::Some(value.into());
ReplyRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReplyRefBuilder<'a, S>
where
S: reply_ref_state::State,
S::Root: reply_ref_state::IsUnset,
{
pub fn root(
mut self,
value: impl Into<AtUri<'a>>,
) -> ReplyRefBuilder<'a, reply_ref_state::SetRoot<S>> {
self._fields.1 = Option::Some(value.into());
ReplyRefBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> ReplyRefBuilder<'a, S>
where
S: reply_ref_state::State,
S::Parent: reply_ref_state::IsSet,
S::Root: reply_ref_state::IsSet,
{
pub fn build(self) -> ReplyRef<'a> {
ReplyRef {
parent: self._fields.0.unwrap(),
root: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> ReplyRef<'a> {
ReplyRef {
parent: self._fields.0.unwrap(),
root: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod rich_text_facet_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 Index;
type Features;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Index = Unset;
type Features = Unset;
}
pub struct SetIndex<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIndex<S> {}
impl<S: State> State for SetIndex<S> {
type Index = Set<members::index>;
type Features = S::Features;
}
pub struct SetFeatures<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetFeatures<S> {}
impl<S: State> State for SetFeatures<S> {
type Index = S::Index;
type Features = Set<members::features>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct index(());
pub struct features(());
}
}
pub struct RichTextFacetBuilder<'a, S: rich_text_facet_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Vec<RichTextFacetFeaturesItem<'a>>>,
Option<message::ByteSlice<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> RichTextFacet<'a> {
pub fn new() -> RichTextFacetBuilder<'a, rich_text_facet_state::Empty> {
RichTextFacetBuilder::new()
}
}
impl<'a> RichTextFacetBuilder<'a, rich_text_facet_state::Empty> {
pub fn new() -> Self {
RichTextFacetBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> RichTextFacetBuilder<'a, S>
where
S: rich_text_facet_state::State,
S::Features: rich_text_facet_state::IsUnset,
{
pub fn features(
mut self,
value: impl Into<Vec<RichTextFacetFeaturesItem<'a>>>,
) -> RichTextFacetBuilder<'a, rich_text_facet_state::SetFeatures<S>> {
self._fields.0 = Option::Some(value.into());
RichTextFacetBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RichTextFacetBuilder<'a, S>
where
S: rich_text_facet_state::State,
S::Index: rich_text_facet_state::IsUnset,
{
pub fn index(
mut self,
value: impl Into<message::ByteSlice<'a>>,
) -> RichTextFacetBuilder<'a, rich_text_facet_state::SetIndex<S>> {
self._fields.1 = Option::Some(value.into());
RichTextFacetBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RichTextFacetBuilder<'a, S>
where
S: rich_text_facet_state::State,
S::Index: rich_text_facet_state::IsSet,
S::Features: rich_text_facet_state::IsSet,
{
pub fn build(self) -> RichTextFacet<'a> {
RichTextFacet {
features: self._fields.0.unwrap(),
index: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> RichTextFacet<'a> {
RichTextFacet {
features: self._fields.0.unwrap(),
index: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod video_embed_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 VideoEmbedBuilder<'a, S: video_embed_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<message::AspectRatio<'a>>,
Option<BlobRef<'a>>,
Option<BlobRef<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> VideoEmbed<'a> {
pub fn new() -> VideoEmbedBuilder<'a, video_embed_state::Empty> {
VideoEmbedBuilder::new()
}
}
impl<'a> VideoEmbedBuilder<'a, video_embed_state::Empty> {
pub fn new() -> Self {
VideoEmbedBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: video_embed_state::State> VideoEmbedBuilder<'a, S> {
pub fn alt(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: video_embed_state::State> VideoEmbedBuilder<'a, S> {
pub fn aspect_ratio(
mut self,
value: impl Into<Option<message::AspectRatio<'a>>>,
) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_aspect_ratio(
mut self,
value: Option<message::AspectRatio<'a>>,
) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: video_embed_state::State> VideoEmbedBuilder<'a, S> {
pub fn thumbnail(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_thumbnail(mut self, value: Option<BlobRef<'a>>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> VideoEmbedBuilder<'a, S>
where
S: video_embed_state::State,
S::Video: video_embed_state::IsUnset,
{
pub fn video(
mut self,
value: impl Into<BlobRef<'a>>,
) -> VideoEmbedBuilder<'a, video_embed_state::SetVideo<S>> {
self._fields.3 = Option::Some(value.into());
VideoEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> VideoEmbedBuilder<'a, S>
where
S: video_embed_state::State,
S::Video: video_embed_state::IsSet,
{
pub fn build(self) -> VideoEmbed<'a> {
VideoEmbed {
alt: self._fields.0,
aspect_ratio: self._fields.1,
thumbnail: self._fields.2,
video: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> VideoEmbed<'a> {
VideoEmbed {
alt: self._fields.0,
aspect_ratio: self._fields.1,
thumbnail: self._fields.2,
video: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}