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