#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, Did, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::app_protoimsg::chat::message;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct AspectRatio<S: BosStr = DefaultStr> {
pub height: i64,
pub width: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Blockquote<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Bold<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ByteSlice<S: BosStr = DefaultStr> {
pub byte_end: i64,
pub byte_start: i64,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CodeBlock<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub lang: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CodeInline<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ExternalEmbed<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub thumb: Option<BlobRef<S>>,
pub title: S,
pub uri: UriValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ImageEmbed<S: BosStr = DefaultStr> {
pub images: Vec<message::ImageItem<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ImageItem<S: BosStr = DefaultStr> {
pub alt: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub aspect_ratio: Option<message::AspectRatio<S>>,
pub image: BlobRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Italic<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Link<S: BosStr = DefaultStr> {
pub uri: UriValue<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "app.protoimsg.chat.message",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Message<S: BosStr = DefaultStr> {
pub channel: AtUri<S>,
pub created_at: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub embed: Option<MessageEmbed<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<message::RichTextFacet<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply: Option<message::ReplyRef<S>>,
pub text: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum MessageEmbed<S: BosStr = DefaultStr> {
#[serde(rename = "app.protoimsg.chat.message#imageEmbed")]
ImageEmbed(Box<message::ImageEmbed<S>>),
#[serde(rename = "app.protoimsg.chat.message#videoEmbed")]
VideoEmbed(Box<message::VideoEmbed<S>>),
#[serde(rename = "app.protoimsg.chat.message#externalEmbed")]
ExternalEmbed(Box<message::ExternalEmbed<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct MessageGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Message<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Mention<S: BosStr = DefaultStr> {
pub did: Did<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ReplyRef<S: BosStr = DefaultStr> {
pub parent: AtUri<S>,
pub root: AtUri<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct RichTextFacet<S: BosStr = DefaultStr> {
pub features: Vec<RichTextFacetFeaturesItem<S>>,
pub index: message::ByteSlice<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum RichTextFacetFeaturesItem<S: BosStr = DefaultStr> {
#[serde(rename = "app.protoimsg.chat.message#mention")]
Mention(Box<message::Mention<S>>),
#[serde(rename = "app.protoimsg.chat.message#link")]
Link(Box<message::Link<S>>),
#[serde(rename = "app.protoimsg.chat.message#tag")]
Tag(Box<message::Tag<S>>),
#[serde(rename = "app.protoimsg.chat.message#bold")]
Bold(Box<message::Bold<S>>),
#[serde(rename = "app.protoimsg.chat.message#italic")]
Italic(Box<message::Italic<S>>),
#[serde(rename = "app.protoimsg.chat.message#strikethrough")]
Strikethrough(Box<message::Strikethrough<S>>),
#[serde(rename = "app.protoimsg.chat.message#codeInline")]
CodeInline(Box<message::CodeInline<S>>),
#[serde(rename = "app.protoimsg.chat.message#codeBlock")]
CodeBlock(Box<message::CodeBlock<S>>),
#[serde(rename = "app.protoimsg.chat.message#blockquote")]
Blockquote(Box<message::Blockquote<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Strikethrough<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Tag<S: BosStr = DefaultStr> {
pub tag: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct VideoEmbed<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alt: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub aspect_ratio: Option<message::AspectRatio<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub thumbnail: Option<BlobRef<S>>,
pub video: BlobRef<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> Message<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, MessageRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for AspectRatio<S> {
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<S: BosStr> LexiconSchema for Blockquote<S> {
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<S: BosStr> LexiconSchema for Bold<S> {
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<S: BosStr> LexiconSchema for ByteSlice<S> {
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<S: BosStr> LexiconSchema for CodeBlock<S> {
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<S: BosStr> LexiconSchema for CodeInline<S> {
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<S: BosStr> LexiconSchema for ExternalEmbed<S> {
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<S: BosStr> LexiconSchema for ImageEmbed<S> {
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<S: BosStr> LexiconSchema for ImageItem<S> {
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<S: BosStr> LexiconSchema for Italic<S> {
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<S: BosStr> LexiconSchema for Link<S> {
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<S: BosStr> = MessageGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<MessageGetRecordOutput<S>> for Message<S> {
fn from(output: MessageGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Message<S> {
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<S: BosStr> LexiconSchema for Message<S> {
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<S: BosStr> LexiconSchema for Mention<S> {
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<S: BosStr> LexiconSchema for ReplyRef<S> {
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<S: BosStr> LexiconSchema for RichTextFacet<S> {
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<S: BosStr> LexiconSchema for Strikethrough<S> {
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<S: BosStr> LexiconSchema for Tag<S> {
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<S: BosStr> LexiconSchema for VideoEmbed<S> {
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHeight<St> {}
impl<St: State> State for SetHeight<St> {
type Height = Set<members::height>;
type Width = St::Width;
}
pub struct SetWidth<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWidth<St> {}
impl<St: State> State for SetWidth<St> {
type Height = St::Height;
type Width = Set<members::width>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct height(());
pub struct width(());
}
}
pub struct AspectRatioBuilder<S: BosStr, St: aspect_ratio_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> AspectRatio<S> {
pub fn new() -> AspectRatioBuilder<S, aspect_ratio_state::Empty> {
AspectRatioBuilder::new()
}
}
impl<S: BosStr> AspectRatioBuilder<S, aspect_ratio_state::Empty> {
pub fn new() -> Self {
AspectRatioBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AspectRatioBuilder<S, St>
where
St: aspect_ratio_state::State,
St::Height: aspect_ratio_state::IsUnset,
{
pub fn height(
mut self,
value: impl Into<i64>,
) -> AspectRatioBuilder<S, aspect_ratio_state::SetHeight<St>> {
self._fields.0 = Option::Some(value.into());
AspectRatioBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AspectRatioBuilder<S, St>
where
St: aspect_ratio_state::State,
St::Width: aspect_ratio_state::IsUnset,
{
pub fn width(
mut self,
value: impl Into<i64>,
) -> AspectRatioBuilder<S, aspect_ratio_state::SetWidth<St>> {
self._fields.1 = Option::Some(value.into());
AspectRatioBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AspectRatioBuilder<S, St>
where
St: aspect_ratio_state::State,
St::Height: aspect_ratio_state::IsSet,
St::Width: aspect_ratio_state::IsSet,
{
pub fn build(self) -> AspectRatio<S> {
AspectRatio {
height: self._fields.0.unwrap(),
width: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> AspectRatio<S> {
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> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type ByteStart;
type ByteEnd;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type ByteStart = Unset;
type ByteEnd = Unset;
}
pub struct SetByteStart<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetByteStart<St> {}
impl<St: State> State for SetByteStart<St> {
type ByteStart = Set<members::byte_start>;
type ByteEnd = St::ByteEnd;
}
pub struct SetByteEnd<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetByteEnd<St> {}
impl<St: State> State for SetByteEnd<St> {
type ByteStart = St::ByteStart;
type ByteEnd = Set<members::byte_end>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct byte_start(());
pub struct byte_end(());
}
}
pub struct ByteSliceBuilder<S: BosStr, St: byte_slice_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ByteSlice<S> {
pub fn new() -> ByteSliceBuilder<S, byte_slice_state::Empty> {
ByteSliceBuilder::new()
}
}
impl<S: BosStr> ByteSliceBuilder<S, byte_slice_state::Empty> {
pub fn new() -> Self {
ByteSliceBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ByteSliceBuilder<S, St>
where
St: byte_slice_state::State,
St::ByteEnd: byte_slice_state::IsUnset,
{
pub fn byte_end(
mut self,
value: impl Into<i64>,
) -> ByteSliceBuilder<S, byte_slice_state::SetByteEnd<St>> {
self._fields.0 = Option::Some(value.into());
ByteSliceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ByteSliceBuilder<S, St>
where
St: byte_slice_state::State,
St::ByteStart: byte_slice_state::IsUnset,
{
pub fn byte_start(
mut self,
value: impl Into<i64>,
) -> ByteSliceBuilder<S, byte_slice_state::SetByteStart<St>> {
self._fields.1 = Option::Some(value.into());
ByteSliceBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ByteSliceBuilder<S, St>
where
St: byte_slice_state::State,
St::ByteStart: byte_slice_state::IsSet,
St::ByteEnd: byte_slice_state::IsSet,
{
pub fn build(self) -> ByteSlice<S> {
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<SmolStr, Data<S>>) -> ByteSlice<S> {
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Uri;
type Title;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Uri = Unset;
type Title = Unset;
}
pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
type Title = St::Title;
}
pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTitle<St> {}
impl<St: State> State for SetTitle<St> {
type Uri = St::Uri;
type Title = Set<members::title>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
pub struct title(());
}
}
pub struct ExternalEmbedBuilder<S: BosStr, St: external_embed_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<BlobRef<S>>,
Option<S>,
Option<UriValue<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ExternalEmbed<S> {
pub fn new() -> ExternalEmbedBuilder<S, external_embed_state::Empty> {
ExternalEmbedBuilder::new()
}
}
impl<S: BosStr> ExternalEmbedBuilder<S, external_embed_state::Empty> {
pub fn new() -> Self {
ExternalEmbedBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: external_embed_state::State> ExternalEmbedBuilder<S, St> {
pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_description(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: external_embed_state::State> ExternalEmbedBuilder<S, St> {
pub fn thumb(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_thumb(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> ExternalEmbedBuilder<S, St>
where
St: external_embed_state::State,
St::Title: external_embed_state::IsUnset,
{
pub fn title(
mut self,
value: impl Into<S>,
) -> ExternalEmbedBuilder<S, external_embed_state::SetTitle<St>> {
self._fields.2 = Option::Some(value.into());
ExternalEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ExternalEmbedBuilder<S, St>
where
St: external_embed_state::State,
St::Uri: external_embed_state::IsUnset,
{
pub fn uri(
mut self,
value: impl Into<UriValue<S>>,
) -> ExternalEmbedBuilder<S, external_embed_state::SetUri<St>> {
self._fields.3 = Option::Some(value.into());
ExternalEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ExternalEmbedBuilder<S, St>
where
St: external_embed_state::State,
St::Uri: external_embed_state::IsSet,
St::Title: external_embed_state::IsSet,
{
pub fn build(self) -> ExternalEmbed<S> {
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<SmolStr, Data<S>>) -> ExternalEmbed<S> {
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetImages<St> {}
impl<St: State> State for SetImages<St> {
type Images = Set<members::images>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct images(());
}
}
pub struct ImageEmbedBuilder<S: BosStr, St: image_embed_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<message::ImageItem<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ImageEmbed<S> {
pub fn new() -> ImageEmbedBuilder<S, image_embed_state::Empty> {
ImageEmbedBuilder::new()
}
}
impl<S: BosStr> ImageEmbedBuilder<S, image_embed_state::Empty> {
pub fn new() -> Self {
ImageEmbedBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ImageEmbedBuilder<S, St>
where
St: image_embed_state::State,
St::Images: image_embed_state::IsUnset,
{
pub fn images(
mut self,
value: impl Into<Vec<message::ImageItem<S>>>,
) -> ImageEmbedBuilder<S, image_embed_state::SetImages<St>> {
self._fields.0 = Option::Some(value.into());
ImageEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ImageEmbedBuilder<S, St>
where
St: image_embed_state::State,
St::Images: image_embed_state::IsSet,
{
pub fn build(self) -> ImageEmbed<S> {
ImageEmbed {
images: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ImageEmbed<S> {
ImageEmbed {
images: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod image_item_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Alt;
type Image;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Alt = Unset;
type Image = Unset;
}
pub struct SetAlt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAlt<St> {}
impl<St: State> State for SetAlt<St> {
type Alt = Set<members::alt>;
type Image = St::Image;
}
pub struct SetImage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetImage<St> {}
impl<St: State> State for SetImage<St> {
type Alt = St::Alt;
type Image = Set<members::image>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct alt(());
pub struct image(());
}
}
pub struct ImageItemBuilder<S: BosStr, St: image_item_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<message::AspectRatio<S>>,
Option<BlobRef<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ImageItem<S> {
pub fn new() -> ImageItemBuilder<S, image_item_state::Empty> {
ImageItemBuilder::new()
}
}
impl<S: BosStr> ImageItemBuilder<S, image_item_state::Empty> {
pub fn new() -> Self {
ImageItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ImageItemBuilder<S, St>
where
St: image_item_state::State,
St::Alt: image_item_state::IsUnset,
{
pub fn alt(mut self, value: impl Into<S>) -> ImageItemBuilder<S, image_item_state::SetAlt<St>> {
self._fields.0 = Option::Some(value.into());
ImageItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: image_item_state::State> ImageItemBuilder<S, St> {
pub fn aspect_ratio(mut self, value: impl Into<Option<message::AspectRatio<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_aspect_ratio(mut self, value: Option<message::AspectRatio<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> ImageItemBuilder<S, St>
where
St: image_item_state::State,
St::Image: image_item_state::IsUnset,
{
pub fn image(
mut self,
value: impl Into<BlobRef<S>>,
) -> ImageItemBuilder<S, image_item_state::SetImage<St>> {
self._fields.2 = Option::Some(value.into());
ImageItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ImageItemBuilder<S, St>
where
St: image_item_state::State,
St::Alt: image_item_state::IsSet,
St::Image: image_item_state::IsSet,
{
pub fn build(self) -> ImageItem<S> {
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<SmolStr, Data<S>>) -> ImageItem<S> {
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetUri<St> {}
impl<St: State> State for SetUri<St> {
type Uri = Set<members::uri>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct uri(());
}
}
pub struct LinkBuilder<S: BosStr, St: link_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<UriValue<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Link<S> {
pub fn new() -> LinkBuilder<S, link_state::Empty> {
LinkBuilder::new()
}
}
impl<S: BosStr> LinkBuilder<S, link_state::Empty> {
pub fn new() -> Self {
LinkBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LinkBuilder<S, St>
where
St: link_state::State,
St::Uri: link_state::IsUnset,
{
pub fn uri(mut self, value: impl Into<UriValue<S>>) -> LinkBuilder<S, link_state::SetUri<St>> {
self._fields.0 = Option::Some(value.into());
LinkBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LinkBuilder<S, St>
where
St: link_state::State,
St::Uri: link_state::IsSet,
{
pub fn build(self) -> Link<S> {
Link {
uri: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Link<S> {
Link {
uri: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod message_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Channel;
type CreatedAt;
type Text;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Channel = Unset;
type CreatedAt = Unset;
type Text = Unset;
}
pub struct SetChannel<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetChannel<St> {}
impl<St: State> State for SetChannel<St> {
type Channel = Set<members::channel>;
type CreatedAt = St::CreatedAt;
type Text = St::Text;
}
pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
impl<St: State> State for SetCreatedAt<St> {
type Channel = St::Channel;
type CreatedAt = Set<members::created_at>;
type Text = St::Text;
}
pub struct SetText<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetText<St> {}
impl<St: State> State for SetText<St> {
type Channel = St::Channel;
type CreatedAt = St::CreatedAt;
type Text = Set<members::text>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct channel(());
pub struct created_at(());
pub struct text(());
}
}
pub struct MessageBuilder<S: BosStr, St: message_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<AtUri<S>>,
Option<Datetime>,
Option<MessageEmbed<S>>,
Option<Vec<message::RichTextFacet<S>>>,
Option<message::ReplyRef<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Message<S> {
pub fn new() -> MessageBuilder<S, message_state::Empty> {
MessageBuilder::new()
}
}
impl<S: BosStr> MessageBuilder<S, message_state::Empty> {
pub fn new() -> Self {
MessageBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MessageBuilder<S, St>
where
St: message_state::State,
St::Channel: message_state::IsUnset,
{
pub fn channel(
mut self,
value: impl Into<AtUri<S>>,
) -> MessageBuilder<S, message_state::SetChannel<St>> {
self._fields.0 = Option::Some(value.into());
MessageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MessageBuilder<S, St>
where
St: message_state::State,
St::CreatedAt: message_state::IsUnset,
{
pub fn created_at(
mut self,
value: impl Into<Datetime>,
) -> MessageBuilder<S, message_state::SetCreatedAt<St>> {
self._fields.1 = Option::Some(value.into());
MessageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: message_state::State> MessageBuilder<S, St> {
pub fn embed(mut self, value: impl Into<Option<MessageEmbed<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_embed(mut self, value: Option<MessageEmbed<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St: message_state::State> MessageBuilder<S, St> {
pub fn facets(mut self, value: impl Into<Option<Vec<message::RichTextFacet<S>>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_facets(mut self, value: Option<Vec<message::RichTextFacet<S>>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St: message_state::State> MessageBuilder<S, St> {
pub fn reply(mut self, value: impl Into<Option<message::ReplyRef<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_reply(mut self, value: Option<message::ReplyRef<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> MessageBuilder<S, St>
where
St: message_state::State,
St::Text: message_state::IsUnset,
{
pub fn text(mut self, value: impl Into<S>) -> MessageBuilder<S, message_state::SetText<St>> {
self._fields.5 = Option::Some(value.into());
MessageBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MessageBuilder<S, St>
where
St: message_state::State,
St::Channel: message_state::IsSet,
St::CreatedAt: message_state::IsSet,
St::Text: message_state::IsSet,
{
pub fn build(self) -> Message<S> {
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<SmolStr, Data<S>>) -> Message<S> {
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct did(());
}
}
pub struct MentionBuilder<S: BosStr, St: mention_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Mention<S> {
pub fn new() -> MentionBuilder<S, mention_state::Empty> {
MentionBuilder::new()
}
}
impl<S: BosStr> MentionBuilder<S, mention_state::Empty> {
pub fn new() -> Self {
MentionBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MentionBuilder<S, St>
where
St: mention_state::State,
St::Did: mention_state::IsUnset,
{
pub fn did(mut self, value: impl Into<Did<S>>) -> MentionBuilder<S, mention_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
MentionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MentionBuilder<S, St>
where
St: mention_state::State,
St::Did: mention_state::IsSet,
{
pub fn build(self) -> Mention<S> {
Mention {
did: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Mention<S> {
Mention {
did: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod reply_ref_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Root;
type Parent;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Root = Unset;
type Parent = Unset;
}
pub struct SetRoot<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRoot<St> {}
impl<St: State> State for SetRoot<St> {
type Root = Set<members::root>;
type Parent = St::Parent;
}
pub struct SetParent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetParent<St> {}
impl<St: State> State for SetParent<St> {
type Root = St::Root;
type Parent = Set<members::parent>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct root(());
pub struct parent(());
}
}
pub struct ReplyRefBuilder<S: BosStr, St: reply_ref_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtUri<S>>, Option<AtUri<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ReplyRef<S> {
pub fn new() -> ReplyRefBuilder<S, reply_ref_state::Empty> {
ReplyRefBuilder::new()
}
}
impl<S: BosStr> ReplyRefBuilder<S, reply_ref_state::Empty> {
pub fn new() -> Self {
ReplyRefBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ReplyRefBuilder<S, St>
where
St: reply_ref_state::State,
St::Parent: reply_ref_state::IsUnset,
{
pub fn parent(
mut self,
value: impl Into<AtUri<S>>,
) -> ReplyRefBuilder<S, reply_ref_state::SetParent<St>> {
self._fields.0 = Option::Some(value.into());
ReplyRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ReplyRefBuilder<S, St>
where
St: reply_ref_state::State,
St::Root: reply_ref_state::IsUnset,
{
pub fn root(
mut self,
value: impl Into<AtUri<S>>,
) -> ReplyRefBuilder<S, reply_ref_state::SetRoot<St>> {
self._fields.1 = Option::Some(value.into());
ReplyRefBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> ReplyRefBuilder<S, St>
where
St: reply_ref_state::State,
St::Root: reply_ref_state::IsSet,
St::Parent: reply_ref_state::IsSet,
{
pub fn build(self) -> ReplyRef<S> {
ReplyRef {
parent: self._fields.0.unwrap(),
root: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ReplyRef<S> {
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::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Features;
type Index;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Features = Unset;
type Index = Unset;
}
pub struct SetFeatures<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetFeatures<St> {}
impl<St: State> State for SetFeatures<St> {
type Features = Set<members::features>;
type Index = St::Index;
}
pub struct SetIndex<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIndex<St> {}
impl<St: State> State for SetIndex<St> {
type Features = St::Features;
type Index = Set<members::index>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct features(());
pub struct index(());
}
}
pub struct RichTextFacetBuilder<S: BosStr, St: rich_text_facet_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<RichTextFacetFeaturesItem<S>>>,
Option<message::ByteSlice<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> RichTextFacet<S> {
pub fn new() -> RichTextFacetBuilder<S, rich_text_facet_state::Empty> {
RichTextFacetBuilder::new()
}
}
impl<S: BosStr> RichTextFacetBuilder<S, rich_text_facet_state::Empty> {
pub fn new() -> Self {
RichTextFacetBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RichTextFacetBuilder<S, St>
where
St: rich_text_facet_state::State,
St::Features: rich_text_facet_state::IsUnset,
{
pub fn features(
mut self,
value: impl Into<Vec<RichTextFacetFeaturesItem<S>>>,
) -> RichTextFacetBuilder<S, rich_text_facet_state::SetFeatures<St>> {
self._fields.0 = Option::Some(value.into());
RichTextFacetBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RichTextFacetBuilder<S, St>
where
St: rich_text_facet_state::State,
St::Index: rich_text_facet_state::IsUnset,
{
pub fn index(
mut self,
value: impl Into<message::ByteSlice<S>>,
) -> RichTextFacetBuilder<S, rich_text_facet_state::SetIndex<St>> {
self._fields.1 = Option::Some(value.into());
RichTextFacetBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RichTextFacetBuilder<S, St>
where
St: rich_text_facet_state::State,
St::Features: rich_text_facet_state::IsSet,
St::Index: rich_text_facet_state::IsSet,
{
pub fn build(self) -> RichTextFacet<S> {
RichTextFacet {
features: self._fields.0.unwrap(),
index: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> RichTextFacet<S> {
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::{IsSet, IsUnset, Set, Unset};
#[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<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetVideo<St> {}
impl<St: State> State for SetVideo<St> {
type Video = Set<members::video>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct video(());
}
}
pub struct VideoEmbedBuilder<S: BosStr, St: video_embed_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<message::AspectRatio<S>>,
Option<BlobRef<S>>,
Option<BlobRef<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> VideoEmbed<S> {
pub fn new() -> VideoEmbedBuilder<S, video_embed_state::Empty> {
VideoEmbedBuilder::new()
}
}
impl<S: BosStr> VideoEmbedBuilder<S, video_embed_state::Empty> {
pub fn new() -> Self {
VideoEmbedBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: video_embed_state::State> VideoEmbedBuilder<S, St> {
pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alt(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: video_embed_state::State> VideoEmbedBuilder<S, St> {
pub fn aspect_ratio(mut self, value: impl Into<Option<message::AspectRatio<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_aspect_ratio(mut self, value: Option<message::AspectRatio<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St: video_embed_state::State> VideoEmbedBuilder<S, St> {
pub fn thumbnail(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_thumbnail(mut self, value: Option<BlobRef<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> VideoEmbedBuilder<S, St>
where
St: video_embed_state::State,
St::Video: video_embed_state::IsUnset,
{
pub fn video(
mut self,
value: impl Into<BlobRef<S>>,
) -> VideoEmbedBuilder<S, video_embed_state::SetVideo<St>> {
self._fields.3 = Option::Some(value.into());
VideoEmbedBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> VideoEmbedBuilder<S, St>
where
St: video_embed_state::State,
St::Video: video_embed_state::IsSet,
{
pub fn build(self) -> VideoEmbed<S> {
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<SmolStr, Data<S>>) -> VideoEmbed<S> {
VideoEmbed {
alt: self._fields.0,
aspect_ratio: self._fields.1,
thumbnail: self._fields.2,
video: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}