Skip to main content

jacquard_api/pub_leaflet/pages/
linear_document.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: pub.leaflet.pages.linearDocument
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_derive::{IntoStatic, lexicon, open_union};
18use jacquard_lexicon::lexicon::LexiconDoc;
19use jacquard_lexicon::schema::LexiconSchema;
20
21#[allow(unused_imports)]
22use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
23use serde::{Serialize, Deserialize};
24use crate::pub_leaflet::blocks::blockquote::Blockquote;
25use crate::pub_leaflet::blocks::bsky_post::BskyPost;
26use crate::pub_leaflet::blocks::button::Button;
27use crate::pub_leaflet::blocks::code::Code;
28use crate::pub_leaflet::blocks::header::Header;
29use crate::pub_leaflet::blocks::horizontal_rule::HorizontalRule;
30use crate::pub_leaflet::blocks::iframe::Iframe;
31use crate::pub_leaflet::blocks::image::Image;
32use crate::pub_leaflet::blocks::math::Math;
33use crate::pub_leaflet::blocks::ordered_list::OrderedList;
34use crate::pub_leaflet::blocks::page::Page;
35use crate::pub_leaflet::blocks::poll::Poll;
36use crate::pub_leaflet::blocks::text::Text;
37use crate::pub_leaflet::blocks::unordered_list::UnorderedList;
38use crate::pub_leaflet::blocks::website::Website;
39use crate::pub_leaflet::pages::linear_document;
40
41#[lexicon]
42#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
43#[serde(rename_all = "camelCase")]
44pub struct Block<'a> {
45    #[serde(skip_serializing_if = "Option::is_none")]
46    #[serde(borrow)]
47    pub alignment: Option<BlockAlignment<'a>>,
48    #[serde(borrow)]
49    pub block: BlockBlock<'a>,
50}
51
52
53#[derive(Debug, Clone, PartialEq, Eq, Hash)]
54pub enum BlockAlignment<'a> {
55    TextAlignLeft,
56    TextAlignCenter,
57    TextAlignRight,
58    TextAlignJustify,
59    Other(CowStr<'a>),
60}
61
62impl<'a> BlockAlignment<'a> {
63    pub fn as_str(&self) -> &str {
64        match self {
65            Self::TextAlignLeft => "#textAlignLeft",
66            Self::TextAlignCenter => "#textAlignCenter",
67            Self::TextAlignRight => "#textAlignRight",
68            Self::TextAlignJustify => "#textAlignJustify",
69            Self::Other(s) => s.as_ref(),
70        }
71    }
72}
73
74impl<'a> From<&'a str> for BlockAlignment<'a> {
75    fn from(s: &'a str) -> Self {
76        match s {
77            "#textAlignLeft" => Self::TextAlignLeft,
78            "#textAlignCenter" => Self::TextAlignCenter,
79            "#textAlignRight" => Self::TextAlignRight,
80            "#textAlignJustify" => Self::TextAlignJustify,
81            _ => Self::Other(CowStr::from(s)),
82        }
83    }
84}
85
86impl<'a> From<String> for BlockAlignment<'a> {
87    fn from(s: String) -> Self {
88        match s.as_str() {
89            "#textAlignLeft" => Self::TextAlignLeft,
90            "#textAlignCenter" => Self::TextAlignCenter,
91            "#textAlignRight" => Self::TextAlignRight,
92            "#textAlignJustify" => Self::TextAlignJustify,
93            _ => Self::Other(CowStr::from(s)),
94        }
95    }
96}
97
98impl<'a> core::fmt::Display for BlockAlignment<'a> {
99    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
100        write!(f, "{}", self.as_str())
101    }
102}
103
104impl<'a> AsRef<str> for BlockAlignment<'a> {
105    fn as_ref(&self) -> &str {
106        self.as_str()
107    }
108}
109
110impl<'a> serde::Serialize for BlockAlignment<'a> {
111    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
112    where
113        S: serde::Serializer,
114    {
115        serializer.serialize_str(self.as_str())
116    }
117}
118
119impl<'de, 'a> serde::Deserialize<'de> for BlockAlignment<'a>
120where
121    'de: 'a,
122{
123    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
124    where
125        D: serde::Deserializer<'de>,
126    {
127        let s = <&'de str>::deserialize(deserializer)?;
128        Ok(Self::from(s))
129    }
130}
131
132impl<'a> Default for BlockAlignment<'a> {
133    fn default() -> Self {
134        Self::Other(Default::default())
135    }
136}
137
138impl jacquard_common::IntoStatic for BlockAlignment<'_> {
139    type Output = BlockAlignment<'static>;
140    fn into_static(self) -> Self::Output {
141        match self {
142            BlockAlignment::TextAlignLeft => BlockAlignment::TextAlignLeft,
143            BlockAlignment::TextAlignCenter => BlockAlignment::TextAlignCenter,
144            BlockAlignment::TextAlignRight => BlockAlignment::TextAlignRight,
145            BlockAlignment::TextAlignJustify => BlockAlignment::TextAlignJustify,
146            BlockAlignment::Other(v) => BlockAlignment::Other(v.into_static()),
147        }
148    }
149}
150
151
152#[open_union]
153#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
154#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
155pub enum BlockBlock<'a> {
156    #[serde(rename = "pub.leaflet.blocks.iframe")]
157    Iframe(Box<Iframe<'a>>),
158    #[serde(rename = "pub.leaflet.blocks.text")]
159    Text(Box<Text<'a>>),
160    #[serde(rename = "pub.leaflet.blocks.blockquote")]
161    Blockquote(Box<Blockquote<'a>>),
162    #[serde(rename = "pub.leaflet.blocks.header")]
163    Header(Box<Header<'a>>),
164    #[serde(rename = "pub.leaflet.blocks.image")]
165    Image(Box<Image<'a>>),
166    #[serde(rename = "pub.leaflet.blocks.unorderedList")]
167    UnorderedList(Box<UnorderedList<'a>>),
168    #[serde(rename = "pub.leaflet.blocks.orderedList")]
169    OrderedList(Box<OrderedList<'a>>),
170    #[serde(rename = "pub.leaflet.blocks.website")]
171    Website(Box<Website<'a>>),
172    #[serde(rename = "pub.leaflet.blocks.math")]
173    Math(Box<Math<'a>>),
174    #[serde(rename = "pub.leaflet.blocks.code")]
175    Code(Box<Code<'a>>),
176    #[serde(rename = "pub.leaflet.blocks.horizontalRule")]
177    HorizontalRule(Box<HorizontalRule<'a>>),
178    #[serde(rename = "pub.leaflet.blocks.bskyPost")]
179    BskyPost(Box<BskyPost<'a>>),
180    #[serde(rename = "pub.leaflet.blocks.page")]
181    Page(Box<Page<'a>>),
182    #[serde(rename = "pub.leaflet.blocks.poll")]
183    Poll(Box<Poll<'a>>),
184    #[serde(rename = "pub.leaflet.blocks.button")]
185    Button(Box<Button<'a>>),
186}
187
188
189#[lexicon]
190#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
191#[serde(rename_all = "camelCase")]
192pub struct LinearDocument<'a> {
193    #[serde(borrow)]
194    pub blocks: Vec<linear_document::Block<'a>>,
195    #[serde(skip_serializing_if = "Option::is_none")]
196    #[serde(borrow)]
197    pub id: Option<CowStr<'a>>,
198}
199
200
201#[lexicon]
202#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
203#[serde(rename_all = "camelCase")]
204pub struct Position<'a> {
205    pub block: Vec<i64>,
206    pub offset: i64,
207}
208
209
210#[lexicon]
211#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
212#[serde(rename_all = "camelCase")]
213pub struct Quote<'a> {
214    #[serde(borrow)]
215    pub end: linear_document::Position<'a>,
216    #[serde(borrow)]
217    pub start: linear_document::Position<'a>,
218}
219
220
221#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
222pub struct TextAlignCenter;
223impl core::fmt::Display for TextAlignCenter {
224    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
225        write!(f, "textAlignCenter")
226    }
227}
228
229
230#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
231pub struct TextAlignJustify;
232impl core::fmt::Display for TextAlignJustify {
233    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
234        write!(f, "textAlignJustify")
235    }
236}
237
238
239#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
240pub struct TextAlignLeft;
241impl core::fmt::Display for TextAlignLeft {
242    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
243        write!(f, "textAlignLeft")
244    }
245}
246
247
248#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Hash)]
249pub struct TextAlignRight;
250impl core::fmt::Display for TextAlignRight {
251    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
252        write!(f, "textAlignRight")
253    }
254}
255
256impl<'a> LexiconSchema for Block<'a> {
257    fn nsid() -> &'static str {
258        "pub.leaflet.pages.linearDocument"
259    }
260    fn def_name() -> &'static str {
261        "block"
262    }
263    fn lexicon_doc() -> LexiconDoc<'static> {
264        lexicon_doc_pub_leaflet_pages_linearDocument()
265    }
266    fn validate(&self) -> Result<(), ConstraintError> {
267        Ok(())
268    }
269}
270
271impl<'a> LexiconSchema for LinearDocument<'a> {
272    fn nsid() -> &'static str {
273        "pub.leaflet.pages.linearDocument"
274    }
275    fn def_name() -> &'static str {
276        "main"
277    }
278    fn lexicon_doc() -> LexiconDoc<'static> {
279        lexicon_doc_pub_leaflet_pages_linearDocument()
280    }
281    fn validate(&self) -> Result<(), ConstraintError> {
282        Ok(())
283    }
284}
285
286impl<'a> LexiconSchema for Position<'a> {
287    fn nsid() -> &'static str {
288        "pub.leaflet.pages.linearDocument"
289    }
290    fn def_name() -> &'static str {
291        "position"
292    }
293    fn lexicon_doc() -> LexiconDoc<'static> {
294        lexicon_doc_pub_leaflet_pages_linearDocument()
295    }
296    fn validate(&self) -> Result<(), ConstraintError> {
297        Ok(())
298    }
299}
300
301impl<'a> LexiconSchema for Quote<'a> {
302    fn nsid() -> &'static str {
303        "pub.leaflet.pages.linearDocument"
304    }
305    fn def_name() -> &'static str {
306        "quote"
307    }
308    fn lexicon_doc() -> LexiconDoc<'static> {
309        lexicon_doc_pub_leaflet_pages_linearDocument()
310    }
311    fn validate(&self) -> Result<(), ConstraintError> {
312        Ok(())
313    }
314}
315
316pub mod block_state {
317
318    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
319    #[allow(unused)]
320    use ::core::marker::PhantomData;
321    mod sealed {
322        pub trait Sealed {}
323    }
324    /// State trait tracking which required fields have been set
325    pub trait State: sealed::Sealed {
326        type Block;
327    }
328    /// Empty state - all required fields are unset
329    pub struct Empty(());
330    impl sealed::Sealed for Empty {}
331    impl State for Empty {
332        type Block = Unset;
333    }
334    ///State transition - sets the `block` field to Set
335    pub struct SetBlock<S: State = Empty>(PhantomData<fn() -> S>);
336    impl<S: State> sealed::Sealed for SetBlock<S> {}
337    impl<S: State> State for SetBlock<S> {
338        type Block = Set<members::block>;
339    }
340    /// Marker types for field names
341    #[allow(non_camel_case_types)]
342    pub mod members {
343        ///Marker type for the `block` field
344        pub struct block(());
345    }
346}
347
348/// Builder for constructing an instance of this type
349pub struct BlockBuilder<'a, S: block_state::State> {
350    _state: PhantomData<fn() -> S>,
351    _fields: (Option<BlockAlignment<'a>>, Option<BlockBlock<'a>>),
352    _lifetime: PhantomData<&'a ()>,
353}
354
355impl<'a> Block<'a> {
356    /// Create a new builder for this type
357    pub fn new() -> BlockBuilder<'a, block_state::Empty> {
358        BlockBuilder::new()
359    }
360}
361
362impl<'a> BlockBuilder<'a, block_state::Empty> {
363    /// Create a new builder with all fields unset
364    pub fn new() -> Self {
365        BlockBuilder {
366            _state: PhantomData,
367            _fields: (None, None),
368            _lifetime: PhantomData,
369        }
370    }
371}
372
373impl<'a, S: block_state::State> BlockBuilder<'a, S> {
374    /// Set the `alignment` field (optional)
375    pub fn alignment(mut self, value: impl Into<Option<BlockAlignment<'a>>>) -> Self {
376        self._fields.0 = value.into();
377        self
378    }
379    /// Set the `alignment` field to an Option value (optional)
380    pub fn maybe_alignment(mut self, value: Option<BlockAlignment<'a>>) -> Self {
381        self._fields.0 = value;
382        self
383    }
384}
385
386impl<'a, S> BlockBuilder<'a, S>
387where
388    S: block_state::State,
389    S::Block: block_state::IsUnset,
390{
391    /// Set the `block` field (required)
392    pub fn block(
393        mut self,
394        value: impl Into<BlockBlock<'a>>,
395    ) -> BlockBuilder<'a, block_state::SetBlock<S>> {
396        self._fields.1 = Option::Some(value.into());
397        BlockBuilder {
398            _state: PhantomData,
399            _fields: self._fields,
400            _lifetime: PhantomData,
401        }
402    }
403}
404
405impl<'a, S> BlockBuilder<'a, S>
406where
407    S: block_state::State,
408    S::Block: block_state::IsSet,
409{
410    /// Build the final struct
411    pub fn build(self) -> Block<'a> {
412        Block {
413            alignment: self._fields.0,
414            block: self._fields.1.unwrap(),
415            extra_data: Default::default(),
416        }
417    }
418    /// Build the final struct with custom extra_data
419    pub fn build_with_data(
420        self,
421        extra_data: BTreeMap<
422            jacquard_common::deps::smol_str::SmolStr,
423            jacquard_common::types::value::Data<'a>,
424        >,
425    ) -> Block<'a> {
426        Block {
427            alignment: self._fields.0,
428            block: self._fields.1.unwrap(),
429            extra_data: Some(extra_data),
430        }
431    }
432}
433
434fn lexicon_doc_pub_leaflet_pages_linearDocument() -> LexiconDoc<'static> {
435    #[allow(unused_imports)]
436    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
437    use jacquard_lexicon::lexicon::*;
438    use alloc::collections::BTreeMap;
439    LexiconDoc {
440        lexicon: Lexicon::Lexicon1,
441        id: CowStr::new_static("pub.leaflet.pages.linearDocument"),
442        defs: {
443            let mut map = BTreeMap::new();
444            map.insert(
445                SmolStr::new_static("block"),
446                LexUserType::Object(LexObject {
447                    required: Some(vec![SmolStr::new_static("block")]),
448                    properties: {
449                        #[allow(unused_mut)]
450                        let mut map = BTreeMap::new();
451                        map.insert(
452                            SmolStr::new_static("alignment"),
453                            LexObjectProperty::String(LexString { ..Default::default() }),
454                        );
455                        map.insert(
456                            SmolStr::new_static("block"),
457                            LexObjectProperty::Union(LexRefUnion {
458                                refs: vec![
459                                    CowStr::new_static("pub.leaflet.blocks.iframe"),
460                                    CowStr::new_static("pub.leaflet.blocks.text"),
461                                    CowStr::new_static("pub.leaflet.blocks.blockquote"),
462                                    CowStr::new_static("pub.leaflet.blocks.header"),
463                                    CowStr::new_static("pub.leaflet.blocks.image"),
464                                    CowStr::new_static("pub.leaflet.blocks.unorderedList"),
465                                    CowStr::new_static("pub.leaflet.blocks.orderedList"),
466                                    CowStr::new_static("pub.leaflet.blocks.website"),
467                                    CowStr::new_static("pub.leaflet.blocks.math"),
468                                    CowStr::new_static("pub.leaflet.blocks.code"),
469                                    CowStr::new_static("pub.leaflet.blocks.horizontalRule"),
470                                    CowStr::new_static("pub.leaflet.blocks.bskyPost"),
471                                    CowStr::new_static("pub.leaflet.blocks.page"),
472                                    CowStr::new_static("pub.leaflet.blocks.poll"),
473                                    CowStr::new_static("pub.leaflet.blocks.button")
474                                ],
475                                ..Default::default()
476                            }),
477                        );
478                        map
479                    },
480                    ..Default::default()
481                }),
482            );
483            map.insert(
484                SmolStr::new_static("main"),
485                LexUserType::Object(LexObject {
486                    required: Some(vec![SmolStr::new_static("blocks")]),
487                    properties: {
488                        #[allow(unused_mut)]
489                        let mut map = BTreeMap::new();
490                        map.insert(
491                            SmolStr::new_static("blocks"),
492                            LexObjectProperty::Array(LexArray {
493                                items: LexArrayItem::Ref(LexRef {
494                                    r#ref: CowStr::new_static("#block"),
495                                    ..Default::default()
496                                }),
497                                ..Default::default()
498                            }),
499                        );
500                        map.insert(
501                            SmolStr::new_static("id"),
502                            LexObjectProperty::String(LexString { ..Default::default() }),
503                        );
504                        map
505                    },
506                    ..Default::default()
507                }),
508            );
509            map.insert(
510                SmolStr::new_static("position"),
511                LexUserType::Object(LexObject {
512                    required: Some(
513                        vec![SmolStr::new_static("block"), SmolStr::new_static("offset")],
514                    ),
515                    properties: {
516                        #[allow(unused_mut)]
517                        let mut map = BTreeMap::new();
518                        map.insert(
519                            SmolStr::new_static("block"),
520                            LexObjectProperty::Array(LexArray {
521                                items: LexArrayItem::Integer(LexInteger {
522                                    ..Default::default()
523                                }),
524                                ..Default::default()
525                            }),
526                        );
527                        map.insert(
528                            SmolStr::new_static("offset"),
529                            LexObjectProperty::Integer(LexInteger {
530                                ..Default::default()
531                            }),
532                        );
533                        map
534                    },
535                    ..Default::default()
536                }),
537            );
538            map.insert(
539                SmolStr::new_static("quote"),
540                LexUserType::Object(LexObject {
541                    required: Some(
542                        vec![SmolStr::new_static("start"), SmolStr::new_static("end")],
543                    ),
544                    properties: {
545                        #[allow(unused_mut)]
546                        let mut map = BTreeMap::new();
547                        map.insert(
548                            SmolStr::new_static("end"),
549                            LexObjectProperty::Ref(LexRef {
550                                r#ref: CowStr::new_static("#position"),
551                                ..Default::default()
552                            }),
553                        );
554                        map.insert(
555                            SmolStr::new_static("start"),
556                            LexObjectProperty::Ref(LexRef {
557                                r#ref: CowStr::new_static("#position"),
558                                ..Default::default()
559                            }),
560                        );
561                        map
562                    },
563                    ..Default::default()
564                }),
565            );
566            map.insert(
567                SmolStr::new_static("textAlignCenter"),
568                LexUserType::Token(LexToken { ..Default::default() }),
569            );
570            map.insert(
571                SmolStr::new_static("textAlignJustify"),
572                LexUserType::Token(LexToken { ..Default::default() }),
573            );
574            map.insert(
575                SmolStr::new_static("textAlignLeft"),
576                LexUserType::Token(LexToken { ..Default::default() }),
577            );
578            map.insert(
579                SmolStr::new_static("textAlignRight"),
580                LexUserType::Token(LexToken { ..Default::default() }),
581            );
582            map
583        },
584        ..Default::default()
585    }
586}
587
588pub mod linear_document_state {
589
590    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
591    #[allow(unused)]
592    use ::core::marker::PhantomData;
593    mod sealed {
594        pub trait Sealed {}
595    }
596    /// State trait tracking which required fields have been set
597    pub trait State: sealed::Sealed {
598        type Blocks;
599    }
600    /// Empty state - all required fields are unset
601    pub struct Empty(());
602    impl sealed::Sealed for Empty {}
603    impl State for Empty {
604        type Blocks = Unset;
605    }
606    ///State transition - sets the `blocks` field to Set
607    pub struct SetBlocks<S: State = Empty>(PhantomData<fn() -> S>);
608    impl<S: State> sealed::Sealed for SetBlocks<S> {}
609    impl<S: State> State for SetBlocks<S> {
610        type Blocks = Set<members::blocks>;
611    }
612    /// Marker types for field names
613    #[allow(non_camel_case_types)]
614    pub mod members {
615        ///Marker type for the `blocks` field
616        pub struct blocks(());
617    }
618}
619
620/// Builder for constructing an instance of this type
621pub struct LinearDocumentBuilder<'a, S: linear_document_state::State> {
622    _state: PhantomData<fn() -> S>,
623    _fields: (Option<Vec<linear_document::Block<'a>>>, Option<CowStr<'a>>),
624    _lifetime: PhantomData<&'a ()>,
625}
626
627impl<'a> LinearDocument<'a> {
628    /// Create a new builder for this type
629    pub fn new() -> LinearDocumentBuilder<'a, linear_document_state::Empty> {
630        LinearDocumentBuilder::new()
631    }
632}
633
634impl<'a> LinearDocumentBuilder<'a, linear_document_state::Empty> {
635    /// Create a new builder with all fields unset
636    pub fn new() -> Self {
637        LinearDocumentBuilder {
638            _state: PhantomData,
639            _fields: (None, None),
640            _lifetime: PhantomData,
641        }
642    }
643}
644
645impl<'a, S> LinearDocumentBuilder<'a, S>
646where
647    S: linear_document_state::State,
648    S::Blocks: linear_document_state::IsUnset,
649{
650    /// Set the `blocks` field (required)
651    pub fn blocks(
652        mut self,
653        value: impl Into<Vec<linear_document::Block<'a>>>,
654    ) -> LinearDocumentBuilder<'a, linear_document_state::SetBlocks<S>> {
655        self._fields.0 = Option::Some(value.into());
656        LinearDocumentBuilder {
657            _state: PhantomData,
658            _fields: self._fields,
659            _lifetime: PhantomData,
660        }
661    }
662}
663
664impl<'a, S: linear_document_state::State> LinearDocumentBuilder<'a, S> {
665    /// Set the `id` field (optional)
666    pub fn id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
667        self._fields.1 = value.into();
668        self
669    }
670    /// Set the `id` field to an Option value (optional)
671    pub fn maybe_id(mut self, value: Option<CowStr<'a>>) -> Self {
672        self._fields.1 = value;
673        self
674    }
675}
676
677impl<'a, S> LinearDocumentBuilder<'a, S>
678where
679    S: linear_document_state::State,
680    S::Blocks: linear_document_state::IsSet,
681{
682    /// Build the final struct
683    pub fn build(self) -> LinearDocument<'a> {
684        LinearDocument {
685            blocks: self._fields.0.unwrap(),
686            id: self._fields.1,
687            extra_data: Default::default(),
688        }
689    }
690    /// Build the final struct with custom extra_data
691    pub fn build_with_data(
692        self,
693        extra_data: BTreeMap<
694            jacquard_common::deps::smol_str::SmolStr,
695            jacquard_common::types::value::Data<'a>,
696        >,
697    ) -> LinearDocument<'a> {
698        LinearDocument {
699            blocks: self._fields.0.unwrap(),
700            id: self._fields.1,
701            extra_data: Some(extra_data),
702        }
703    }
704}
705
706pub mod position_state {
707
708    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
709    #[allow(unused)]
710    use ::core::marker::PhantomData;
711    mod sealed {
712        pub trait Sealed {}
713    }
714    /// State trait tracking which required fields have been set
715    pub trait State: sealed::Sealed {
716        type Offset;
717        type Block;
718    }
719    /// Empty state - all required fields are unset
720    pub struct Empty(());
721    impl sealed::Sealed for Empty {}
722    impl State for Empty {
723        type Offset = Unset;
724        type Block = Unset;
725    }
726    ///State transition - sets the `offset` field to Set
727    pub struct SetOffset<S: State = Empty>(PhantomData<fn() -> S>);
728    impl<S: State> sealed::Sealed for SetOffset<S> {}
729    impl<S: State> State for SetOffset<S> {
730        type Offset = Set<members::offset>;
731        type Block = S::Block;
732    }
733    ///State transition - sets the `block` field to Set
734    pub struct SetBlock<S: State = Empty>(PhantomData<fn() -> S>);
735    impl<S: State> sealed::Sealed for SetBlock<S> {}
736    impl<S: State> State for SetBlock<S> {
737        type Offset = S::Offset;
738        type Block = Set<members::block>;
739    }
740    /// Marker types for field names
741    #[allow(non_camel_case_types)]
742    pub mod members {
743        ///Marker type for the `offset` field
744        pub struct offset(());
745        ///Marker type for the `block` field
746        pub struct block(());
747    }
748}
749
750/// Builder for constructing an instance of this type
751pub struct PositionBuilder<'a, S: position_state::State> {
752    _state: PhantomData<fn() -> S>,
753    _fields: (Option<Vec<i64>>, Option<i64>),
754    _lifetime: PhantomData<&'a ()>,
755}
756
757impl<'a> Position<'a> {
758    /// Create a new builder for this type
759    pub fn new() -> PositionBuilder<'a, position_state::Empty> {
760        PositionBuilder::new()
761    }
762}
763
764impl<'a> PositionBuilder<'a, position_state::Empty> {
765    /// Create a new builder with all fields unset
766    pub fn new() -> Self {
767        PositionBuilder {
768            _state: PhantomData,
769            _fields: (None, None),
770            _lifetime: PhantomData,
771        }
772    }
773}
774
775impl<'a, S> PositionBuilder<'a, S>
776where
777    S: position_state::State,
778    S::Block: position_state::IsUnset,
779{
780    /// Set the `block` field (required)
781    pub fn block(
782        mut self,
783        value: impl Into<Vec<i64>>,
784    ) -> PositionBuilder<'a, position_state::SetBlock<S>> {
785        self._fields.0 = Option::Some(value.into());
786        PositionBuilder {
787            _state: PhantomData,
788            _fields: self._fields,
789            _lifetime: PhantomData,
790        }
791    }
792}
793
794impl<'a, S> PositionBuilder<'a, S>
795where
796    S: position_state::State,
797    S::Offset: position_state::IsUnset,
798{
799    /// Set the `offset` field (required)
800    pub fn offset(
801        mut self,
802        value: impl Into<i64>,
803    ) -> PositionBuilder<'a, position_state::SetOffset<S>> {
804        self._fields.1 = Option::Some(value.into());
805        PositionBuilder {
806            _state: PhantomData,
807            _fields: self._fields,
808            _lifetime: PhantomData,
809        }
810    }
811}
812
813impl<'a, S> PositionBuilder<'a, S>
814where
815    S: position_state::State,
816    S::Offset: position_state::IsSet,
817    S::Block: position_state::IsSet,
818{
819    /// Build the final struct
820    pub fn build(self) -> Position<'a> {
821        Position {
822            block: self._fields.0.unwrap(),
823            offset: self._fields.1.unwrap(),
824            extra_data: Default::default(),
825        }
826    }
827    /// Build the final struct with custom extra_data
828    pub fn build_with_data(
829        self,
830        extra_data: BTreeMap<
831            jacquard_common::deps::smol_str::SmolStr,
832            jacquard_common::types::value::Data<'a>,
833        >,
834    ) -> Position<'a> {
835        Position {
836            block: self._fields.0.unwrap(),
837            offset: self._fields.1.unwrap(),
838            extra_data: Some(extra_data),
839        }
840    }
841}
842
843pub mod quote_state {
844
845    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
846    #[allow(unused)]
847    use ::core::marker::PhantomData;
848    mod sealed {
849        pub trait Sealed {}
850    }
851    /// State trait tracking which required fields have been set
852    pub trait State: sealed::Sealed {
853        type End;
854        type Start;
855    }
856    /// Empty state - all required fields are unset
857    pub struct Empty(());
858    impl sealed::Sealed for Empty {}
859    impl State for Empty {
860        type End = Unset;
861        type Start = Unset;
862    }
863    ///State transition - sets the `end` field to Set
864    pub struct SetEnd<S: State = Empty>(PhantomData<fn() -> S>);
865    impl<S: State> sealed::Sealed for SetEnd<S> {}
866    impl<S: State> State for SetEnd<S> {
867        type End = Set<members::end>;
868        type Start = S::Start;
869    }
870    ///State transition - sets the `start` field to Set
871    pub struct SetStart<S: State = Empty>(PhantomData<fn() -> S>);
872    impl<S: State> sealed::Sealed for SetStart<S> {}
873    impl<S: State> State for SetStart<S> {
874        type End = S::End;
875        type Start = Set<members::start>;
876    }
877    /// Marker types for field names
878    #[allow(non_camel_case_types)]
879    pub mod members {
880        ///Marker type for the `end` field
881        pub struct end(());
882        ///Marker type for the `start` field
883        pub struct start(());
884    }
885}
886
887/// Builder for constructing an instance of this type
888pub struct QuoteBuilder<'a, S: quote_state::State> {
889    _state: PhantomData<fn() -> S>,
890    _fields: (
891        Option<linear_document::Position<'a>>,
892        Option<linear_document::Position<'a>>,
893    ),
894    _lifetime: PhantomData<&'a ()>,
895}
896
897impl<'a> Quote<'a> {
898    /// Create a new builder for this type
899    pub fn new() -> QuoteBuilder<'a, quote_state::Empty> {
900        QuoteBuilder::new()
901    }
902}
903
904impl<'a> QuoteBuilder<'a, quote_state::Empty> {
905    /// Create a new builder with all fields unset
906    pub fn new() -> Self {
907        QuoteBuilder {
908            _state: PhantomData,
909            _fields: (None, None),
910            _lifetime: PhantomData,
911        }
912    }
913}
914
915impl<'a, S> QuoteBuilder<'a, S>
916where
917    S: quote_state::State,
918    S::End: quote_state::IsUnset,
919{
920    /// Set the `end` field (required)
921    pub fn end(
922        mut self,
923        value: impl Into<linear_document::Position<'a>>,
924    ) -> QuoteBuilder<'a, quote_state::SetEnd<S>> {
925        self._fields.0 = Option::Some(value.into());
926        QuoteBuilder {
927            _state: PhantomData,
928            _fields: self._fields,
929            _lifetime: PhantomData,
930        }
931    }
932}
933
934impl<'a, S> QuoteBuilder<'a, S>
935where
936    S: quote_state::State,
937    S::Start: quote_state::IsUnset,
938{
939    /// Set the `start` field (required)
940    pub fn start(
941        mut self,
942        value: impl Into<linear_document::Position<'a>>,
943    ) -> QuoteBuilder<'a, quote_state::SetStart<S>> {
944        self._fields.1 = Option::Some(value.into());
945        QuoteBuilder {
946            _state: PhantomData,
947            _fields: self._fields,
948            _lifetime: PhantomData,
949        }
950    }
951}
952
953impl<'a, S> QuoteBuilder<'a, S>
954where
955    S: quote_state::State,
956    S::End: quote_state::IsSet,
957    S::Start: quote_state::IsSet,
958{
959    /// Build the final struct
960    pub fn build(self) -> Quote<'a> {
961        Quote {
962            end: self._fields.0.unwrap(),
963            start: self._fields.1.unwrap(),
964            extra_data: Default::default(),
965        }
966    }
967    /// Build the final struct with custom extra_data
968    pub fn build_with_data(
969        self,
970        extra_data: BTreeMap<
971            jacquard_common::deps::smol_str::SmolStr,
972            jacquard_common::types::value::Data<'a>,
973        >,
974    ) -> Quote<'a> {
975        Quote {
976            end: self._fields.0.unwrap(),
977            start: self._fields.1.unwrap(),
978            extra_data: Some(extra_data),
979        }
980    }
981}