Skip to main content

jacquard_api/blog_pckt/block/
table_row.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: blog.pckt.block.tableRow
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;
13
14#[allow(unused_imports)]
15use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
16use jacquard_derive::{IntoStatic, lexicon, open_union};
17use jacquard_lexicon::lexicon::LexiconDoc;
18use jacquard_lexicon::schema::LexiconSchema;
19
20#[allow(unused_imports)]
21use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
22use serde::{Serialize, Deserialize};
23use crate::blog_pckt::block::table_cell::TableCell;
24use crate::blog_pckt::block::table_header::TableHeader;
25
26#[lexicon]
27#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
28#[serde(rename_all = "camelCase")]
29pub struct TableRow<'a> {
30    ///Array of table cells or header cells
31    #[serde(borrow)]
32    pub content: Vec<TableRowContentItem<'a>>,
33}
34
35
36#[open_union]
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
39pub enum TableRowContentItem<'a> {
40    #[serde(rename = "blog.pckt.block.tableCell")]
41    TableCell(Box<TableCell<'a>>),
42    #[serde(rename = "blog.pckt.block.tableHeader")]
43    TableHeader(Box<TableHeader<'a>>),
44}
45
46impl<'a> LexiconSchema for TableRow<'a> {
47    fn nsid() -> &'static str {
48        "blog.pckt.block.tableRow"
49    }
50    fn def_name() -> &'static str {
51        "main"
52    }
53    fn lexicon_doc() -> LexiconDoc<'static> {
54        lexicon_doc_blog_pckt_block_tableRow()
55    }
56    fn validate(&self) -> Result<(), ConstraintError> {
57        Ok(())
58    }
59}
60
61pub mod table_row_state {
62
63    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
64    #[allow(unused)]
65    use ::core::marker::PhantomData;
66    mod sealed {
67        pub trait Sealed {}
68    }
69    /// State trait tracking which required fields have been set
70    pub trait State: sealed::Sealed {
71        type Content;
72    }
73    /// Empty state - all required fields are unset
74    pub struct Empty(());
75    impl sealed::Sealed for Empty {}
76    impl State for Empty {
77        type Content = Unset;
78    }
79    ///State transition - sets the `content` field to Set
80    pub struct SetContent<S: State = Empty>(PhantomData<fn() -> S>);
81    impl<S: State> sealed::Sealed for SetContent<S> {}
82    impl<S: State> State for SetContent<S> {
83        type Content = Set<members::content>;
84    }
85    /// Marker types for field names
86    #[allow(non_camel_case_types)]
87    pub mod members {
88        ///Marker type for the `content` field
89        pub struct content(());
90    }
91}
92
93/// Builder for constructing an instance of this type
94pub struct TableRowBuilder<'a, S: table_row_state::State> {
95    _state: PhantomData<fn() -> S>,
96    _fields: (Option<Vec<TableRowContentItem<'a>>>,),
97    _lifetime: PhantomData<&'a ()>,
98}
99
100impl<'a> TableRow<'a> {
101    /// Create a new builder for this type
102    pub fn new() -> TableRowBuilder<'a, table_row_state::Empty> {
103        TableRowBuilder::new()
104    }
105}
106
107impl<'a> TableRowBuilder<'a, table_row_state::Empty> {
108    /// Create a new builder with all fields unset
109    pub fn new() -> Self {
110        TableRowBuilder {
111            _state: PhantomData,
112            _fields: (None,),
113            _lifetime: PhantomData,
114        }
115    }
116}
117
118impl<'a, S> TableRowBuilder<'a, S>
119where
120    S: table_row_state::State,
121    S::Content: table_row_state::IsUnset,
122{
123    /// Set the `content` field (required)
124    pub fn content(
125        mut self,
126        value: impl Into<Vec<TableRowContentItem<'a>>>,
127    ) -> TableRowBuilder<'a, table_row_state::SetContent<S>> {
128        self._fields.0 = Option::Some(value.into());
129        TableRowBuilder {
130            _state: PhantomData,
131            _fields: self._fields,
132            _lifetime: PhantomData,
133        }
134    }
135}
136
137impl<'a, S> TableRowBuilder<'a, S>
138where
139    S: table_row_state::State,
140    S::Content: table_row_state::IsSet,
141{
142    /// Build the final struct
143    pub fn build(self) -> TableRow<'a> {
144        TableRow {
145            content: self._fields.0.unwrap(),
146            extra_data: Default::default(),
147        }
148    }
149    /// Build the final struct with custom extra_data
150    pub fn build_with_data(
151        self,
152        extra_data: BTreeMap<
153            jacquard_common::deps::smol_str::SmolStr,
154            jacquard_common::types::value::Data<'a>,
155        >,
156    ) -> TableRow<'a> {
157        TableRow {
158            content: self._fields.0.unwrap(),
159            extra_data: Some(extra_data),
160        }
161    }
162}
163
164fn lexicon_doc_blog_pckt_block_tableRow() -> LexiconDoc<'static> {
165    #[allow(unused_imports)]
166    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
167    use jacquard_lexicon::lexicon::*;
168    use alloc::collections::BTreeMap;
169    LexiconDoc {
170        lexicon: Lexicon::Lexicon1,
171        id: CowStr::new_static("blog.pckt.block.tableRow"),
172        defs: {
173            let mut map = BTreeMap::new();
174            map.insert(
175                SmolStr::new_static("main"),
176                LexUserType::Object(LexObject {
177                    required: Some(vec![SmolStr::new_static("content")]),
178                    properties: {
179                        #[allow(unused_mut)]
180                        let mut map = BTreeMap::new();
181                        map.insert(
182                            SmolStr::new_static("content"),
183                            LexObjectProperty::Array(LexArray {
184                                description: Some(
185                                    CowStr::new_static("Array of table cells or header cells"),
186                                ),
187                                items: LexArrayItem::Union(LexRefUnion {
188                                    refs: vec![
189                                        CowStr::new_static("blog.pckt.block.tableCell"),
190                                        CowStr::new_static("blog.pckt.block.tableHeader")
191                                    ],
192                                    closed: Some(false),
193                                    ..Default::default()
194                                }),
195                                ..Default::default()
196                            }),
197                        );
198                        map
199                    },
200                    ..Default::default()
201                }),
202            );
203            map
204        },
205        ..Default::default()
206    }
207}