// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: com.deckbelcher.richtext // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. //! Generated bindings for the `com.deckbelcher.richtext` Lexicon namespace/module. pub mod facet; #[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::value::Data; use jacquard_derive::{IntoStatic, open_union}; use jacquard_lexicon::lexicon::LexiconDoc; use jacquard_lexicon::schema::LexiconSchema; use crate::com_deckbelcher::richtext; use crate::com_deckbelcher::richtext::facet::Facet; #[allow(unused_imports)] use jacquard_lexicon::validation::{ConstraintError, ValidationPath}; use serde::{Deserialize, Serialize}; /// An unordered (bullet) list. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct BulletListBlock { /// The list items. pub items: Vec>, #[serde( flatten, default, deserialize_with = "deserialize_bullet_list_block_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// A code block with optional language hint. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct CodeBlock { /// Optional language identifier for syntax highlighting. #[serde(skip_serializing_if = "Option::is_none")] pub language: Option, /// The code content (plain text, no facets). pub text: S, #[serde( flatten, default, deserialize_with = "deserialize_code_block_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// A multi-block rich text document. /// Used for primers and other long-form content. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct Document { /// Array of blocks (paragraphs, headings, etc). pub content: Vec>, #[serde( flatten, default, deserialize_with = "deserialize_document_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } #[open_union] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub enum DocumentContentItem { #[serde(rename = "com.deckbelcher.richtext#paragraphBlock")] ParagraphBlock(Box>), #[serde(rename = "com.deckbelcher.richtext#headingBlock")] HeadingBlock(Box>), #[serde(rename = "com.deckbelcher.richtext#codeBlock")] CodeBlock(Box>), #[serde(rename = "com.deckbelcher.richtext#bulletListBlock")] BulletListBlock(Box>), #[serde(rename = "com.deckbelcher.richtext#orderedListBlock")] OrderedListBlock(Box>), #[serde(rename = "com.deckbelcher.richtext#horizontalRuleBlock")] HorizontalRuleBlock(Box>), } /// A heading block with level, text, and optional facets. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct HeadingBlock { /// Annotations of text (formatting, mentions, links, etc). #[serde(skip_serializing_if = "Option::is_none")] pub facets: Option>>, /// Heading level (1-6). pub level: i64, /// The plain text content (no markdown symbols). #[serde(skip_serializing_if = "Option::is_none")] pub text: Option, #[serde( flatten, default, deserialize_with = "deserialize_heading_block_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// A horizontal rule (thematic break). #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct HorizontalRuleBlock { #[serde( flatten, default, deserialize_with = "deserialize_horizontal_rule_block_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// A single list item with text, optional facets, and optional sublist. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct ListItem { /// Annotations of text (formatting, mentions, links, etc). #[serde(skip_serializing_if = "Option::is_none")] pub facets: Option>>, /// Optional nested sublist (bullet or ordered). #[serde(skip_serializing_if = "Option::is_none")] pub sublist: Option>, /// The plain text content (no markdown symbols). #[serde(skip_serializing_if = "Option::is_none")] pub text: Option, #[serde( flatten, default, deserialize_with = "deserialize_list_item_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } #[open_union] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))] pub enum ListItemSublist { #[serde(rename = "com.deckbelcher.richtext#bulletListBlock")] BulletListBlock(Box>), #[serde(rename = "com.deckbelcher.richtext#orderedListBlock")] OrderedListBlock(Box>), } /// A single paragraph of rich text with optional facet annotations. /// Used for descriptions and other short formatted text. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct Richtext { /// Annotations of text (mentions, URLs, hashtags, formatting, etc). #[serde(skip_serializing_if = "Option::is_none")] pub facets: Option>>, /// The plain text content (no markdown symbols). #[serde(skip_serializing_if = "Option::is_none")] pub text: Option, #[serde( flatten, default, deserialize_with = "deserialize_richtext_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// An ordered (numbered) list. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct OrderedListBlock { /// The list items. pub items: Vec>, /// Starting number (default 1). #[serde(skip_serializing_if = "Option::is_none")] pub start: Option, #[serde( flatten, default, deserialize_with = "deserialize_ordered_list_block_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } /// A paragraph block with text and optional facets. #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)] #[serde( rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr") )] pub struct ParagraphBlock { /// Annotations of text (formatting, mentions, links, etc). #[serde(skip_serializing_if = "Option::is_none")] pub facets: Option>>, /// The plain text content (no markdown symbols). #[serde(skip_serializing_if = "Option::is_none")] pub text: Option, #[serde( flatten, default, deserialize_with = "deserialize_paragraph_block_extra_data", skip_serializing_if = "Option::is_none" )] pub extra_data: Option>>, } impl LexiconSchema for BulletListBlock { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "bulletListBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } impl LexiconSchema for CodeBlock { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "codeBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.language { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 50usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("language"), max: 50usize, actual: ::len(value.as_ref()), }); } } { let value = &self.text; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 100000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 100000usize, actual: ::len(value.as_ref()), }); } } Ok(()) } } impl LexiconSchema for Document { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "document" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } impl LexiconSchema for HeadingBlock { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "headingBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { { let value = &self.level; if *value > 6i64 { return Err(ConstraintError::Maximum { path: ValidationPath::from_field("level"), max: 6i64, actual: *value, }); } } { let value = &self.level; if *value < 1i64 { return Err(ConstraintError::Minimum { path: ValidationPath::from_field("level"), min: 1i64, actual: *value, }); } } if let Some(ref value) = self.text { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 10000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 10000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref 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 LexiconSchema for HorizontalRuleBlock { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "horizontalRuleBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } impl LexiconSchema for ListItem { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "listItem" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.text { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 100000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 100000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.text { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 10000usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("text"), max: 10000usize, actual: count, }); } } } Ok(()) } } impl LexiconSchema for Richtext { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.text { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 500000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 500000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.text { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 50000usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("text"), max: 50000usize, actual: count, }); } } } Ok(()) } } impl LexiconSchema for OrderedListBlock { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "orderedListBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { Ok(()) } } impl LexiconSchema for ParagraphBlock { fn nsid() -> &'static str { "com.deckbelcher.richtext" } fn def_name() -> &'static str { "paragraphBlock" } fn lexicon_doc() -> LexiconDoc<'static> { lexicon_doc_com_deckbelcher_richtext() } fn validate(&self) -> Result<(), ConstraintError> { if let Some(ref value) = self.text { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 500000usize { return Err(ConstraintError::MaxLength { path: ValidationPath::from_field("text"), max: 500000usize, actual: ::len(value.as_ref()), }); } } if let Some(ref value) = self.text { { let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count(); if count > 50000usize { return Err(ConstraintError::MaxGraphemes { path: ValidationPath::from_field("text"), max: 50000usize, actual: count, }); } } } Ok(()) } } fn deserialize_bullet_list_block_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } pub mod bullet_list_block_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Items; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Items = Unset; } ///State transition - sets the `items` field to Set pub struct SetItems(PhantomData St>); impl sealed::Sealed for SetItems {} impl State for SetItems { type Items = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `items` field pub struct items(()); } } /// Builder for constructing an instance of this type. pub struct BulletListBlockBuilder { _state: PhantomData St>, _fields: (Option>>,), _type: PhantomData S>, } impl BulletListBlock { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> BulletListBlockBuilder { BulletListBlockBuilder::new() } } impl BulletListBlock { /// Create a new builder for this type pub fn builder() -> BulletListBlockBuilder { BulletListBlockBuilder::builder() } } impl BulletListBlockBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { BulletListBlockBuilder { _state: PhantomData, _fields: (None,), _type: PhantomData, } } } impl BulletListBlockBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { BulletListBlockBuilder { _state: PhantomData, _fields: (None,), _type: PhantomData, } } } impl BulletListBlockBuilder where St: bullet_list_block_state::State, St::Items: bullet_list_block_state::IsUnset, { /// Set the `items` field (required) pub fn items( mut self, value: impl Into>>, ) -> BulletListBlockBuilder, S> { self._fields.0 = Option::Some(value.into()); BulletListBlockBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl BulletListBlockBuilder where St: bullet_list_block_state::State, St::Items: bullet_list_block_state::IsSet, { /// Build the final struct. pub fn build(self) -> BulletListBlock { BulletListBlock { items: self._fields.0.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> BulletListBlock { BulletListBlock { items: self._fields.0.unwrap(), extra_data: Some(extra_data), } } } fn lexicon_doc_com_deckbelcher_richtext() -> 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("com.deckbelcher.richtext"), defs: { let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("bulletListBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static("An unordered (bullet) list.")), required: Some(vec![SmolStr::new_static("items")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("items"), LexObjectProperty::Array(LexArray { description: Some(CowStr::new_static("The list items.")), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("#listItem"), ..Default::default() }), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("codeBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static( "A code block with optional language hint.", )), required: Some(vec![SmolStr::new_static("text")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("language"), LexObjectProperty::String(LexString { description: Some(CowStr::new_static( "Optional language identifier for syntax highlighting.", )), max_length: Some(50usize), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { description: Some(CowStr::new_static( "The code content (plain text, no facets).", )), max_length: Some(100000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("document"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A multi-block rich text document.\nUsed for primers and other long-form content.", ), ), required: Some(vec![SmolStr::new_static("content")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("content"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static( "Array of blocks (paragraphs, headings, etc).", ), ), items: LexArrayItem::Union(LexRefUnion { refs: vec![ CowStr::new_static("#paragraphBlock"), CowStr::new_static("#headingBlock"), CowStr::new_static("#codeBlock"), CowStr::new_static("#bulletListBlock"), CowStr::new_static("#orderedListBlock"), CowStr::new_static("#horizontalRuleBlock") ], ..Default::default() }), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("headingBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static( "A heading block with level, text, and optional facets.", )), required: Some(vec![SmolStr::new_static("level")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { description: Some(CowStr::new_static( "Annotations of text (formatting, mentions, links, etc).", )), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("level"), LexObjectProperty::Integer(LexInteger { minimum: Some(1i64), maximum: Some(6i64), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { description: Some(CowStr::new_static( "The plain text content (no markdown symbols).", )), max_length: Some(10000usize), max_graphemes: Some(1000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("horizontalRuleBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static("A horizontal rule (thematic break).")), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("listItem"), LexUserType::Object(LexObject { description: Some(CowStr::new_static( "A single list item with text, optional facets, and optional sublist.", )), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { description: Some(CowStr::new_static( "Annotations of text (formatting, mentions, links, etc).", )), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("sublist"), LexObjectProperty::Union(LexRefUnion { description: Some(CowStr::new_static( "Optional nested sublist (bullet or ordered).", )), refs: vec![ CowStr::new_static("#bulletListBlock"), CowStr::new_static("#orderedListBlock"), ], ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { description: Some(CowStr::new_static( "The plain text content (no markdown symbols).", )), max_length: Some(100000usize), max_graphemes: Some(10000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("main"), LexUserType::Object(LexObject { description: Some( CowStr::new_static( "A single paragraph of rich text with optional facet annotations.\nUsed for descriptions and other short formatted text.", ), ), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { description: Some( CowStr::new_static( "Annotations of text (mentions, URLs, hashtags, formatting, etc).", ), ), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { description: Some( CowStr::new_static( "The plain text content (no markdown symbols).", ), ), max_length: Some(500000usize), max_graphemes: Some(50000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("orderedListBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static("An ordered (numbered) list.")), required: Some(vec![SmolStr::new_static("items")]), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("items"), LexObjectProperty::Array(LexArray { description: Some(CowStr::new_static("The list items.")), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("#listItem"), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("start"), LexObjectProperty::Integer(LexInteger { ..Default::default() }), ); map }, ..Default::default() }), ); map.insert( SmolStr::new_static("paragraphBlock"), LexUserType::Object(LexObject { description: Some(CowStr::new_static( "A paragraph block with text and optional facets.", )), properties: { #[allow(unused_mut)] let mut map = BTreeMap::new(); map.insert( SmolStr::new_static("facets"), LexObjectProperty::Array(LexArray { description: Some(CowStr::new_static( "Annotations of text (formatting, mentions, links, etc).", )), items: LexArrayItem::Ref(LexRef { r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"), ..Default::default() }), ..Default::default() }), ); map.insert( SmolStr::new_static("text"), LexObjectProperty::String(LexString { description: Some(CowStr::new_static( "The plain text content (no markdown symbols).", )), max_length: Some(500000usize), max_graphemes: Some(50000usize), ..Default::default() }), ); map }, ..Default::default() }), ); map }, ..Default::default() } } fn deserialize_code_block_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } fn deserialize_document_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } pub mod document_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Content; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Content = Unset; } ///State transition - sets the `content` field to Set pub struct SetContent(PhantomData St>); impl sealed::Sealed for SetContent {} impl State for SetContent { type Content = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `content` field pub struct content(()); } } /// Builder for constructing an instance of this type. pub struct DocumentBuilder { _state: PhantomData St>, _fields: (Option>>,), _type: PhantomData S>, } impl Document { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> DocumentBuilder { DocumentBuilder::new() } } impl Document { /// Create a new builder for this type pub fn builder() -> DocumentBuilder { DocumentBuilder::builder() } } impl DocumentBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { DocumentBuilder { _state: PhantomData, _fields: (None,), _type: PhantomData, } } } impl DocumentBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { DocumentBuilder { _state: PhantomData, _fields: (None,), _type: PhantomData, } } } impl DocumentBuilder where St: document_state::State, St::Content: document_state::IsUnset, { /// Set the `content` field (required) pub fn content( mut self, value: impl Into>>, ) -> DocumentBuilder, S> { self._fields.0 = Option::Some(value.into()); DocumentBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl DocumentBuilder where St: document_state::State, St::Content: document_state::IsSet, { /// Build the final struct. pub fn build(self) -> Document { Document { content: self._fields.0.unwrap(), extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> Document { Document { content: self._fields.0.unwrap(), extra_data: Some(extra_data), } } } fn deserialize_heading_block_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } pub mod heading_block_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Level; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Level = Unset; } ///State transition - sets the `level` field to Set pub struct SetLevel(PhantomData St>); impl sealed::Sealed for SetLevel {} impl State for SetLevel { type Level = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `level` field pub struct level(()); } } /// Builder for constructing an instance of this type. pub struct HeadingBlockBuilder { _state: PhantomData St>, _fields: (Option>>, Option, Option), _type: PhantomData S>, } impl HeadingBlock { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> HeadingBlockBuilder { HeadingBlockBuilder::new() } } impl HeadingBlock { /// Create a new builder for this type pub fn builder() -> HeadingBlockBuilder { HeadingBlockBuilder::builder() } } impl HeadingBlockBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { HeadingBlockBuilder { _state: PhantomData, _fields: (None, None, None), _type: PhantomData, } } } impl HeadingBlockBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { HeadingBlockBuilder { _state: PhantomData, _fields: (None, None, None), _type: PhantomData, } } } impl HeadingBlockBuilder { /// Set the `facets` field (optional) pub fn facets(mut self, value: impl Into>>>) -> Self { self._fields.0 = value.into(); self } /// Set the `facets` field to an Option value (optional) pub fn maybe_facets(mut self, value: Option>>) -> Self { self._fields.0 = value; self } } impl HeadingBlockBuilder where St: heading_block_state::State, St::Level: heading_block_state::IsUnset, { /// Set the `level` field (required) pub fn level( mut self, value: impl Into, ) -> HeadingBlockBuilder, S> { self._fields.1 = Option::Some(value.into()); HeadingBlockBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl HeadingBlockBuilder { /// Set the `text` field (optional) pub fn text(mut self, value: impl Into>) -> Self { self._fields.2 = value.into(); self } /// Set the `text` field to an Option value (optional) pub fn maybe_text(mut self, value: Option) -> Self { self._fields.2 = value; self } } impl HeadingBlockBuilder where St: heading_block_state::State, St::Level: heading_block_state::IsSet, { /// Build the final struct. pub fn build(self) -> HeadingBlock { HeadingBlock { facets: self._fields.0, level: self._fields.1.unwrap(), text: self._fields.2, extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> HeadingBlock { HeadingBlock { facets: self._fields.0, level: self._fields.1.unwrap(), text: self._fields.2, extra_data: Some(extra_data), } } } fn deserialize_horizontal_rule_block_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } fn deserialize_list_item_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } fn deserialize_richtext_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } fn deserialize_ordered_list_block_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) } pub mod ordered_list_block_state { pub use crate::builder_types::{IsSet, IsUnset, Set, Unset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Items; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Items = Unset; } ///State transition - sets the `items` field to Set pub struct SetItems(PhantomData St>); impl sealed::Sealed for SetItems {} impl State for SetItems { type Items = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `items` field pub struct items(()); } } /// Builder for constructing an instance of this type. pub struct OrderedListBlockBuilder { _state: PhantomData St>, _fields: (Option>>, Option), _type: PhantomData S>, } impl OrderedListBlock { /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed pub fn new() -> OrderedListBlockBuilder { OrderedListBlockBuilder::new() } } impl OrderedListBlock { /// Create a new builder for this type pub fn builder() -> OrderedListBlockBuilder { OrderedListBlockBuilder::builder() } } impl OrderedListBlockBuilder { /// Create a new builder with all fields unset, using the default string type, if needed pub fn new() -> Self { OrderedListBlockBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl OrderedListBlockBuilder { /// Create a new builder with all fields unset pub fn builder() -> Self { OrderedListBlockBuilder { _state: PhantomData, _fields: (None, None), _type: PhantomData, } } } impl OrderedListBlockBuilder where St: ordered_list_block_state::State, St::Items: ordered_list_block_state::IsUnset, { /// Set the `items` field (required) pub fn items( mut self, value: impl Into>>, ) -> OrderedListBlockBuilder, S> { self._fields.0 = Option::Some(value.into()); OrderedListBlockBuilder { _state: PhantomData, _fields: self._fields, _type: PhantomData, } } } impl OrderedListBlockBuilder { /// Set the `start` field (optional) pub fn start(mut self, value: impl Into>) -> Self { self._fields.1 = value.into(); self } /// Set the `start` field to an Option value (optional) pub fn maybe_start(mut self, value: Option) -> Self { self._fields.1 = value; self } } impl OrderedListBlockBuilder where St: ordered_list_block_state::State, St::Items: ordered_list_block_state::IsSet, { /// Build the final struct. pub fn build(self) -> OrderedListBlock { OrderedListBlock { items: self._fields.0.unwrap(), start: self._fields.1, extra_data: Default::default(), } } /// Build the final struct with custom extra_data. pub fn build_with_data(self, extra_data: BTreeMap>) -> OrderedListBlock { OrderedListBlock { items: self._fields.0.unwrap(), start: self._fields.1, extra_data: Some(extra_data), } } } fn deserialize_paragraph_block_extra_data<'de, S, D>( deserializer: D, ) -> Result>>, D::Error> where S: BosStr + serde::Deserialize<'de>, D: serde::Deserializer<'de>, { let data = >> as serde::Deserialize<'de>>::deserialize(deserializer)?; Ok(data.filter(|extra_data| !extra_data.is_empty())) }