Skip to main content

jacquard_api/app_bsky/embed/
external.rs

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