#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::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;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Block<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub alignment: Option<BlockAlignment<'a>>,
#[serde(borrow)]
pub block: BlockBlock<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum BlockAlignment<'a> {
TextAlignLeft,
TextAlignCenter,
TextAlignRight,
TextAlignJustify,
Other(CowStr<'a>),
}
impl<'a> BlockAlignment<'a> {
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(),
}
}
}
impl<'a> From<&'a str> for BlockAlignment<'a> {
fn from(s: &'a str) -> Self {
match s {
"#textAlignLeft" => Self::TextAlignLeft,
"#textAlignCenter" => Self::TextAlignCenter,
"#textAlignRight" => Self::TextAlignRight,
"#textAlignJustify" => Self::TextAlignJustify,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> From<String> for BlockAlignment<'a> {
fn from(s: String) -> Self {
match s.as_str() {
"#textAlignLeft" => Self::TextAlignLeft,
"#textAlignCenter" => Self::TextAlignCenter,
"#textAlignRight" => Self::TextAlignRight,
"#textAlignJustify" => Self::TextAlignJustify,
_ => Self::Other(CowStr::from(s)),
}
}
}
impl<'a> core::fmt::Display for BlockAlignment<'a> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<'a> AsRef<str> for BlockAlignment<'a> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<'a> serde::Serialize for BlockAlignment<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, 'a> serde::Deserialize<'de> for BlockAlignment<'a>
where
'de: 'a,
{
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = <&'de str>::deserialize(deserializer)?;
Ok(Self::from(s))
}
}
impl<'a> Default for BlockAlignment<'a> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl jacquard_common::IntoStatic for BlockAlignment<'_> {
type Output = BlockAlignment<'static>;
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 = "'de: 'a"))]
pub enum BlockBlock<'a> {
#[serde(rename = "pub.leaflet.blocks.iframe")]
Iframe(Box<Iframe<'a>>),
#[serde(rename = "pub.leaflet.blocks.text")]
Text(Box<Text<'a>>),
#[serde(rename = "pub.leaflet.blocks.blockquote")]
Blockquote(Box<Blockquote<'a>>),
#[serde(rename = "pub.leaflet.blocks.header")]
Header(Box<Header<'a>>),
#[serde(rename = "pub.leaflet.blocks.image")]
Image(Box<Image<'a>>),
#[serde(rename = "pub.leaflet.blocks.unorderedList")]
UnorderedList(Box<UnorderedList<'a>>),
#[serde(rename = "pub.leaflet.blocks.orderedList")]
OrderedList(Box<OrderedList<'a>>),
#[serde(rename = "pub.leaflet.blocks.website")]
Website(Box<Website<'a>>),
#[serde(rename = "pub.leaflet.blocks.math")]
Math(Box<Math<'a>>),
#[serde(rename = "pub.leaflet.blocks.code")]
Code(Box<Code<'a>>),
#[serde(rename = "pub.leaflet.blocks.horizontalRule")]
HorizontalRule(Box<HorizontalRule<'a>>),
#[serde(rename = "pub.leaflet.blocks.bskyPost")]
BskyPost(Box<BskyPost<'a>>),
#[serde(rename = "pub.leaflet.blocks.page")]
Page(Box<Page<'a>>),
#[serde(rename = "pub.leaflet.blocks.poll")]
Poll(Box<Poll<'a>>),
#[serde(rename = "pub.leaflet.blocks.button")]
Button(Box<Button<'a>>),
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct LinearDocument<'a> {
#[serde(borrow)]
pub blocks: Vec<linear_document::Block<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub id: Option<CowStr<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Position<'a> {
pub block: Vec<i64>,
pub offset: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Quote<'a> {
#[serde(borrow)]
pub end: linear_document::Position<'a>,
#[serde(borrow)]
pub start: linear_document::Position<'a>,
}
#[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<'a> LexiconSchema for Block<'a> {
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<'a> LexiconSchema for LinearDocument<'a> {
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<'a> LexiconSchema for Position<'a> {
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<'a> LexiconSchema for Quote<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBlock<S> {}
impl<S: State> State for SetBlock<S> {
type Block = Set<members::block>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct block(());
}
}
pub struct BlockBuilder<'a, S: block_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<BlockAlignment<'a>>, Option<BlockBlock<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Block<'a> {
pub fn new() -> BlockBuilder<'a, block_state::Empty> {
BlockBuilder::new()
}
}
impl<'a> BlockBuilder<'a, block_state::Empty> {
pub fn new() -> Self {
BlockBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: block_state::State> BlockBuilder<'a, S> {
pub fn alignment(mut self, value: impl Into<Option<BlockAlignment<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_alignment(mut self, value: Option<BlockAlignment<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> BlockBuilder<'a, S>
where
S: block_state::State,
S::Block: block_state::IsUnset,
{
pub fn block(
mut self,
value: impl Into<BlockBlock<'a>>,
) -> BlockBuilder<'a, block_state::SetBlock<S>> {
self._fields.1 = Option::Some(value.into());
BlockBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlockBuilder<'a, S>
where
S: block_state::State,
S::Block: block_state::IsSet,
{
pub fn build(self) -> Block<'a> {
Block {
alignment: self._fields.0,
block: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Block<'a> {
Block {
alignment: self._fields.0,
block: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_pub_leaflet_pages_linearDocument() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBlocks<S> {}
impl<S: State> State for SetBlocks<S> {
type Blocks = Set<members::blocks>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct blocks(());
}
}
pub struct LinearDocumentBuilder<'a, S: linear_document_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<linear_document::Block<'a>>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> LinearDocument<'a> {
pub fn new() -> LinearDocumentBuilder<'a, linear_document_state::Empty> {
LinearDocumentBuilder::new()
}
}
impl<'a> LinearDocumentBuilder<'a, linear_document_state::Empty> {
pub fn new() -> Self {
LinearDocumentBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> LinearDocumentBuilder<'a, S>
where
S: linear_document_state::State,
S::Blocks: linear_document_state::IsUnset,
{
pub fn blocks(
mut self,
value: impl Into<Vec<linear_document::Block<'a>>>,
) -> LinearDocumentBuilder<'a, linear_document_state::SetBlocks<S>> {
self._fields.0 = Option::Some(value.into());
LinearDocumentBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: linear_document_state::State> LinearDocumentBuilder<'a, S> {
pub fn id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_id(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> LinearDocumentBuilder<'a, S>
where
S: linear_document_state::State,
S::Blocks: linear_document_state::IsSet,
{
pub fn build(self) -> LinearDocument<'a> {
LinearDocument {
blocks: self._fields.0.unwrap(),
id: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> LinearDocument<'a> {
LinearDocument {
blocks: self._fields.0.unwrap(),
id: self._fields.1,
extra_data: Some(extra_data),
}
}
}
pub mod position_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Offset;
type Block;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Offset = Unset;
type Block = Unset;
}
pub struct SetOffset<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetOffset<S> {}
impl<S: State> State for SetOffset<S> {
type Offset = Set<members::offset>;
type Block = S::Block;
}
pub struct SetBlock<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetBlock<S> {}
impl<S: State> State for SetBlock<S> {
type Offset = S::Offset;
type Block = Set<members::block>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct offset(());
pub struct block(());
}
}
pub struct PositionBuilder<'a, S: position_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<i64>>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Position<'a> {
pub fn new() -> PositionBuilder<'a, position_state::Empty> {
PositionBuilder::new()
}
}
impl<'a> PositionBuilder<'a, position_state::Empty> {
pub fn new() -> Self {
PositionBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> PositionBuilder<'a, S>
where
S: position_state::State,
S::Block: position_state::IsUnset,
{
pub fn block(
mut self,
value: impl Into<Vec<i64>>,
) -> PositionBuilder<'a, position_state::SetBlock<S>> {
self._fields.0 = Option::Some(value.into());
PositionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PositionBuilder<'a, S>
where
S: position_state::State,
S::Offset: position_state::IsUnset,
{
pub fn offset(
mut self,
value: impl Into<i64>,
) -> PositionBuilder<'a, position_state::SetOffset<S>> {
self._fields.1 = Option::Some(value.into());
PositionBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> PositionBuilder<'a, S>
where
S: position_state::State,
S::Offset: position_state::IsSet,
S::Block: position_state::IsSet,
{
pub fn build(self) -> Position<'a> {
Position {
block: self._fields.0.unwrap(),
offset: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Position<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type End;
type Start;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type End = Unset;
type Start = Unset;
}
pub struct SetEnd<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEnd<S> {}
impl<S: State> State for SetEnd<S> {
type End = Set<members::end>;
type Start = S::Start;
}
pub struct SetStart<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetStart<S> {}
impl<S: State> State for SetStart<S> {
type End = S::End;
type Start = Set<members::start>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct end(());
pub struct start(());
}
}
pub struct QuoteBuilder<'a, S: quote_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<linear_document::Position<'a>>,
Option<linear_document::Position<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Quote<'a> {
pub fn new() -> QuoteBuilder<'a, quote_state::Empty> {
QuoteBuilder::new()
}
}
impl<'a> QuoteBuilder<'a, quote_state::Empty> {
pub fn new() -> Self {
QuoteBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> QuoteBuilder<'a, S>
where
S: quote_state::State,
S::End: quote_state::IsUnset,
{
pub fn end(
mut self,
value: impl Into<linear_document::Position<'a>>,
) -> QuoteBuilder<'a, quote_state::SetEnd<S>> {
self._fields.0 = Option::Some(value.into());
QuoteBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> QuoteBuilder<'a, S>
where
S: quote_state::State,
S::Start: quote_state::IsUnset,
{
pub fn start(
mut self,
value: impl Into<linear_document::Position<'a>>,
) -> QuoteBuilder<'a, quote_state::SetStart<S>> {
self._fields.1 = Option::Some(value.into());
QuoteBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> QuoteBuilder<'a, S>
where
S: quote_state::State,
S::End: quote_state::IsSet,
S::Start: quote_state::IsSet,
{
pub fn build(self) -> Quote<'a> {
Quote {
end: self._fields.0.unwrap(),
start: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Quote<'a> {
Quote {
end: self._fields.0.unwrap(),
start: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}