#[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::pub_leaflet::blocks::blockquote::Blockquote;
use crate::pub_leaflet::blocks::bsky_post::BskyPost;
use crate::pub_leaflet::blocks::button::Button;
use crate::pub_leaflet::blocks::code::Code;
use crate::pub_leaflet::blocks::header::Header;
use crate::pub_leaflet::blocks::horizontal_rule::HorizontalRule;
use crate::pub_leaflet::blocks::iframe::Iframe;
use crate::pub_leaflet::blocks::image::Image;
use crate::pub_leaflet::blocks::math::Math;
use crate::pub_leaflet::blocks::ordered_list::OrderedList;
use crate::pub_leaflet::blocks::page::Page;
use crate::pub_leaflet::blocks::poll::Poll;
use crate::pub_leaflet::blocks::text::Text;
use crate::pub_leaflet::blocks::unordered_list::UnorderedList;
use crate::pub_leaflet::blocks::website::Website;
use crate::pub_leaflet::pages::linear_document;
#[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 Block<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub alignment: Option<BlockAlignment<S>>,
pub block: BlockBlock<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BlockAlignment<S: BosStr = DefaultStr> {
TextAlignLeft,
TextAlignCenter,
TextAlignRight,
TextAlignJustify,
Other(S),
}
impl<S: BosStr> BlockAlignment<S> {
pub fn as_str(&self) -> &str {
match self {
Self::TextAlignLeft => "#textAlignLeft",
Self::TextAlignCenter => "#textAlignCenter",
Self::TextAlignRight => "#textAlignRight",
Self::TextAlignJustify => "#textAlignJustify",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"#textAlignLeft" => Self::TextAlignLeft,
"#textAlignCenter" => Self::TextAlignCenter,
"#textAlignRight" => Self::TextAlignRight,
"#textAlignJustify" => Self::TextAlignJustify,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for BlockAlignment<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for BlockAlignment<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for BlockAlignment<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for BlockAlignment<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for BlockAlignment<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for BlockAlignment<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = BlockAlignment<S::Output>;
fn into_static(self) -> Self::Output {
match self {
BlockAlignment::TextAlignLeft => BlockAlignment::TextAlignLeft,
BlockAlignment::TextAlignCenter => BlockAlignment::TextAlignCenter,
BlockAlignment::TextAlignRight => BlockAlignment::TextAlignRight,
BlockAlignment::TextAlignJustify => BlockAlignment::TextAlignJustify,
BlockAlignment::Other(v) => BlockAlignment::Other(v.into_static()),
}
}
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum BlockBlock<S: BosStr = DefaultStr> {
#[serde(rename = "pub.leaflet.blocks.iframe")]
Iframe(Box<Iframe<S>>),
#[serde(rename = "pub.leaflet.blocks.text")]
Text(Box<Text<S>>),
#[serde(rename = "pub.leaflet.blocks.blockquote")]
Blockquote(Box<Blockquote<S>>),
#[serde(rename = "pub.leaflet.blocks.header")]
Header(Box<Header<S>>),
#[serde(rename = "pub.leaflet.blocks.image")]
Image(Box<Image<S>>),
#[serde(rename = "pub.leaflet.blocks.unorderedList")]
UnorderedList(Box<UnorderedList<S>>),
#[serde(rename = "pub.leaflet.blocks.orderedList")]
OrderedList(Box<OrderedList<S>>),
#[serde(rename = "pub.leaflet.blocks.website")]
Website(Box<Website<S>>),
#[serde(rename = "pub.leaflet.blocks.math")]
Math(Box<Math<S>>),
#[serde(rename = "pub.leaflet.blocks.code")]
Code(Box<Code<S>>),
#[serde(rename = "pub.leaflet.blocks.horizontalRule")]
HorizontalRule(Box<HorizontalRule<S>>),
#[serde(rename = "pub.leaflet.blocks.bskyPost")]
BskyPost(Box<BskyPost<S>>),
#[serde(rename = "pub.leaflet.blocks.page")]
Page(Box<Page<S>>),
#[serde(rename = "pub.leaflet.blocks.poll")]
Poll(Box<Poll<S>>),
#[serde(rename = "pub.leaflet.blocks.button")]
Button(Box<Button<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct LinearDocument<S: BosStr = DefaultStr> {
pub blocks: Vec<linear_document::Block<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub id: 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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Position<S: BosStr = DefaultStr> {
pub block: Vec<i64>,
pub offset: 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)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Quote<S: BosStr = DefaultStr> {
pub end: linear_document::Position<S>,
pub start: linear_document::Position<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, Hash)]
pub struct TextAlignCenter;
impl core::fmt::Display for TextAlignCenter {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "textAlignCenter")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct TextAlignJustify;
impl core::fmt::Display for TextAlignJustify {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "textAlignJustify")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct TextAlignLeft;
impl core::fmt::Display for TextAlignLeft {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "textAlignLeft")
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
pub struct TextAlignRight;
impl core::fmt::Display for TextAlignRight {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "textAlignRight")
}
}
impl<S: BosStr> LexiconSchema for Block<S> {
fn nsid() -> &'static str {
"pub.leaflet.pages.linearDocument"
}
fn def_name() -> &'static str {
"block"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_linearDocument()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for LinearDocument<S> {
fn nsid() -> &'static str {
"pub.leaflet.pages.linearDocument"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_linearDocument()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Position<S> {
fn nsid() -> &'static str {
"pub.leaflet.pages.linearDocument"
}
fn def_name() -> &'static str {
"position"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_linearDocument()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Quote<S> {
fn nsid() -> &'static str {
"pub.leaflet.pages.linearDocument"
}
fn def_name() -> &'static str {
"quote"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_linearDocument()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod block_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 Block;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Block = Unset;
}
pub struct SetBlock<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlock<St> {}
impl<St: State> State for SetBlock<St> {
type Block = Set<members::block>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct block(());
}
}
pub struct BlockBuilder<S: BosStr, St: block_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<BlockAlignment<S>>, Option<BlockBlock<S>>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Block<S> {
pub fn new() -> BlockBuilder<S, block_state::Empty> {
BlockBuilder::new()
}
}
impl<S: BosStr> BlockBuilder<S, block_state::Empty> {
pub fn new() -> Self {
BlockBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: block_state::State> BlockBuilder<S, St> {
pub fn alignment(mut self, value: impl Into<Option<BlockAlignment<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alignment(mut self, value: Option<BlockAlignment<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> BlockBuilder<S, St>
where
St: block_state::State,
St::Block: block_state::IsUnset,
{
pub fn block(
mut self,
value: impl Into<BlockBlock<S>>,
) -> BlockBuilder<S, block_state::SetBlock<St>> {
self._fields.1 = Option::Some(value.into());
BlockBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlockBuilder<S, St>
where
St: block_state::State,
St::Block: block_state::IsSet,
{
pub fn build(self) -> Block<S> {
Block {
alignment: self._fields.0,
block: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Block<S> {
Block {
alignment: self._fields.0,
block: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_pub_leaflet_pages_linearDocument() -> 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("pub.leaflet.pages.linearDocument"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("block"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("block")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("alignment"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("block"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("pub.leaflet.blocks.iframe"),
CowStr::new_static("pub.leaflet.blocks.text"),
CowStr::new_static("pub.leaflet.blocks.blockquote"),
CowStr::new_static("pub.leaflet.blocks.header"),
CowStr::new_static("pub.leaflet.blocks.image"),
CowStr::new_static("pub.leaflet.blocks.unorderedList"),
CowStr::new_static("pub.leaflet.blocks.orderedList"),
CowStr::new_static("pub.leaflet.blocks.website"),
CowStr::new_static("pub.leaflet.blocks.math"),
CowStr::new_static("pub.leaflet.blocks.code"),
CowStr::new_static("pub.leaflet.blocks.horizontalRule"),
CowStr::new_static("pub.leaflet.blocks.bskyPost"),
CowStr::new_static("pub.leaflet.blocks.page"),
CowStr::new_static("pub.leaflet.blocks.poll"),
CowStr::new_static("pub.leaflet.blocks.button"),
],
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("blocks")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blocks"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#block"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("id"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("position"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("block"),
SmolStr::new_static("offset"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("block"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Integer(LexInteger {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("offset"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("quote"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("start"),
SmolStr::new_static("end"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("end"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#position"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("start"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#position"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("textAlignCenter"),
LexUserType::Token(LexToken {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("textAlignJustify"),
LexUserType::Token(LexToken {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("textAlignLeft"),
LexUserType::Token(LexToken {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("textAlignRight"),
LexUserType::Token(LexToken {
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod linear_document_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 Blocks;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Blocks = Unset;
}
pub struct SetBlocks<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlocks<St> {}
impl<St: State> State for SetBlocks<St> {
type Blocks = Set<members::blocks>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blocks(());
}
}
pub struct LinearDocumentBuilder<S: BosStr, St: linear_document_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<linear_document::Block<S>>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> LinearDocument<S> {
pub fn new() -> LinearDocumentBuilder<S, linear_document_state::Empty> {
LinearDocumentBuilder::new()
}
}
impl<S: BosStr> LinearDocumentBuilder<S, linear_document_state::Empty> {
pub fn new() -> Self {
LinearDocumentBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> LinearDocumentBuilder<S, St>
where
St: linear_document_state::State,
St::Blocks: linear_document_state::IsUnset,
{
pub fn blocks(
mut self,
value: impl Into<Vec<linear_document::Block<S>>>,
) -> LinearDocumentBuilder<S, linear_document_state::SetBlocks<St>> {
self._fields.0 = Option::Some(value.into());
LinearDocumentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: linear_document_state::State> LinearDocumentBuilder<S, St> {
pub fn id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_id(mut self, value: Option<S>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> LinearDocumentBuilder<S, St>
where
St: linear_document_state::State,
St::Blocks: linear_document_state::IsSet,
{
pub fn build(self) -> LinearDocument<S> {
LinearDocument {
blocks: self._fields.0.unwrap(),
id: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> LinearDocument<S> {
LinearDocument {
blocks: self._fields.0.unwrap(),
id: self._fields.1,
extra_data: Some(extra_data),
}
}
}
pub mod position_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 Offset;
type Block;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Offset = Unset;
type Block = Unset;
}
pub struct SetOffset<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetOffset<St> {}
impl<St: State> State for SetOffset<St> {
type Offset = Set<members::offset>;
type Block = St::Block;
}
pub struct SetBlock<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlock<St> {}
impl<St: State> State for SetBlock<St> {
type Offset = St::Offset;
type Block = Set<members::block>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct offset(());
pub struct block(());
}
}
pub struct PositionBuilder<S: BosStr, St: position_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<i64>>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Position<S> {
pub fn new() -> PositionBuilder<S, position_state::Empty> {
PositionBuilder::new()
}
}
impl<S: BosStr> PositionBuilder<S, position_state::Empty> {
pub fn new() -> Self {
PositionBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PositionBuilder<S, St>
where
St: position_state::State,
St::Block: position_state::IsUnset,
{
pub fn block(
mut self,
value: impl Into<Vec<i64>>,
) -> PositionBuilder<S, position_state::SetBlock<St>> {
self._fields.0 = Option::Some(value.into());
PositionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PositionBuilder<S, St>
where
St: position_state::State,
St::Offset: position_state::IsUnset,
{
pub fn offset(
mut self,
value: impl Into<i64>,
) -> PositionBuilder<S, position_state::SetOffset<St>> {
self._fields.1 = Option::Some(value.into());
PositionBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> PositionBuilder<S, St>
where
St: position_state::State,
St::Offset: position_state::IsSet,
St::Block: position_state::IsSet,
{
pub fn build(self) -> Position<S> {
Position {
block: self._fields.0.unwrap(),
offset: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Position<S> {
Position {
block: self._fields.0.unwrap(),
offset: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod quote_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 Start;
type End;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Start = Unset;
type End = Unset;
}
pub struct SetStart<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetStart<St> {}
impl<St: State> State for SetStart<St> {
type Start = Set<members::start>;
type End = St::End;
}
pub struct SetEnd<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEnd<St> {}
impl<St: State> State for SetEnd<St> {
type Start = St::Start;
type End = Set<members::end>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct start(());
pub struct end(());
}
}
pub struct QuoteBuilder<S: BosStr, St: quote_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<linear_document::Position<S>>,
Option<linear_document::Position<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Quote<S> {
pub fn new() -> QuoteBuilder<S, quote_state::Empty> {
QuoteBuilder::new()
}
}
impl<S: BosStr> QuoteBuilder<S, quote_state::Empty> {
pub fn new() -> Self {
QuoteBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> QuoteBuilder<S, St>
where
St: quote_state::State,
St::End: quote_state::IsUnset,
{
pub fn end(
mut self,
value: impl Into<linear_document::Position<S>>,
) -> QuoteBuilder<S, quote_state::SetEnd<St>> {
self._fields.0 = Option::Some(value.into());
QuoteBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> QuoteBuilder<S, St>
where
St: quote_state::State,
St::Start: quote_state::IsUnset,
{
pub fn start(
mut self,
value: impl Into<linear_document::Position<S>>,
) -> QuoteBuilder<S, quote_state::SetStart<St>> {
self._fields.1 = Option::Some(value.into());
QuoteBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> QuoteBuilder<S, St>
where
St: quote_state::State,
St::Start: quote_state::IsSet,
St::End: quote_state::IsSet,
{
pub fn build(self) -> Quote<S> {
Quote {
end: self._fields.0.unwrap(),
start: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Quote<S> {
Quote {
end: self._fields.0.unwrap(),
start: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}