#[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::canvas;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Block<'a> {
#[serde(borrow)]
pub block: BlockBlock<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub rotation: Option<i64>,
pub width: i64,
pub x: i64,
pub y: i64,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(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 Canvas<'a> {
#[serde(borrow)]
pub blocks: Vec<canvas::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: canvas::Position<'a>,
#[serde(borrow)]
pub start: canvas::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 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.canvas"
}
fn def_name() -> &'static str {
"block"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_canvas()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Canvas<'a> {
fn nsid() -> &'static str {
"pub.leaflet.pages.canvas"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_canvas()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Position<'a> {
fn nsid() -> &'static str {
"pub.leaflet.pages.canvas"
}
fn def_name() -> &'static str {
"position"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_canvas()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<'a> LexiconSchema for Quote<'a> {
fn nsid() -> &'static str {
"pub.leaflet.pages.canvas"
}
fn def_name() -> &'static str {
"quote"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_pages_canvas()
}
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;
type Width;
type Y;
type X;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Block = Unset;
type Width = Unset;
type Y = Unset;
type X = 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>;
type Width = S::Width;
type Y = S::Y;
type X = S::X;
}
pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWidth<S> {}
impl<S: State> State for SetWidth<S> {
type Block = S::Block;
type Width = Set<members::width>;
type Y = S::Y;
type X = S::X;
}
pub struct SetY<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetY<S> {}
impl<S: State> State for SetY<S> {
type Block = S::Block;
type Width = S::Width;
type Y = Set<members::y>;
type X = S::X;
}
pub struct SetX<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetX<S> {}
impl<S: State> State for SetX<S> {
type Block = S::Block;
type Width = S::Width;
type Y = S::Y;
type X = Set<members::x>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct block(());
pub struct width(());
pub struct y(());
pub struct x(());
}
}
pub struct BlockBuilder<'a, S: block_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<BlockBlock<'a>>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
Option<i64>,
),
_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, None, None, None, None),
_lifetime: PhantomData,
}
}
}
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.0 = Option::Some(value.into());
BlockBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: block_state::State> BlockBuilder<'a, S> {
pub fn height(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_height(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S: block_state::State> BlockBuilder<'a, S> {
pub fn rotation(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_rotation(mut self, value: Option<i64>) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> BlockBuilder<'a, S>
where
S: block_state::State,
S::Width: block_state::IsUnset,
{
pub fn width(
mut self,
value: impl Into<i64>,
) -> BlockBuilder<'a, block_state::SetWidth<S>> {
self._fields.3 = Option::Some(value.into());
BlockBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlockBuilder<'a, S>
where
S: block_state::State,
S::X: block_state::IsUnset,
{
pub fn x(mut self, value: impl Into<i64>) -> BlockBuilder<'a, block_state::SetX<S>> {
self._fields.4 = Option::Some(value.into());
BlockBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlockBuilder<'a, S>
where
S: block_state::State,
S::Y: block_state::IsUnset,
{
pub fn y(mut self, value: impl Into<i64>) -> BlockBuilder<'a, block_state::SetY<S>> {
self._fields.5 = 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,
S::Width: block_state::IsSet,
S::Y: block_state::IsSet,
S::X: block_state::IsSet,
{
pub fn build(self) -> Block<'a> {
Block {
block: self._fields.0.unwrap(),
height: self._fields.1,
rotation: self._fields.2,
width: self._fields.3.unwrap(),
x: self._fields.4.unwrap(),
y: self._fields.5.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Block<'a> {
Block {
block: self._fields.0.unwrap(),
height: self._fields.1,
rotation: self._fields.2,
width: self._fields.3.unwrap(),
x: self._fields.4.unwrap(),
y: self._fields.5.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_pub_leaflet_pages_canvas() -> 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.canvas"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("block"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("block"), SmolStr::new_static("x"),
SmolStr::new_static("y"), SmolStr::new_static("width")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
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.insert(
SmolStr::new_static("height"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rotation"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("width"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("x"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("y"),
LexObjectProperty::Integer(LexInteger {
..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("textAlignLeft"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map.insert(
SmolStr::new_static("textAlignRight"),
LexUserType::Token(LexToken { ..Default::default() }),
);
map
},
..Default::default()
}
}
pub mod canvas_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 CanvasBuilder<'a, S: canvas_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<Vec<canvas::Block<'a>>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Canvas<'a> {
pub fn new() -> CanvasBuilder<'a, canvas_state::Empty> {
CanvasBuilder::new()
}
}
impl<'a> CanvasBuilder<'a, canvas_state::Empty> {
pub fn new() -> Self {
CanvasBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CanvasBuilder<'a, S>
where
S: canvas_state::State,
S::Blocks: canvas_state::IsUnset,
{
pub fn blocks(
mut self,
value: impl Into<Vec<canvas::Block<'a>>>,
) -> CanvasBuilder<'a, canvas_state::SetBlocks<S>> {
self._fields.0 = Option::Some(value.into());
CanvasBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: canvas_state::State> CanvasBuilder<'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> CanvasBuilder<'a, S>
where
S: canvas_state::State,
S::Blocks: canvas_state::IsSet,
{
pub fn build(self) -> Canvas<'a> {
Canvas {
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>,
>,
) -> Canvas<'a> {
Canvas {
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 Start;
type End;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Start = Unset;
type End = Unset;
}
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 Start = Set<members::start>;
type End = S::End;
}
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 Start = S::Start;
type End = Set<members::end>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct start(());
pub struct end(());
}
}
pub struct QuoteBuilder<'a, S: quote_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<canvas::Position<'a>>, Option<canvas::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<canvas::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<canvas::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::Start: quote_state::IsSet,
S::End: 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),
}
}
}