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