1#[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};
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::app_bsky::embed::images;
28
29#[lexicon]
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
31#[serde(rename_all = "camelCase")]
32pub struct Image<'a> {
33 #[serde(borrow)]
35 pub alt: CowStr<'a>,
36 #[serde(skip_serializing_if = "Option::is_none")]
37 #[serde(borrow)]
38 pub aspect_ratio: Option<AspectRatio<'a>>,
39 #[serde(borrow)]
40 pub image: BlobRef<'a>,
41}
42
43
44#[lexicon]
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
46#[serde(rename_all = "camelCase")]
47pub struct Images<'a> {
48 #[serde(borrow)]
49 pub images: Vec<images::Image<'a>>,
50}
51
52
53#[lexicon]
54#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
55#[serde(rename_all = "camelCase")]
56pub struct View<'a> {
57 #[serde(borrow)]
58 pub images: Vec<images::ViewImage<'a>>,
59}
60
61
62#[lexicon]
63#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
64#[serde(rename_all = "camelCase")]
65pub struct ViewImage<'a> {
66 #[serde(borrow)]
68 pub alt: CowStr<'a>,
69 #[serde(skip_serializing_if = "Option::is_none")]
70 #[serde(borrow)]
71 pub aspect_ratio: Option<AspectRatio<'a>>,
72 #[serde(borrow)]
74 pub fullsize: UriValue<'a>,
75 #[serde(borrow)]
77 pub thumb: UriValue<'a>,
78}
79
80impl<'a> LexiconSchema for Image<'a> {
81 fn nsid() -> &'static str {
82 "app.bsky.embed.images"
83 }
84 fn def_name() -> &'static str {
85 "image"
86 }
87 fn lexicon_doc() -> LexiconDoc<'static> {
88 lexicon_doc_app_bsky_embed_images()
89 }
90 fn validate(&self) -> Result<(), ConstraintError> {
91 {
92 let value = &self.image;
93 {
94 let size = value.blob().size;
95 if size > 1000000usize {
96 return Err(ConstraintError::BlobTooLarge {
97 path: ValidationPath::from_field("image"),
98 max: 1000000usize,
99 actual: size,
100 });
101 }
102 }
103 }
104 {
105 let value = &self.image;
106 {
107 let mime = value.blob().mime_type.as_str();
108 let accepted: &[&str] = &["image/*"];
109 let matched = accepted
110 .iter()
111 .any(|pattern| {
112 if *pattern == "*/*" {
113 true
114 } else if pattern.ends_with("/*") {
115 let prefix = &pattern[..pattern.len() - 2];
116 mime.starts_with(prefix)
117 && mime.as_bytes().get(prefix.len()) == Some(&b'/')
118 } else {
119 mime == *pattern
120 }
121 });
122 if !matched {
123 return Err(ConstraintError::BlobMimeTypeNotAccepted {
124 path: ValidationPath::from_field("image"),
125 accepted: vec!["image/*".to_string()],
126 actual: mime.to_string(),
127 });
128 }
129 }
130 }
131 Ok(())
132 }
133}
134
135impl<'a> LexiconSchema for Images<'a> {
136 fn nsid() -> &'static str {
137 "app.bsky.embed.images"
138 }
139 fn def_name() -> &'static str {
140 "main"
141 }
142 fn lexicon_doc() -> LexiconDoc<'static> {
143 lexicon_doc_app_bsky_embed_images()
144 }
145 fn validate(&self) -> Result<(), ConstraintError> {
146 {
147 let value = &self.images;
148 #[allow(unused_comparisons)]
149 if value.len() > 4usize {
150 return Err(ConstraintError::MaxLength {
151 path: ValidationPath::from_field("images"),
152 max: 4usize,
153 actual: value.len(),
154 });
155 }
156 }
157 Ok(())
158 }
159}
160
161impl<'a> LexiconSchema for View<'a> {
162 fn nsid() -> &'static str {
163 "app.bsky.embed.images"
164 }
165 fn def_name() -> &'static str {
166 "view"
167 }
168 fn lexicon_doc() -> LexiconDoc<'static> {
169 lexicon_doc_app_bsky_embed_images()
170 }
171 fn validate(&self) -> Result<(), ConstraintError> {
172 {
173 let value = &self.images;
174 #[allow(unused_comparisons)]
175 if value.len() > 4usize {
176 return Err(ConstraintError::MaxLength {
177 path: ValidationPath::from_field("images"),
178 max: 4usize,
179 actual: value.len(),
180 });
181 }
182 }
183 Ok(())
184 }
185}
186
187impl<'a> LexiconSchema for ViewImage<'a> {
188 fn nsid() -> &'static str {
189 "app.bsky.embed.images"
190 }
191 fn def_name() -> &'static str {
192 "viewImage"
193 }
194 fn lexicon_doc() -> LexiconDoc<'static> {
195 lexicon_doc_app_bsky_embed_images()
196 }
197 fn validate(&self) -> Result<(), ConstraintError> {
198 Ok(())
199 }
200}
201
202pub mod image_state {
203
204 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
205 #[allow(unused)]
206 use ::core::marker::PhantomData;
207 mod sealed {
208 pub trait Sealed {}
209 }
210 pub trait State: sealed::Sealed {
212 type Image;
213 type Alt;
214 }
215 pub struct Empty(());
217 impl sealed::Sealed for Empty {}
218 impl State for Empty {
219 type Image = Unset;
220 type Alt = Unset;
221 }
222 pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
224 impl<S: State> sealed::Sealed for SetImage<S> {}
225 impl<S: State> State for SetImage<S> {
226 type Image = Set<members::image>;
227 type Alt = S::Alt;
228 }
229 pub struct SetAlt<S: State = Empty>(PhantomData<fn() -> S>);
231 impl<S: State> sealed::Sealed for SetAlt<S> {}
232 impl<S: State> State for SetAlt<S> {
233 type Image = S::Image;
234 type Alt = Set<members::alt>;
235 }
236 #[allow(non_camel_case_types)]
238 pub mod members {
239 pub struct image(());
241 pub struct alt(());
243 }
244}
245
246pub struct ImageBuilder<'a, S: image_state::State> {
248 _state: PhantomData<fn() -> S>,
249 _fields: (Option<CowStr<'a>>, Option<AspectRatio<'a>>, Option<BlobRef<'a>>),
250 _lifetime: PhantomData<&'a ()>,
251}
252
253impl<'a> Image<'a> {
254 pub fn new() -> ImageBuilder<'a, image_state::Empty> {
256 ImageBuilder::new()
257 }
258}
259
260impl<'a> ImageBuilder<'a, image_state::Empty> {
261 pub fn new() -> Self {
263 ImageBuilder {
264 _state: PhantomData,
265 _fields: (None, None, None),
266 _lifetime: PhantomData,
267 }
268 }
269}
270
271impl<'a, S> ImageBuilder<'a, S>
272where
273 S: image_state::State,
274 S::Alt: image_state::IsUnset,
275{
276 pub fn alt(
278 mut self,
279 value: impl Into<CowStr<'a>>,
280 ) -> ImageBuilder<'a, image_state::SetAlt<S>> {
281 self._fields.0 = Option::Some(value.into());
282 ImageBuilder {
283 _state: PhantomData,
284 _fields: self._fields,
285 _lifetime: PhantomData,
286 }
287 }
288}
289
290impl<'a, S: image_state::State> ImageBuilder<'a, S> {
291 pub fn aspect_ratio(mut self, value: impl Into<Option<AspectRatio<'a>>>) -> Self {
293 self._fields.1 = value.into();
294 self
295 }
296 pub fn maybe_aspect_ratio(mut self, value: Option<AspectRatio<'a>>) -> Self {
298 self._fields.1 = value;
299 self
300 }
301}
302
303impl<'a, S> ImageBuilder<'a, S>
304where
305 S: image_state::State,
306 S::Image: image_state::IsUnset,
307{
308 pub fn image(
310 mut self,
311 value: impl Into<BlobRef<'a>>,
312 ) -> ImageBuilder<'a, image_state::SetImage<S>> {
313 self._fields.2 = Option::Some(value.into());
314 ImageBuilder {
315 _state: PhantomData,
316 _fields: self._fields,
317 _lifetime: PhantomData,
318 }
319 }
320}
321
322impl<'a, S> ImageBuilder<'a, S>
323where
324 S: image_state::State,
325 S::Image: image_state::IsSet,
326 S::Alt: image_state::IsSet,
327{
328 pub fn build(self) -> Image<'a> {
330 Image {
331 alt: self._fields.0.unwrap(),
332 aspect_ratio: self._fields.1,
333 image: self._fields.2.unwrap(),
334 extra_data: Default::default(),
335 }
336 }
337 pub fn build_with_data(
339 self,
340 extra_data: BTreeMap<
341 jacquard_common::deps::smol_str::SmolStr,
342 jacquard_common::types::value::Data<'a>,
343 >,
344 ) -> Image<'a> {
345 Image {
346 alt: self._fields.0.unwrap(),
347 aspect_ratio: self._fields.1,
348 image: self._fields.2.unwrap(),
349 extra_data: Some(extra_data),
350 }
351 }
352}
353
354fn lexicon_doc_app_bsky_embed_images() -> LexiconDoc<'static> {
355 #[allow(unused_imports)]
356 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
357 use jacquard_lexicon::lexicon::*;
358 use alloc::collections::BTreeMap;
359 LexiconDoc {
360 lexicon: Lexicon::Lexicon1,
361 id: CowStr::new_static("app.bsky.embed.images"),
362 defs: {
363 let mut map = BTreeMap::new();
364 map.insert(
365 SmolStr::new_static("image"),
366 LexUserType::Object(LexObject {
367 required: Some(
368 vec![SmolStr::new_static("image"), SmolStr::new_static("alt")],
369 ),
370 properties: {
371 #[allow(unused_mut)]
372 let mut map = BTreeMap::new();
373 map.insert(
374 SmolStr::new_static("alt"),
375 LexObjectProperty::String(LexString {
376 description: Some(
377 CowStr::new_static(
378 "Alt text description of the image, for accessibility.",
379 ),
380 ),
381 ..Default::default()
382 }),
383 );
384 map.insert(
385 SmolStr::new_static("aspectRatio"),
386 LexObjectProperty::Ref(LexRef {
387 r#ref: CowStr::new_static(
388 "app.bsky.embed.defs#aspectRatio",
389 ),
390 ..Default::default()
391 }),
392 );
393 map.insert(
394 SmolStr::new_static("image"),
395 LexObjectProperty::Blob(LexBlob { ..Default::default() }),
396 );
397 map
398 },
399 ..Default::default()
400 }),
401 );
402 map.insert(
403 SmolStr::new_static("main"),
404 LexUserType::Object(LexObject {
405 required: Some(vec![SmolStr::new_static("images")]),
406 properties: {
407 #[allow(unused_mut)]
408 let mut map = BTreeMap::new();
409 map.insert(
410 SmolStr::new_static("images"),
411 LexObjectProperty::Array(LexArray {
412 items: LexArrayItem::Ref(LexRef {
413 r#ref: CowStr::new_static("#image"),
414 ..Default::default()
415 }),
416 max_length: Some(4usize),
417 ..Default::default()
418 }),
419 );
420 map
421 },
422 ..Default::default()
423 }),
424 );
425 map.insert(
426 SmolStr::new_static("view"),
427 LexUserType::Object(LexObject {
428 required: Some(vec![SmolStr::new_static("images")]),
429 properties: {
430 #[allow(unused_mut)]
431 let mut map = BTreeMap::new();
432 map.insert(
433 SmolStr::new_static("images"),
434 LexObjectProperty::Array(LexArray {
435 items: LexArrayItem::Ref(LexRef {
436 r#ref: CowStr::new_static("#viewImage"),
437 ..Default::default()
438 }),
439 max_length: Some(4usize),
440 ..Default::default()
441 }),
442 );
443 map
444 },
445 ..Default::default()
446 }),
447 );
448 map.insert(
449 SmolStr::new_static("viewImage"),
450 LexUserType::Object(LexObject {
451 required: Some(
452 vec![
453 SmolStr::new_static("thumb"),
454 SmolStr::new_static("fullsize"), SmolStr::new_static("alt")
455 ],
456 ),
457 properties: {
458 #[allow(unused_mut)]
459 let mut map = BTreeMap::new();
460 map.insert(
461 SmolStr::new_static("alt"),
462 LexObjectProperty::String(LexString {
463 description: Some(
464 CowStr::new_static(
465 "Alt text description of the image, for accessibility.",
466 ),
467 ),
468 ..Default::default()
469 }),
470 );
471 map.insert(
472 SmolStr::new_static("aspectRatio"),
473 LexObjectProperty::Ref(LexRef {
474 r#ref: CowStr::new_static(
475 "app.bsky.embed.defs#aspectRatio",
476 ),
477 ..Default::default()
478 }),
479 );
480 map.insert(
481 SmolStr::new_static("fullsize"),
482 LexObjectProperty::String(LexString {
483 description: Some(
484 CowStr::new_static(
485 "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.",
486 ),
487 ),
488 format: Some(LexStringFormat::Uri),
489 ..Default::default()
490 }),
491 );
492 map.insert(
493 SmolStr::new_static("thumb"),
494 LexObjectProperty::String(LexString {
495 description: Some(
496 CowStr::new_static(
497 "Fully-qualified URL where a thumbnail of the image can be fetched. For example, CDN location provided by the App View.",
498 ),
499 ),
500 format: Some(LexStringFormat::Uri),
501 ..Default::default()
502 }),
503 );
504 map
505 },
506 ..Default::default()
507 }),
508 );
509 map
510 },
511 ..Default::default()
512 }
513}
514
515pub mod images_state {
516
517 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
518 #[allow(unused)]
519 use ::core::marker::PhantomData;
520 mod sealed {
521 pub trait Sealed {}
522 }
523 pub trait State: sealed::Sealed {
525 type Images;
526 }
527 pub struct Empty(());
529 impl sealed::Sealed for Empty {}
530 impl State for Empty {
531 type Images = Unset;
532 }
533 pub struct SetImages<S: State = Empty>(PhantomData<fn() -> S>);
535 impl<S: State> sealed::Sealed for SetImages<S> {}
536 impl<S: State> State for SetImages<S> {
537 type Images = Set<members::images>;
538 }
539 #[allow(non_camel_case_types)]
541 pub mod members {
542 pub struct images(());
544 }
545}
546
547pub struct ImagesBuilder<'a, S: images_state::State> {
549 _state: PhantomData<fn() -> S>,
550 _fields: (Option<Vec<images::Image<'a>>>,),
551 _lifetime: PhantomData<&'a ()>,
552}
553
554impl<'a> Images<'a> {
555 pub fn new() -> ImagesBuilder<'a, images_state::Empty> {
557 ImagesBuilder::new()
558 }
559}
560
561impl<'a> ImagesBuilder<'a, images_state::Empty> {
562 pub fn new() -> Self {
564 ImagesBuilder {
565 _state: PhantomData,
566 _fields: (None,),
567 _lifetime: PhantomData,
568 }
569 }
570}
571
572impl<'a, S> ImagesBuilder<'a, S>
573where
574 S: images_state::State,
575 S::Images: images_state::IsUnset,
576{
577 pub fn images(
579 mut self,
580 value: impl Into<Vec<images::Image<'a>>>,
581 ) -> ImagesBuilder<'a, images_state::SetImages<S>> {
582 self._fields.0 = Option::Some(value.into());
583 ImagesBuilder {
584 _state: PhantomData,
585 _fields: self._fields,
586 _lifetime: PhantomData,
587 }
588 }
589}
590
591impl<'a, S> ImagesBuilder<'a, S>
592where
593 S: images_state::State,
594 S::Images: images_state::IsSet,
595{
596 pub fn build(self) -> Images<'a> {
598 Images {
599 images: self._fields.0.unwrap(),
600 extra_data: Default::default(),
601 }
602 }
603 pub fn build_with_data(
605 self,
606 extra_data: BTreeMap<
607 jacquard_common::deps::smol_str::SmolStr,
608 jacquard_common::types::value::Data<'a>,
609 >,
610 ) -> Images<'a> {
611 Images {
612 images: self._fields.0.unwrap(),
613 extra_data: Some(extra_data),
614 }
615 }
616}
617
618pub mod view_state {
619
620 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
621 #[allow(unused)]
622 use ::core::marker::PhantomData;
623 mod sealed {
624 pub trait Sealed {}
625 }
626 pub trait State: sealed::Sealed {
628 type Images;
629 }
630 pub struct Empty(());
632 impl sealed::Sealed for Empty {}
633 impl State for Empty {
634 type Images = Unset;
635 }
636 pub struct SetImages<S: State = Empty>(PhantomData<fn() -> S>);
638 impl<S: State> sealed::Sealed for SetImages<S> {}
639 impl<S: State> State for SetImages<S> {
640 type Images = Set<members::images>;
641 }
642 #[allow(non_camel_case_types)]
644 pub mod members {
645 pub struct images(());
647 }
648}
649
650pub struct ViewBuilder<'a, S: view_state::State> {
652 _state: PhantomData<fn() -> S>,
653 _fields: (Option<Vec<images::ViewImage<'a>>>,),
654 _lifetime: PhantomData<&'a ()>,
655}
656
657impl<'a> View<'a> {
658 pub fn new() -> ViewBuilder<'a, view_state::Empty> {
660 ViewBuilder::new()
661 }
662}
663
664impl<'a> ViewBuilder<'a, view_state::Empty> {
665 pub fn new() -> Self {
667 ViewBuilder {
668 _state: PhantomData,
669 _fields: (None,),
670 _lifetime: PhantomData,
671 }
672 }
673}
674
675impl<'a, S> ViewBuilder<'a, S>
676where
677 S: view_state::State,
678 S::Images: view_state::IsUnset,
679{
680 pub fn images(
682 mut self,
683 value: impl Into<Vec<images::ViewImage<'a>>>,
684 ) -> ViewBuilder<'a, view_state::SetImages<S>> {
685 self._fields.0 = Option::Some(value.into());
686 ViewBuilder {
687 _state: PhantomData,
688 _fields: self._fields,
689 _lifetime: PhantomData,
690 }
691 }
692}
693
694impl<'a, S> ViewBuilder<'a, S>
695where
696 S: view_state::State,
697 S::Images: view_state::IsSet,
698{
699 pub fn build(self) -> View<'a> {
701 View {
702 images: self._fields.0.unwrap(),
703 extra_data: Default::default(),
704 }
705 }
706 pub fn build_with_data(
708 self,
709 extra_data: BTreeMap<
710 jacquard_common::deps::smol_str::SmolStr,
711 jacquard_common::types::value::Data<'a>,
712 >,
713 ) -> View<'a> {
714 View {
715 images: self._fields.0.unwrap(),
716 extra_data: Some(extra_data),
717 }
718 }
719}
720
721pub mod view_image_state {
722
723 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
724 #[allow(unused)]
725 use ::core::marker::PhantomData;
726 mod sealed {
727 pub trait Sealed {}
728 }
729 pub trait State: sealed::Sealed {
731 type Thumb;
732 type Alt;
733 type Fullsize;
734 }
735 pub struct Empty(());
737 impl sealed::Sealed for Empty {}
738 impl State for Empty {
739 type Thumb = Unset;
740 type Alt = Unset;
741 type Fullsize = Unset;
742 }
743 pub struct SetThumb<S: State = Empty>(PhantomData<fn() -> S>);
745 impl<S: State> sealed::Sealed for SetThumb<S> {}
746 impl<S: State> State for SetThumb<S> {
747 type Thumb = Set<members::thumb>;
748 type Alt = S::Alt;
749 type Fullsize = S::Fullsize;
750 }
751 pub struct SetAlt<S: State = Empty>(PhantomData<fn() -> S>);
753 impl<S: State> sealed::Sealed for SetAlt<S> {}
754 impl<S: State> State for SetAlt<S> {
755 type Thumb = S::Thumb;
756 type Alt = Set<members::alt>;
757 type Fullsize = S::Fullsize;
758 }
759 pub struct SetFullsize<S: State = Empty>(PhantomData<fn() -> S>);
761 impl<S: State> sealed::Sealed for SetFullsize<S> {}
762 impl<S: State> State for SetFullsize<S> {
763 type Thumb = S::Thumb;
764 type Alt = S::Alt;
765 type Fullsize = Set<members::fullsize>;
766 }
767 #[allow(non_camel_case_types)]
769 pub mod members {
770 pub struct thumb(());
772 pub struct alt(());
774 pub struct fullsize(());
776 }
777}
778
779pub struct ViewImageBuilder<'a, S: view_image_state::State> {
781 _state: PhantomData<fn() -> S>,
782 _fields: (
783 Option<CowStr<'a>>,
784 Option<AspectRatio<'a>>,
785 Option<UriValue<'a>>,
786 Option<UriValue<'a>>,
787 ),
788 _lifetime: PhantomData<&'a ()>,
789}
790
791impl<'a> ViewImage<'a> {
792 pub fn new() -> ViewImageBuilder<'a, view_image_state::Empty> {
794 ViewImageBuilder::new()
795 }
796}
797
798impl<'a> ViewImageBuilder<'a, view_image_state::Empty> {
799 pub fn new() -> Self {
801 ViewImageBuilder {
802 _state: PhantomData,
803 _fields: (None, None, None, None),
804 _lifetime: PhantomData,
805 }
806 }
807}
808
809impl<'a, S> ViewImageBuilder<'a, S>
810where
811 S: view_image_state::State,
812 S::Alt: view_image_state::IsUnset,
813{
814 pub fn alt(
816 mut self,
817 value: impl Into<CowStr<'a>>,
818 ) -> ViewImageBuilder<'a, view_image_state::SetAlt<S>> {
819 self._fields.0 = Option::Some(value.into());
820 ViewImageBuilder {
821 _state: PhantomData,
822 _fields: self._fields,
823 _lifetime: PhantomData,
824 }
825 }
826}
827
828impl<'a, S: view_image_state::State> ViewImageBuilder<'a, S> {
829 pub fn aspect_ratio(mut self, value: impl Into<Option<AspectRatio<'a>>>) -> Self {
831 self._fields.1 = value.into();
832 self
833 }
834 pub fn maybe_aspect_ratio(mut self, value: Option<AspectRatio<'a>>) -> Self {
836 self._fields.1 = value;
837 self
838 }
839}
840
841impl<'a, S> ViewImageBuilder<'a, S>
842where
843 S: view_image_state::State,
844 S::Fullsize: view_image_state::IsUnset,
845{
846 pub fn fullsize(
848 mut self,
849 value: impl Into<UriValue<'a>>,
850 ) -> ViewImageBuilder<'a, view_image_state::SetFullsize<S>> {
851 self._fields.2 = Option::Some(value.into());
852 ViewImageBuilder {
853 _state: PhantomData,
854 _fields: self._fields,
855 _lifetime: PhantomData,
856 }
857 }
858}
859
860impl<'a, S> ViewImageBuilder<'a, S>
861where
862 S: view_image_state::State,
863 S::Thumb: view_image_state::IsUnset,
864{
865 pub fn thumb(
867 mut self,
868 value: impl Into<UriValue<'a>>,
869 ) -> ViewImageBuilder<'a, view_image_state::SetThumb<S>> {
870 self._fields.3 = Option::Some(value.into());
871 ViewImageBuilder {
872 _state: PhantomData,
873 _fields: self._fields,
874 _lifetime: PhantomData,
875 }
876 }
877}
878
879impl<'a, S> ViewImageBuilder<'a, S>
880where
881 S: view_image_state::State,
882 S::Thumb: view_image_state::IsSet,
883 S::Alt: view_image_state::IsSet,
884 S::Fullsize: view_image_state::IsSet,
885{
886 pub fn build(self) -> ViewImage<'a> {
888 ViewImage {
889 alt: self._fields.0.unwrap(),
890 aspect_ratio: self._fields.1,
891 fullsize: self._fields.2.unwrap(),
892 thumb: self._fields.3.unwrap(),
893 extra_data: Default::default(),
894 }
895 }
896 pub fn build_with_data(
898 self,
899 extra_data: BTreeMap<
900 jacquard_common::deps::smol_str::SmolStr,
901 jacquard_common::types::value::Data<'a>,
902 >,
903 ) -> ViewImage<'a> {
904 ViewImage {
905 alt: self._fields.0.unwrap(),
906 aspect_ratio: self._fields.1,
907 fullsize: self._fields.2.unwrap(),
908 thumb: self._fields.3.unwrap(),
909 extra_data: Some(extra_data),
910 }
911 }
912}