Skip to main content

jacquard_api/sh_weaver/embed/
images.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: sh.weaver.embed.images
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_common::types::blob::BlobRef;
18use jacquard_common::types::string::UriValue;
19use jacquard_derive::{IntoStatic, lexicon, open_union};
20use jacquard_lexicon::lexicon::LexiconDoc;
21use jacquard_lexicon::schema::LexiconSchema;
22
23#[allow(unused_imports)]
24use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
25use serde::{Serialize, Deserialize};
26use crate::app_bsky::embed::AspectRatio;
27use crate::sh_weaver::embed::PercentSize;
28use crate::sh_weaver::embed::PixelSize;
29use crate::sh_weaver::embed::images;
30
31#[lexicon]
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
33#[serde(rename_all = "camelCase")]
34pub struct Image<'a> {
35    ///alt text description of the image
36    #[serde(borrow)]
37    pub alt: CowStr<'a>,
38    ///Blurhash string for the image, used for low-resolution placeholders. This must be a valid Blurhash string.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(borrow)]
41    pub blurhash: Option<CowStr<'a>>,
42    #[serde(skip_serializing_if = "Option::is_none")]
43    #[serde(borrow)]
44    pub dimensions: Option<ImageDimensions<'a>>,
45    #[serde(borrow)]
46    pub image: BlobRef<'a>,
47    #[serde(skip_serializing_if = "Option::is_none")]
48    #[serde(borrow)]
49    pub name: Option<CowStr<'a>>,
50}
51
52
53#[open_union]
54#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
55#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
56pub enum ImageDimensions<'a> {
57    #[serde(rename = "app.bsky.embed.defs#aspectRatio")]
58    AspectRatio(Box<AspectRatio<'a>>),
59    #[serde(rename = "sh.weaver.embed.defs#percentSize")]
60    PercentSize(Box<PercentSize<'a>>),
61    #[serde(rename = "sh.weaver.embed.defs#pixelSize")]
62    PixelSize(Box<PixelSize<'a>>),
63}
64
65
66#[lexicon]
67#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
68#[serde(rename_all = "camelCase")]
69pub struct Images<'a> {
70    #[serde(borrow)]
71    pub images: Vec<images::Image<'a>>,
72}
73
74
75#[lexicon]
76#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
77#[serde(rename_all = "camelCase")]
78pub struct View<'a> {
79    #[serde(borrow)]
80    pub images: Vec<images::ViewImage<'a>>,
81}
82
83
84#[lexicon]
85#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
86#[serde(rename_all = "camelCase")]
87pub struct ViewImage<'a> {
88    ///Alt text description of the image, for accessibility.
89    #[serde(borrow)]
90    pub alt: CowStr<'a>,
91    #[serde(skip_serializing_if = "Option::is_none")]
92    #[serde(borrow)]
93    pub dimensions: Option<ViewImageDimensions<'a>>,
94    ///Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View.
95    #[serde(borrow)]
96    pub fullsize: UriValue<'a>,
97    #[serde(skip_serializing_if = "Option::is_none")]
98    #[serde(borrow)]
99    pub name: Option<CowStr<'a>>,
100    ///Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View.
101    #[serde(borrow)]
102    pub thumb: UriValue<'a>,
103}
104
105
106#[open_union]
107#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
108#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
109pub enum ViewImageDimensions<'a> {
110    #[serde(rename = "app.bsky.embed.defs#aspectRatio")]
111    AspectRatio(Box<AspectRatio<'a>>),
112    #[serde(rename = "sh.weaver.embed.defs#percentSize")]
113    PercentSize(Box<PercentSize<'a>>),
114    #[serde(rename = "sh.weaver.embed.defs#pixelSize")]
115    PixelSize(Box<PixelSize<'a>>),
116}
117
118impl<'a> LexiconSchema for Image<'a> {
119    fn nsid() -> &'static str {
120        "sh.weaver.embed.images"
121    }
122    fn def_name() -> &'static str {
123        "image"
124    }
125    fn lexicon_doc() -> LexiconDoc<'static> {
126        lexicon_doc_sh_weaver_embed_images()
127    }
128    fn validate(&self) -> Result<(), ConstraintError> {
129        if let Some(ref value) = self.blurhash {
130            #[allow(unused_comparisons)]
131            if <str>::len(value.as_ref()) > 32usize {
132                return Err(ConstraintError::MaxLength {
133                    path: ValidationPath::from_field("blurhash"),
134                    max: 32usize,
135                    actual: <str>::len(value.as_ref()),
136                });
137            }
138        }
139        {
140            let value = &self.image;
141            {
142                let size = value.blob().size;
143                if size > 3000000usize {
144                    return Err(ConstraintError::BlobTooLarge {
145                        path: ValidationPath::from_field("image"),
146                        max: 3000000usize,
147                        actual: size,
148                    });
149                }
150            }
151        }
152        {
153            let value = &self.image;
154            {
155                let mime = value.blob().mime_type.as_str();
156                let accepted: &[&str] = &["image/*"];
157                let matched = accepted
158                    .iter()
159                    .any(|pattern| {
160                        if *pattern == "*/*" {
161                            true
162                        } else if pattern.ends_with("/*") {
163                            let prefix = &pattern[..pattern.len() - 2];
164                            mime.starts_with(prefix)
165                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
166                        } else {
167                            mime == *pattern
168                        }
169                    });
170                if !matched {
171                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
172                        path: ValidationPath::from_field("image"),
173                        accepted: vec!["image/*".to_string()],
174                        actual: mime.to_string(),
175                    });
176                }
177            }
178        }
179        if let Some(ref value) = self.name {
180            #[allow(unused_comparisons)]
181            if <str>::len(value.as_ref()) > 128usize {
182                return Err(ConstraintError::MaxLength {
183                    path: ValidationPath::from_field("name"),
184                    max: 128usize,
185                    actual: <str>::len(value.as_ref()),
186                });
187            }
188        }
189        Ok(())
190    }
191}
192
193impl<'a> LexiconSchema for Images<'a> {
194    fn nsid() -> &'static str {
195        "sh.weaver.embed.images"
196    }
197    fn def_name() -> &'static str {
198        "main"
199    }
200    fn lexicon_doc() -> LexiconDoc<'static> {
201        lexicon_doc_sh_weaver_embed_images()
202    }
203    fn validate(&self) -> Result<(), ConstraintError> {
204        {
205            let value = &self.images;
206            #[allow(unused_comparisons)]
207            if value.len() > 48usize {
208                return Err(ConstraintError::MaxLength {
209                    path: ValidationPath::from_field("images"),
210                    max: 48usize,
211                    actual: value.len(),
212                });
213            }
214        }
215        Ok(())
216    }
217}
218
219impl<'a> LexiconSchema for View<'a> {
220    fn nsid() -> &'static str {
221        "sh.weaver.embed.images"
222    }
223    fn def_name() -> &'static str {
224        "view"
225    }
226    fn lexicon_doc() -> LexiconDoc<'static> {
227        lexicon_doc_sh_weaver_embed_images()
228    }
229    fn validate(&self) -> Result<(), ConstraintError> {
230        {
231            let value = &self.images;
232            #[allow(unused_comparisons)]
233            if value.len() > 48usize {
234                return Err(ConstraintError::MaxLength {
235                    path: ValidationPath::from_field("images"),
236                    max: 48usize,
237                    actual: value.len(),
238                });
239            }
240        }
241        Ok(())
242    }
243}
244
245impl<'a> LexiconSchema for ViewImage<'a> {
246    fn nsid() -> &'static str {
247        "sh.weaver.embed.images"
248    }
249    fn def_name() -> &'static str {
250        "viewImage"
251    }
252    fn lexicon_doc() -> LexiconDoc<'static> {
253        lexicon_doc_sh_weaver_embed_images()
254    }
255    fn validate(&self) -> Result<(), ConstraintError> {
256        if let Some(ref value) = self.name {
257            #[allow(unused_comparisons)]
258            if <str>::len(value.as_ref()) > 128usize {
259                return Err(ConstraintError::MaxLength {
260                    path: ValidationPath::from_field("name"),
261                    max: 128usize,
262                    actual: <str>::len(value.as_ref()),
263                });
264            }
265        }
266        Ok(())
267    }
268}
269
270pub mod image_state {
271
272    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
273    #[allow(unused)]
274    use ::core::marker::PhantomData;
275    mod sealed {
276        pub trait Sealed {}
277    }
278    /// State trait tracking which required fields have been set
279    pub trait State: sealed::Sealed {
280        type Image;
281        type Alt;
282    }
283    /// Empty state - all required fields are unset
284    pub struct Empty(());
285    impl sealed::Sealed for Empty {}
286    impl State for Empty {
287        type Image = Unset;
288        type Alt = Unset;
289    }
290    ///State transition - sets the `image` field to Set
291    pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
292    impl<S: State> sealed::Sealed for SetImage<S> {}
293    impl<S: State> State for SetImage<S> {
294        type Image = Set<members::image>;
295        type Alt = S::Alt;
296    }
297    ///State transition - sets the `alt` field to Set
298    pub struct SetAlt<S: State = Empty>(PhantomData<fn() -> S>);
299    impl<S: State> sealed::Sealed for SetAlt<S> {}
300    impl<S: State> State for SetAlt<S> {
301        type Image = S::Image;
302        type Alt = Set<members::alt>;
303    }
304    /// Marker types for field names
305    #[allow(non_camel_case_types)]
306    pub mod members {
307        ///Marker type for the `image` field
308        pub struct image(());
309        ///Marker type for the `alt` field
310        pub struct alt(());
311    }
312}
313
314/// Builder for constructing an instance of this type
315pub struct ImageBuilder<'a, S: image_state::State> {
316    _state: PhantomData<fn() -> S>,
317    _fields: (
318        Option<CowStr<'a>>,
319        Option<CowStr<'a>>,
320        Option<ImageDimensions<'a>>,
321        Option<BlobRef<'a>>,
322        Option<CowStr<'a>>,
323    ),
324    _lifetime: PhantomData<&'a ()>,
325}
326
327impl<'a> Image<'a> {
328    /// Create a new builder for this type
329    pub fn new() -> ImageBuilder<'a, image_state::Empty> {
330        ImageBuilder::new()
331    }
332}
333
334impl<'a> ImageBuilder<'a, image_state::Empty> {
335    /// Create a new builder with all fields unset
336    pub fn new() -> Self {
337        ImageBuilder {
338            _state: PhantomData,
339            _fields: (None, None, None, None, None),
340            _lifetime: PhantomData,
341        }
342    }
343}
344
345impl<'a, S> ImageBuilder<'a, S>
346where
347    S: image_state::State,
348    S::Alt: image_state::IsUnset,
349{
350    /// Set the `alt` field (required)
351    pub fn alt(
352        mut self,
353        value: impl Into<CowStr<'a>>,
354    ) -> ImageBuilder<'a, image_state::SetAlt<S>> {
355        self._fields.0 = Option::Some(value.into());
356        ImageBuilder {
357            _state: PhantomData,
358            _fields: self._fields,
359            _lifetime: PhantomData,
360        }
361    }
362}
363
364impl<'a, S: image_state::State> ImageBuilder<'a, S> {
365    /// Set the `blurhash` field (optional)
366    pub fn blurhash(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
367        self._fields.1 = value.into();
368        self
369    }
370    /// Set the `blurhash` field to an Option value (optional)
371    pub fn maybe_blurhash(mut self, value: Option<CowStr<'a>>) -> Self {
372        self._fields.1 = value;
373        self
374    }
375}
376
377impl<'a, S: image_state::State> ImageBuilder<'a, S> {
378    /// Set the `dimensions` field (optional)
379    pub fn dimensions(mut self, value: impl Into<Option<ImageDimensions<'a>>>) -> Self {
380        self._fields.2 = value.into();
381        self
382    }
383    /// Set the `dimensions` field to an Option value (optional)
384    pub fn maybe_dimensions(mut self, value: Option<ImageDimensions<'a>>) -> Self {
385        self._fields.2 = value;
386        self
387    }
388}
389
390impl<'a, S> ImageBuilder<'a, S>
391where
392    S: image_state::State,
393    S::Image: image_state::IsUnset,
394{
395    /// Set the `image` field (required)
396    pub fn image(
397        mut self,
398        value: impl Into<BlobRef<'a>>,
399    ) -> ImageBuilder<'a, image_state::SetImage<S>> {
400        self._fields.3 = Option::Some(value.into());
401        ImageBuilder {
402            _state: PhantomData,
403            _fields: self._fields,
404            _lifetime: PhantomData,
405        }
406    }
407}
408
409impl<'a, S: image_state::State> ImageBuilder<'a, S> {
410    /// Set the `name` field (optional)
411    pub fn name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
412        self._fields.4 = value.into();
413        self
414    }
415    /// Set the `name` field to an Option value (optional)
416    pub fn maybe_name(mut self, value: Option<CowStr<'a>>) -> Self {
417        self._fields.4 = value;
418        self
419    }
420}
421
422impl<'a, S> ImageBuilder<'a, S>
423where
424    S: image_state::State,
425    S::Image: image_state::IsSet,
426    S::Alt: image_state::IsSet,
427{
428    /// Build the final struct
429    pub fn build(self) -> Image<'a> {
430        Image {
431            alt: self._fields.0.unwrap(),
432            blurhash: self._fields.1,
433            dimensions: self._fields.2,
434            image: self._fields.3.unwrap(),
435            name: self._fields.4,
436            extra_data: Default::default(),
437        }
438    }
439    /// Build the final struct with custom extra_data
440    pub fn build_with_data(
441        self,
442        extra_data: BTreeMap<
443            jacquard_common::deps::smol_str::SmolStr,
444            jacquard_common::types::value::Data<'a>,
445        >,
446    ) -> Image<'a> {
447        Image {
448            alt: self._fields.0.unwrap(),
449            blurhash: self._fields.1,
450            dimensions: self._fields.2,
451            image: self._fields.3.unwrap(),
452            name: self._fields.4,
453            extra_data: Some(extra_data),
454        }
455    }
456}
457
458fn lexicon_doc_sh_weaver_embed_images() -> LexiconDoc<'static> {
459    #[allow(unused_imports)]
460    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
461    use jacquard_lexicon::lexicon::*;
462    use alloc::collections::BTreeMap;
463    LexiconDoc {
464        lexicon: Lexicon::Lexicon1,
465        id: CowStr::new_static("sh.weaver.embed.images"),
466        defs: {
467            let mut map = BTreeMap::new();
468            map.insert(
469                SmolStr::new_static("image"),
470                LexUserType::Object(LexObject {
471                    required: Some(
472                        vec![SmolStr::new_static("image"), SmolStr::new_static("alt")],
473                    ),
474                    properties: {
475                        #[allow(unused_mut)]
476                        let mut map = BTreeMap::new();
477                        map.insert(
478                            SmolStr::new_static("alt"),
479                            LexObjectProperty::String(LexString {
480                                description: Some(
481                                    CowStr::new_static("alt text description of the image"),
482                                ),
483                                ..Default::default()
484                            }),
485                        );
486                        map.insert(
487                            SmolStr::new_static("blurhash"),
488                            LexObjectProperty::String(LexString {
489                                description: Some(
490                                    CowStr::new_static(
491                                        "Blurhash string for the image, used for low-resolution placeholders. This must be a valid Blurhash string.",
492                                    ),
493                                ),
494                                max_length: Some(32usize),
495                                ..Default::default()
496                            }),
497                        );
498                        map.insert(
499                            SmolStr::new_static("dimensions"),
500                            LexObjectProperty::Union(LexRefUnion {
501                                refs: vec![
502                                    CowStr::new_static("app.bsky.embed.defs#aspectRatio"),
503                                    CowStr::new_static("sh.weaver.embed.defs#percentSize"),
504                                    CowStr::new_static("sh.weaver.embed.defs#pixelSize")
505                                ],
506                                ..Default::default()
507                            }),
508                        );
509                        map.insert(
510                            SmolStr::new_static("image"),
511                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
512                        );
513                        map.insert(
514                            SmolStr::new_static("name"),
515                            LexObjectProperty::String(LexString {
516                                max_length: Some(128usize),
517                                ..Default::default()
518                            }),
519                        );
520                        map
521                    },
522                    ..Default::default()
523                }),
524            );
525            map.insert(
526                SmolStr::new_static("main"),
527                LexUserType::Object(LexObject {
528                    required: Some(vec![SmolStr::new_static("images")]),
529                    properties: {
530                        #[allow(unused_mut)]
531                        let mut map = BTreeMap::new();
532                        map.insert(
533                            SmolStr::new_static("images"),
534                            LexObjectProperty::Array(LexArray {
535                                items: LexArrayItem::Ref(LexRef {
536                                    r#ref: CowStr::new_static("#image"),
537                                    ..Default::default()
538                                }),
539                                max_length: Some(48usize),
540                                ..Default::default()
541                            }),
542                        );
543                        map
544                    },
545                    ..Default::default()
546                }),
547            );
548            map.insert(
549                SmolStr::new_static("view"),
550                LexUserType::Object(LexObject {
551                    required: Some(vec![SmolStr::new_static("images")]),
552                    properties: {
553                        #[allow(unused_mut)]
554                        let mut map = BTreeMap::new();
555                        map.insert(
556                            SmolStr::new_static("images"),
557                            LexObjectProperty::Array(LexArray {
558                                items: LexArrayItem::Ref(LexRef {
559                                    r#ref: CowStr::new_static("#viewImage"),
560                                    ..Default::default()
561                                }),
562                                max_length: Some(48usize),
563                                ..Default::default()
564                            }),
565                        );
566                        map
567                    },
568                    ..Default::default()
569                }),
570            );
571            map.insert(
572                SmolStr::new_static("viewImage"),
573                LexUserType::Object(LexObject {
574                    required: Some(
575                        vec![
576                            SmolStr::new_static("thumb"),
577                            SmolStr::new_static("fullsize"), SmolStr::new_static("alt")
578                        ],
579                    ),
580                    properties: {
581                        #[allow(unused_mut)]
582                        let mut map = BTreeMap::new();
583                        map.insert(
584                            SmolStr::new_static("alt"),
585                            LexObjectProperty::String(LexString {
586                                description: Some(
587                                    CowStr::new_static(
588                                        "Alt text description of the image, for accessibility.",
589                                    ),
590                                ),
591                                ..Default::default()
592                            }),
593                        );
594                        map.insert(
595                            SmolStr::new_static("dimensions"),
596                            LexObjectProperty::Union(LexRefUnion {
597                                refs: vec![
598                                    CowStr::new_static("app.bsky.embed.defs#aspectRatio"),
599                                    CowStr::new_static("sh.weaver.embed.defs#percentSize"),
600                                    CowStr::new_static("sh.weaver.embed.defs#pixelSize")
601                                ],
602                                ..Default::default()
603                            }),
604                        );
605                        map.insert(
606                            SmolStr::new_static("fullsize"),
607                            LexObjectProperty::String(LexString {
608                                description: Some(
609                                    CowStr::new_static(
610                                        "Fully-qualified URL where a large version of the image can be fetched. May or may not be the exact original blob. For example, CDN location provided by the App View.",
611                                    ),
612                                ),
613                                format: Some(LexStringFormat::Uri),
614                                ..Default::default()
615                            }),
616                        );
617                        map.insert(
618                            SmolStr::new_static("name"),
619                            LexObjectProperty::String(LexString {
620                                max_length: Some(128usize),
621                                ..Default::default()
622                            }),
623                        );
624                        map.insert(
625                            SmolStr::new_static("thumb"),
626                            LexObjectProperty::String(LexString {
627                                description: Some(
628                                    CowStr::new_static(
629                                        "Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View.",
630                                    ),
631                                ),
632                                format: Some(LexStringFormat::Uri),
633                                ..Default::default()
634                            }),
635                        );
636                        map
637                    },
638                    ..Default::default()
639                }),
640            );
641            map
642        },
643        ..Default::default()
644    }
645}
646
647pub mod images_state {
648
649    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
650    #[allow(unused)]
651    use ::core::marker::PhantomData;
652    mod sealed {
653        pub trait Sealed {}
654    }
655    /// State trait tracking which required fields have been set
656    pub trait State: sealed::Sealed {
657        type Images;
658    }
659    /// Empty state - all required fields are unset
660    pub struct Empty(());
661    impl sealed::Sealed for Empty {}
662    impl State for Empty {
663        type Images = Unset;
664    }
665    ///State transition - sets the `images` field to Set
666    pub struct SetImages<S: State = Empty>(PhantomData<fn() -> S>);
667    impl<S: State> sealed::Sealed for SetImages<S> {}
668    impl<S: State> State for SetImages<S> {
669        type Images = Set<members::images>;
670    }
671    /// Marker types for field names
672    #[allow(non_camel_case_types)]
673    pub mod members {
674        ///Marker type for the `images` field
675        pub struct images(());
676    }
677}
678
679/// Builder for constructing an instance of this type
680pub struct ImagesBuilder<'a, S: images_state::State> {
681    _state: PhantomData<fn() -> S>,
682    _fields: (Option<Vec<images::Image<'a>>>,),
683    _lifetime: PhantomData<&'a ()>,
684}
685
686impl<'a> Images<'a> {
687    /// Create a new builder for this type
688    pub fn new() -> ImagesBuilder<'a, images_state::Empty> {
689        ImagesBuilder::new()
690    }
691}
692
693impl<'a> ImagesBuilder<'a, images_state::Empty> {
694    /// Create a new builder with all fields unset
695    pub fn new() -> Self {
696        ImagesBuilder {
697            _state: PhantomData,
698            _fields: (None,),
699            _lifetime: PhantomData,
700        }
701    }
702}
703
704impl<'a, S> ImagesBuilder<'a, S>
705where
706    S: images_state::State,
707    S::Images: images_state::IsUnset,
708{
709    /// Set the `images` field (required)
710    pub fn images(
711        mut self,
712        value: impl Into<Vec<images::Image<'a>>>,
713    ) -> ImagesBuilder<'a, images_state::SetImages<S>> {
714        self._fields.0 = Option::Some(value.into());
715        ImagesBuilder {
716            _state: PhantomData,
717            _fields: self._fields,
718            _lifetime: PhantomData,
719        }
720    }
721}
722
723impl<'a, S> ImagesBuilder<'a, S>
724where
725    S: images_state::State,
726    S::Images: images_state::IsSet,
727{
728    /// Build the final struct
729    pub fn build(self) -> Images<'a> {
730        Images {
731            images: self._fields.0.unwrap(),
732            extra_data: Default::default(),
733        }
734    }
735    /// Build the final struct with custom extra_data
736    pub fn build_with_data(
737        self,
738        extra_data: BTreeMap<
739            jacquard_common::deps::smol_str::SmolStr,
740            jacquard_common::types::value::Data<'a>,
741        >,
742    ) -> Images<'a> {
743        Images {
744            images: self._fields.0.unwrap(),
745            extra_data: Some(extra_data),
746        }
747    }
748}
749
750pub mod view_state {
751
752    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
753    #[allow(unused)]
754    use ::core::marker::PhantomData;
755    mod sealed {
756        pub trait Sealed {}
757    }
758    /// State trait tracking which required fields have been set
759    pub trait State: sealed::Sealed {
760        type Images;
761    }
762    /// Empty state - all required fields are unset
763    pub struct Empty(());
764    impl sealed::Sealed for Empty {}
765    impl State for Empty {
766        type Images = Unset;
767    }
768    ///State transition - sets the `images` field to Set
769    pub struct SetImages<S: State = Empty>(PhantomData<fn() -> S>);
770    impl<S: State> sealed::Sealed for SetImages<S> {}
771    impl<S: State> State for SetImages<S> {
772        type Images = Set<members::images>;
773    }
774    /// Marker types for field names
775    #[allow(non_camel_case_types)]
776    pub mod members {
777        ///Marker type for the `images` field
778        pub struct images(());
779    }
780}
781
782/// Builder for constructing an instance of this type
783pub struct ViewBuilder<'a, S: view_state::State> {
784    _state: PhantomData<fn() -> S>,
785    _fields: (Option<Vec<images::ViewImage<'a>>>,),
786    _lifetime: PhantomData<&'a ()>,
787}
788
789impl<'a> View<'a> {
790    /// Create a new builder for this type
791    pub fn new() -> ViewBuilder<'a, view_state::Empty> {
792        ViewBuilder::new()
793    }
794}
795
796impl<'a> ViewBuilder<'a, view_state::Empty> {
797    /// Create a new builder with all fields unset
798    pub fn new() -> Self {
799        ViewBuilder {
800            _state: PhantomData,
801            _fields: (None,),
802            _lifetime: PhantomData,
803        }
804    }
805}
806
807impl<'a, S> ViewBuilder<'a, S>
808where
809    S: view_state::State,
810    S::Images: view_state::IsUnset,
811{
812    /// Set the `images` field (required)
813    pub fn images(
814        mut self,
815        value: impl Into<Vec<images::ViewImage<'a>>>,
816    ) -> ViewBuilder<'a, view_state::SetImages<S>> {
817        self._fields.0 = Option::Some(value.into());
818        ViewBuilder {
819            _state: PhantomData,
820            _fields: self._fields,
821            _lifetime: PhantomData,
822        }
823    }
824}
825
826impl<'a, S> ViewBuilder<'a, S>
827where
828    S: view_state::State,
829    S::Images: view_state::IsSet,
830{
831    /// Build the final struct
832    pub fn build(self) -> View<'a> {
833        View {
834            images: self._fields.0.unwrap(),
835            extra_data: Default::default(),
836        }
837    }
838    /// Build the final struct with custom extra_data
839    pub fn build_with_data(
840        self,
841        extra_data: BTreeMap<
842            jacquard_common::deps::smol_str::SmolStr,
843            jacquard_common::types::value::Data<'a>,
844        >,
845    ) -> View<'a> {
846        View {
847            images: self._fields.0.unwrap(),
848            extra_data: Some(extra_data),
849        }
850    }
851}
852
853pub mod view_image_state {
854
855    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
856    #[allow(unused)]
857    use ::core::marker::PhantomData;
858    mod sealed {
859        pub trait Sealed {}
860    }
861    /// State trait tracking which required fields have been set
862    pub trait State: sealed::Sealed {
863        type Fullsize;
864        type Thumb;
865        type Alt;
866    }
867    /// Empty state - all required fields are unset
868    pub struct Empty(());
869    impl sealed::Sealed for Empty {}
870    impl State for Empty {
871        type Fullsize = Unset;
872        type Thumb = Unset;
873        type Alt = Unset;
874    }
875    ///State transition - sets the `fullsize` field to Set
876    pub struct SetFullsize<S: State = Empty>(PhantomData<fn() -> S>);
877    impl<S: State> sealed::Sealed for SetFullsize<S> {}
878    impl<S: State> State for SetFullsize<S> {
879        type Fullsize = Set<members::fullsize>;
880        type Thumb = S::Thumb;
881        type Alt = S::Alt;
882    }
883    ///State transition - sets the `thumb` field to Set
884    pub struct SetThumb<S: State = Empty>(PhantomData<fn() -> S>);
885    impl<S: State> sealed::Sealed for SetThumb<S> {}
886    impl<S: State> State for SetThumb<S> {
887        type Fullsize = S::Fullsize;
888        type Thumb = Set<members::thumb>;
889        type Alt = S::Alt;
890    }
891    ///State transition - sets the `alt` field to Set
892    pub struct SetAlt<S: State = Empty>(PhantomData<fn() -> S>);
893    impl<S: State> sealed::Sealed for SetAlt<S> {}
894    impl<S: State> State for SetAlt<S> {
895        type Fullsize = S::Fullsize;
896        type Thumb = S::Thumb;
897        type Alt = Set<members::alt>;
898    }
899    /// Marker types for field names
900    #[allow(non_camel_case_types)]
901    pub mod members {
902        ///Marker type for the `fullsize` field
903        pub struct fullsize(());
904        ///Marker type for the `thumb` field
905        pub struct thumb(());
906        ///Marker type for the `alt` field
907        pub struct alt(());
908    }
909}
910
911/// Builder for constructing an instance of this type
912pub struct ViewImageBuilder<'a, S: view_image_state::State> {
913    _state: PhantomData<fn() -> S>,
914    _fields: (
915        Option<CowStr<'a>>,
916        Option<ViewImageDimensions<'a>>,
917        Option<UriValue<'a>>,
918        Option<CowStr<'a>>,
919        Option<UriValue<'a>>,
920    ),
921    _lifetime: PhantomData<&'a ()>,
922}
923
924impl<'a> ViewImage<'a> {
925    /// Create a new builder for this type
926    pub fn new() -> ViewImageBuilder<'a, view_image_state::Empty> {
927        ViewImageBuilder::new()
928    }
929}
930
931impl<'a> ViewImageBuilder<'a, view_image_state::Empty> {
932    /// Create a new builder with all fields unset
933    pub fn new() -> Self {
934        ViewImageBuilder {
935            _state: PhantomData,
936            _fields: (None, None, None, None, None),
937            _lifetime: PhantomData,
938        }
939    }
940}
941
942impl<'a, S> ViewImageBuilder<'a, S>
943where
944    S: view_image_state::State,
945    S::Alt: view_image_state::IsUnset,
946{
947    /// Set the `alt` field (required)
948    pub fn alt(
949        mut self,
950        value: impl Into<CowStr<'a>>,
951    ) -> ViewImageBuilder<'a, view_image_state::SetAlt<S>> {
952        self._fields.0 = Option::Some(value.into());
953        ViewImageBuilder {
954            _state: PhantomData,
955            _fields: self._fields,
956            _lifetime: PhantomData,
957        }
958    }
959}
960
961impl<'a, S: view_image_state::State> ViewImageBuilder<'a, S> {
962    /// Set the `dimensions` field (optional)
963    pub fn dimensions(
964        mut self,
965        value: impl Into<Option<ViewImageDimensions<'a>>>,
966    ) -> Self {
967        self._fields.1 = value.into();
968        self
969    }
970    /// Set the `dimensions` field to an Option value (optional)
971    pub fn maybe_dimensions(mut self, value: Option<ViewImageDimensions<'a>>) -> Self {
972        self._fields.1 = value;
973        self
974    }
975}
976
977impl<'a, S> ViewImageBuilder<'a, S>
978where
979    S: view_image_state::State,
980    S::Fullsize: view_image_state::IsUnset,
981{
982    /// Set the `fullsize` field (required)
983    pub fn fullsize(
984        mut self,
985        value: impl Into<UriValue<'a>>,
986    ) -> ViewImageBuilder<'a, view_image_state::SetFullsize<S>> {
987        self._fields.2 = Option::Some(value.into());
988        ViewImageBuilder {
989            _state: PhantomData,
990            _fields: self._fields,
991            _lifetime: PhantomData,
992        }
993    }
994}
995
996impl<'a, S: view_image_state::State> ViewImageBuilder<'a, S> {
997    /// Set the `name` field (optional)
998    pub fn name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
999        self._fields.3 = value.into();
1000        self
1001    }
1002    /// Set the `name` field to an Option value (optional)
1003    pub fn maybe_name(mut self, value: Option<CowStr<'a>>) -> Self {
1004        self._fields.3 = value;
1005        self
1006    }
1007}
1008
1009impl<'a, S> ViewImageBuilder<'a, S>
1010where
1011    S: view_image_state::State,
1012    S::Thumb: view_image_state::IsUnset,
1013{
1014    /// Set the `thumb` field (required)
1015    pub fn thumb(
1016        mut self,
1017        value: impl Into<UriValue<'a>>,
1018    ) -> ViewImageBuilder<'a, view_image_state::SetThumb<S>> {
1019        self._fields.4 = Option::Some(value.into());
1020        ViewImageBuilder {
1021            _state: PhantomData,
1022            _fields: self._fields,
1023            _lifetime: PhantomData,
1024        }
1025    }
1026}
1027
1028impl<'a, S> ViewImageBuilder<'a, S>
1029where
1030    S: view_image_state::State,
1031    S::Fullsize: view_image_state::IsSet,
1032    S::Thumb: view_image_state::IsSet,
1033    S::Alt: view_image_state::IsSet,
1034{
1035    /// Build the final struct
1036    pub fn build(self) -> ViewImage<'a> {
1037        ViewImage {
1038            alt: self._fields.0.unwrap(),
1039            dimensions: self._fields.1,
1040            fullsize: self._fields.2.unwrap(),
1041            name: self._fields.3,
1042            thumb: self._fields.4.unwrap(),
1043            extra_data: Default::default(),
1044        }
1045    }
1046    /// Build the final struct with custom extra_data
1047    pub fn build_with_data(
1048        self,
1049        extra_data: BTreeMap<
1050            jacquard_common::deps::smol_str::SmolStr,
1051            jacquard_common::types::value::Data<'a>,
1052        >,
1053    ) -> ViewImage<'a> {
1054        ViewImage {
1055            alt: self._fields.0.unwrap(),
1056            dimensions: self._fields.1,
1057            fullsize: self._fields.2.unwrap(),
1058            name: self._fields.3,
1059            thumb: self._fields.4.unwrap(),
1060            extra_data: Some(extra_data),
1061        }
1062    }
1063}