Skip to main content

jacquard_api/sh_weaver/
embed.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.embed.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod external;
9pub mod images;
10pub mod record_with_media;
11pub mod records;
12pub mod video;
13
14
15#[allow(unused_imports)]
16use alloc::collections::BTreeMap;
17
18#[allow(unused_imports)]
19use core::marker::PhantomData;
20
21#[allow(unused_imports)]
22use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
23use jacquard_derive::{IntoStatic, lexicon};
24use jacquard_lexicon::lexicon::LexiconDoc;
25use jacquard_lexicon::schema::LexiconSchema;
26
27#[allow(unused_imports)]
28use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
29use serde::{Serialize, Deserialize};
30/// Proportional size of the embed relative to the viewport in larger windows. The dimensions are percentage out of 100. Could we use more granularity? Maybe, but come on.
31
32#[lexicon]
33#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
34#[serde(rename_all = "camelCase")]
35pub struct PercentSize<'a> {
36    pub height: i64,
37    pub width: i64,
38}
39
40/// Pixel-exact embed size. The dimensions are logical pixels, subject to scaling, so 200px at X2 scale is 400px.
41
42#[lexicon]
43#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
44#[serde(rename_all = "camelCase")]
45pub struct PixelSize<'a> {
46    pub height: i64,
47    pub width: i64,
48}
49
50impl<'a> LexiconSchema for PercentSize<'a> {
51    fn nsid() -> &'static str {
52        "sh.weaver.embed.defs"
53    }
54    fn def_name() -> &'static str {
55        "percentSize"
56    }
57    fn lexicon_doc() -> LexiconDoc<'static> {
58        lexicon_doc_sh_weaver_embed_defs()
59    }
60    fn validate(&self) -> Result<(), ConstraintError> {
61        Ok(())
62    }
63}
64
65impl<'a> LexiconSchema for PixelSize<'a> {
66    fn nsid() -> &'static str {
67        "sh.weaver.embed.defs"
68    }
69    fn def_name() -> &'static str {
70        "pixelSize"
71    }
72    fn lexicon_doc() -> LexiconDoc<'static> {
73        lexicon_doc_sh_weaver_embed_defs()
74    }
75    fn validate(&self) -> Result<(), ConstraintError> {
76        Ok(())
77    }
78}
79
80pub mod percent_size_state {
81
82    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
83    #[allow(unused)]
84    use ::core::marker::PhantomData;
85    mod sealed {
86        pub trait Sealed {}
87    }
88    /// State trait tracking which required fields have been set
89    pub trait State: sealed::Sealed {
90        type Height;
91        type Width;
92    }
93    /// Empty state - all required fields are unset
94    pub struct Empty(());
95    impl sealed::Sealed for Empty {}
96    impl State for Empty {
97        type Height = Unset;
98        type Width = Unset;
99    }
100    ///State transition - sets the `height` field to Set
101    pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
102    impl<S: State> sealed::Sealed for SetHeight<S> {}
103    impl<S: State> State for SetHeight<S> {
104        type Height = Set<members::height>;
105        type Width = S::Width;
106    }
107    ///State transition - sets the `width` field to Set
108    pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
109    impl<S: State> sealed::Sealed for SetWidth<S> {}
110    impl<S: State> State for SetWidth<S> {
111        type Height = S::Height;
112        type Width = Set<members::width>;
113    }
114    /// Marker types for field names
115    #[allow(non_camel_case_types)]
116    pub mod members {
117        ///Marker type for the `height` field
118        pub struct height(());
119        ///Marker type for the `width` field
120        pub struct width(());
121    }
122}
123
124/// Builder for constructing an instance of this type
125pub struct PercentSizeBuilder<'a, S: percent_size_state::State> {
126    _state: PhantomData<fn() -> S>,
127    _fields: (Option<i64>, Option<i64>),
128    _lifetime: PhantomData<&'a ()>,
129}
130
131impl<'a> PercentSize<'a> {
132    /// Create a new builder for this type
133    pub fn new() -> PercentSizeBuilder<'a, percent_size_state::Empty> {
134        PercentSizeBuilder::new()
135    }
136}
137
138impl<'a> PercentSizeBuilder<'a, percent_size_state::Empty> {
139    /// Create a new builder with all fields unset
140    pub fn new() -> Self {
141        PercentSizeBuilder {
142            _state: PhantomData,
143            _fields: (None, None),
144            _lifetime: PhantomData,
145        }
146    }
147}
148
149impl<'a, S> PercentSizeBuilder<'a, S>
150where
151    S: percent_size_state::State,
152    S::Height: percent_size_state::IsUnset,
153{
154    /// Set the `height` field (required)
155    pub fn height(
156        mut self,
157        value: impl Into<i64>,
158    ) -> PercentSizeBuilder<'a, percent_size_state::SetHeight<S>> {
159        self._fields.0 = Option::Some(value.into());
160        PercentSizeBuilder {
161            _state: PhantomData,
162            _fields: self._fields,
163            _lifetime: PhantomData,
164        }
165    }
166}
167
168impl<'a, S> PercentSizeBuilder<'a, S>
169where
170    S: percent_size_state::State,
171    S::Width: percent_size_state::IsUnset,
172{
173    /// Set the `width` field (required)
174    pub fn width(
175        mut self,
176        value: impl Into<i64>,
177    ) -> PercentSizeBuilder<'a, percent_size_state::SetWidth<S>> {
178        self._fields.1 = Option::Some(value.into());
179        PercentSizeBuilder {
180            _state: PhantomData,
181            _fields: self._fields,
182            _lifetime: PhantomData,
183        }
184    }
185}
186
187impl<'a, S> PercentSizeBuilder<'a, S>
188where
189    S: percent_size_state::State,
190    S::Height: percent_size_state::IsSet,
191    S::Width: percent_size_state::IsSet,
192{
193    /// Build the final struct
194    pub fn build(self) -> PercentSize<'a> {
195        PercentSize {
196            height: self._fields.0.unwrap(),
197            width: self._fields.1.unwrap(),
198            extra_data: Default::default(),
199        }
200    }
201    /// Build the final struct with custom extra_data
202    pub fn build_with_data(
203        self,
204        extra_data: BTreeMap<
205            jacquard_common::deps::smol_str::SmolStr,
206            jacquard_common::types::value::Data<'a>,
207        >,
208    ) -> PercentSize<'a> {
209        PercentSize {
210            height: self._fields.0.unwrap(),
211            width: self._fields.1.unwrap(),
212            extra_data: Some(extra_data),
213        }
214    }
215}
216
217fn lexicon_doc_sh_weaver_embed_defs() -> LexiconDoc<'static> {
218    #[allow(unused_imports)]
219    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
220    use jacquard_lexicon::lexicon::*;
221    use alloc::collections::BTreeMap;
222    LexiconDoc {
223        lexicon: Lexicon::Lexicon1,
224        id: CowStr::new_static("sh.weaver.embed.defs"),
225        defs: {
226            let mut map = BTreeMap::new();
227            map.insert(
228                SmolStr::new_static("percentSize"),
229                LexUserType::Object(LexObject {
230                    description: Some(
231                        CowStr::new_static(
232                            "Proportional size of the embed relative to the viewport in larger windows. The dimensions are percentage out of 100. Could we use more granularity? Maybe, but come on.",
233                        ),
234                    ),
235                    required: Some(
236                        vec![SmolStr::new_static("width"), SmolStr::new_static("height")],
237                    ),
238                    properties: {
239                        #[allow(unused_mut)]
240                        let mut map = BTreeMap::new();
241                        map.insert(
242                            SmolStr::new_static("height"),
243                            LexObjectProperty::Integer(LexInteger {
244                                ..Default::default()
245                            }),
246                        );
247                        map.insert(
248                            SmolStr::new_static("width"),
249                            LexObjectProperty::Integer(LexInteger {
250                                ..Default::default()
251                            }),
252                        );
253                        map
254                    },
255                    ..Default::default()
256                }),
257            );
258            map.insert(
259                SmolStr::new_static("pixelSize"),
260                LexUserType::Object(LexObject {
261                    description: Some(
262                        CowStr::new_static(
263                            "Pixel-exact embed size. The dimensions are logical pixels, subject to scaling, so 200px at X2 scale is 400px.",
264                        ),
265                    ),
266                    required: Some(
267                        vec![SmolStr::new_static("width"), SmolStr::new_static("height")],
268                    ),
269                    properties: {
270                        #[allow(unused_mut)]
271                        let mut map = BTreeMap::new();
272                        map.insert(
273                            SmolStr::new_static("height"),
274                            LexObjectProperty::Integer(LexInteger {
275                                ..Default::default()
276                            }),
277                        );
278                        map.insert(
279                            SmolStr::new_static("width"),
280                            LexObjectProperty::Integer(LexInteger {
281                                ..Default::default()
282                            }),
283                        );
284                        map
285                    },
286                    ..Default::default()
287                }),
288            );
289            map
290        },
291        ..Default::default()
292    }
293}
294
295pub mod pixel_size_state {
296
297    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
298    #[allow(unused)]
299    use ::core::marker::PhantomData;
300    mod sealed {
301        pub trait Sealed {}
302    }
303    /// State trait tracking which required fields have been set
304    pub trait State: sealed::Sealed {
305        type Height;
306        type Width;
307    }
308    /// Empty state - all required fields are unset
309    pub struct Empty(());
310    impl sealed::Sealed for Empty {}
311    impl State for Empty {
312        type Height = Unset;
313        type Width = Unset;
314    }
315    ///State transition - sets the `height` field to Set
316    pub struct SetHeight<S: State = Empty>(PhantomData<fn() -> S>);
317    impl<S: State> sealed::Sealed for SetHeight<S> {}
318    impl<S: State> State for SetHeight<S> {
319        type Height = Set<members::height>;
320        type Width = S::Width;
321    }
322    ///State transition - sets the `width` field to Set
323    pub struct SetWidth<S: State = Empty>(PhantomData<fn() -> S>);
324    impl<S: State> sealed::Sealed for SetWidth<S> {}
325    impl<S: State> State for SetWidth<S> {
326        type Height = S::Height;
327        type Width = Set<members::width>;
328    }
329    /// Marker types for field names
330    #[allow(non_camel_case_types)]
331    pub mod members {
332        ///Marker type for the `height` field
333        pub struct height(());
334        ///Marker type for the `width` field
335        pub struct width(());
336    }
337}
338
339/// Builder for constructing an instance of this type
340pub struct PixelSizeBuilder<'a, S: pixel_size_state::State> {
341    _state: PhantomData<fn() -> S>,
342    _fields: (Option<i64>, Option<i64>),
343    _lifetime: PhantomData<&'a ()>,
344}
345
346impl<'a> PixelSize<'a> {
347    /// Create a new builder for this type
348    pub fn new() -> PixelSizeBuilder<'a, pixel_size_state::Empty> {
349        PixelSizeBuilder::new()
350    }
351}
352
353impl<'a> PixelSizeBuilder<'a, pixel_size_state::Empty> {
354    /// Create a new builder with all fields unset
355    pub fn new() -> Self {
356        PixelSizeBuilder {
357            _state: PhantomData,
358            _fields: (None, None),
359            _lifetime: PhantomData,
360        }
361    }
362}
363
364impl<'a, S> PixelSizeBuilder<'a, S>
365where
366    S: pixel_size_state::State,
367    S::Height: pixel_size_state::IsUnset,
368{
369    /// Set the `height` field (required)
370    pub fn height(
371        mut self,
372        value: impl Into<i64>,
373    ) -> PixelSizeBuilder<'a, pixel_size_state::SetHeight<S>> {
374        self._fields.0 = Option::Some(value.into());
375        PixelSizeBuilder {
376            _state: PhantomData,
377            _fields: self._fields,
378            _lifetime: PhantomData,
379        }
380    }
381}
382
383impl<'a, S> PixelSizeBuilder<'a, S>
384where
385    S: pixel_size_state::State,
386    S::Width: pixel_size_state::IsUnset,
387{
388    /// Set the `width` field (required)
389    pub fn width(
390        mut self,
391        value: impl Into<i64>,
392    ) -> PixelSizeBuilder<'a, pixel_size_state::SetWidth<S>> {
393        self._fields.1 = Option::Some(value.into());
394        PixelSizeBuilder {
395            _state: PhantomData,
396            _fields: self._fields,
397            _lifetime: PhantomData,
398        }
399    }
400}
401
402impl<'a, S> PixelSizeBuilder<'a, S>
403where
404    S: pixel_size_state::State,
405    S::Height: pixel_size_state::IsSet,
406    S::Width: pixel_size_state::IsSet,
407{
408    /// Build the final struct
409    pub fn build(self) -> PixelSize<'a> {
410        PixelSize {
411            height: self._fields.0.unwrap(),
412            width: self._fields.1.unwrap(),
413            extra_data: Default::default(),
414        }
415    }
416    /// Build the final struct with custom extra_data
417    pub fn build_with_data(
418        self,
419        extra_data: BTreeMap<
420            jacquard_common::deps::smol_str::SmolStr,
421            jacquard_common::types::value::Data<'a>,
422        >,
423    ) -> PixelSize<'a> {
424        PixelSize {
425            height: self._fields.0.unwrap(),
426            width: self._fields.1.unwrap(),
427            extra_data: Some(extra_data),
428        }
429    }
430}