jacquard_api/pub_leaflet/blocks/
iframe.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: pub.leaflet.blocks.iframe
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10    serde::Serialize,
11    serde::Deserialize,
12    Debug,
13    Clone,
14    PartialEq,
15    Eq,
16    jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct Iframe<'a> {
20    #[serde(skip_serializing_if = "std::option::Option::is_none")]
21    pub height: Option<i64>,
22    #[serde(borrow)]
23    pub url: jacquard_common::types::string::Uri<'a>,
24}
25
26pub mod iframe_state {
27
28    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
29    #[allow(unused)]
30    use ::core::marker::PhantomData;
31    mod sealed {
32        pub trait Sealed {}
33    }
34    /// State trait tracking which required fields have been set
35    pub trait State: sealed::Sealed {
36        type Url;
37    }
38    /// Empty state - all required fields are unset
39    pub struct Empty(());
40    impl sealed::Sealed for Empty {}
41    impl State for Empty {
42        type Url = Unset;
43    }
44    ///State transition - sets the `url` field to Set
45    pub struct SetUrl<S: State = Empty>(PhantomData<fn() -> S>);
46    impl<S: State> sealed::Sealed for SetUrl<S> {}
47    impl<S: State> State for SetUrl<S> {
48        type Url = Set<members::url>;
49    }
50    /// Marker types for field names
51    #[allow(non_camel_case_types)]
52    pub mod members {
53        ///Marker type for the `url` field
54        pub struct url(());
55    }
56}
57
58/// Builder for constructing an instance of this type
59pub struct IframeBuilder<'a, S: iframe_state::State> {
60    _phantom_state: ::core::marker::PhantomData<fn() -> S>,
61    __unsafe_private_named: (
62        ::core::option::Option<i64>,
63        ::core::option::Option<jacquard_common::types::string::Uri<'a>>,
64    ),
65    _phantom: ::core::marker::PhantomData<&'a ()>,
66}
67
68impl<'a> Iframe<'a> {
69    /// Create a new builder for this type
70    pub fn new() -> IframeBuilder<'a, iframe_state::Empty> {
71        IframeBuilder::new()
72    }
73}
74
75impl<'a> IframeBuilder<'a, iframe_state::Empty> {
76    /// Create a new builder with all fields unset
77    pub fn new() -> Self {
78        IframeBuilder {
79            _phantom_state: ::core::marker::PhantomData,
80            __unsafe_private_named: (None, None),
81            _phantom: ::core::marker::PhantomData,
82        }
83    }
84}
85
86impl<'a, S: iframe_state::State> IframeBuilder<'a, S> {
87    /// Set the `height` field (optional)
88    pub fn height(mut self, value: impl Into<Option<i64>>) -> Self {
89        self.__unsafe_private_named.0 = value.into();
90        self
91    }
92    /// Set the `height` field to an Option value (optional)
93    pub fn maybe_height(mut self, value: Option<i64>) -> Self {
94        self.__unsafe_private_named.0 = value;
95        self
96    }
97}
98
99impl<'a, S> IframeBuilder<'a, S>
100where
101    S: iframe_state::State,
102    S::Url: iframe_state::IsUnset,
103{
104    /// Set the `url` field (required)
105    pub fn url(
106        mut self,
107        value: impl Into<jacquard_common::types::string::Uri<'a>>,
108    ) -> IframeBuilder<'a, iframe_state::SetUrl<S>> {
109        self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
110        IframeBuilder {
111            _phantom_state: ::core::marker::PhantomData,
112            __unsafe_private_named: self.__unsafe_private_named,
113            _phantom: ::core::marker::PhantomData,
114        }
115    }
116}
117
118impl<'a, S> IframeBuilder<'a, S>
119where
120    S: iframe_state::State,
121    S::Url: iframe_state::IsSet,
122{
123    /// Build the final struct
124    pub fn build(self) -> Iframe<'a> {
125        Iframe {
126            height: self.__unsafe_private_named.0,
127            url: self.__unsafe_private_named.1.unwrap(),
128            extra_data: Default::default(),
129        }
130    }
131    /// Build the final struct with custom extra_data
132    pub fn build_with_data(
133        self,
134        extra_data: std::collections::BTreeMap<
135            jacquard_common::smol_str::SmolStr,
136            jacquard_common::types::value::Data<'a>,
137        >,
138    ) -> Iframe<'a> {
139        Iframe {
140            height: self.__unsafe_private_named.0,
141            url: self.__unsafe_private_named.1.unwrap(),
142            extra_data: Some(extra_data),
143        }
144    }
145}
146
147fn lexicon_doc_pub_leaflet_blocks_iframe() -> ::jacquard_lexicon::lexicon::LexiconDoc<
148    'static,
149> {
150    ::jacquard_lexicon::lexicon::LexiconDoc {
151        lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
152        id: ::jacquard_common::CowStr::new_static("pub.leaflet.blocks.iframe"),
153        revision: None,
154        description: None,
155        defs: {
156            let mut map = ::std::collections::BTreeMap::new();
157            map.insert(
158                ::jacquard_common::smol_str::SmolStr::new_static("main"),
159                ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
160                    description: None,
161                    required: Some(
162                        vec![::jacquard_common::smol_str::SmolStr::new_static("url")],
163                    ),
164                    nullable: None,
165                    properties: {
166                        #[allow(unused_mut)]
167                        let mut map = ::std::collections::BTreeMap::new();
168                        map.insert(
169                            ::jacquard_common::smol_str::SmolStr::new_static("height"),
170                            ::jacquard_lexicon::lexicon::LexObjectProperty::Integer(::jacquard_lexicon::lexicon::LexInteger {
171                                description: None,
172                                default: None,
173                                minimum: Some(16i64),
174                                maximum: Some(1600i64),
175                                r#enum: None,
176                                r#const: None,
177                            }),
178                        );
179                        map.insert(
180                            ::jacquard_common::smol_str::SmolStr::new_static("url"),
181                            ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
182                                description: None,
183                                format: Some(
184                                    ::jacquard_lexicon::lexicon::LexStringFormat::Uri,
185                                ),
186                                default: None,
187                                min_length: None,
188                                max_length: None,
189                                min_graphemes: None,
190                                max_graphemes: None,
191                                r#enum: None,
192                                r#const: None,
193                                known_values: None,
194                            }),
195                        );
196                        map
197                    },
198                }),
199            );
200            map
201        },
202    }
203}
204
205impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Iframe<'a> {
206    fn nsid() -> &'static str {
207        "pub.leaflet.blocks.iframe"
208    }
209    fn def_name() -> &'static str {
210        "main"
211    }
212    fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
213        lexicon_doc_pub_leaflet_blocks_iframe()
214    }
215    fn validate(
216        &self,
217    ) -> ::std::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
218        if let Some(ref value) = self.height {
219            if *value > 1600i64 {
220                return Err(::jacquard_lexicon::validation::ConstraintError::Maximum {
221                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
222                        "height",
223                    ),
224                    max: 1600i64,
225                    actual: *value,
226                });
227            }
228        }
229        if let Some(ref value) = self.height {
230            if *value < 16i64 {
231                return Err(::jacquard_lexicon::validation::ConstraintError::Minimum {
232                    path: ::jacquard_lexicon::validation::ValidationPath::from_field(
233                        "height",
234                    ),
235                    min: 16i64,
236                    actual: *value,
237                });
238            }
239        }
240        Ok(())
241    }
242}