1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::deps::smol_str::SmolStr;
18use jacquard_common::types::blob::BlobRef;
19use jacquard_common::types::string::{Datetime, UriValue};
20use jacquard_common::types::value::Data;
21use jacquard_derive::IntoStatic;
22use jacquard_lexicon::lexicon::LexiconDoc;
23use jacquard_lexicon::schema::LexiconSchema;
24
25#[allow(unused_imports)]
26use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
27use serde::{Serialize, Deserialize};
28use crate::app_bsky::actor::ProfileViewBasic;
29use crate::com_atproto::label::Label;
30use crate::com_atproto::repo::strong_ref::StrongRef;
31use crate::app_bsky::embed::external;
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
35#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
36pub struct ColorRgb<S: BosStr = DefaultStr> {
37 pub b: i64,
38 pub g: i64,
39 pub r: i64,
40 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
41 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
42}
43
44
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
46#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
47pub struct External<S: BosStr = DefaultStr> {
48 #[serde(skip_serializing_if = "Option::is_none")]
50 pub associated_refs: Option<Vec<StrongRef<S>>>,
51 pub description: S,
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub thumb: Option<BlobRef<S>>,
54 pub title: S,
55 pub uri: UriValue<S>,
56 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
57 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
58}
59
60#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
63#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
64pub struct ExternalRecord<S: BosStr = DefaultStr> {
65 pub external: external::External<S>,
66 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
67 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
68}
69
70
71#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
72#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
73pub struct View<S: BosStr = DefaultStr> {
74 pub external: external::ViewExternal<S>,
75 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
76 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
77}
78
79
80#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
81#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
82pub struct ViewExternal<S: BosStr = DefaultStr> {
83 #[serde(skip_serializing_if = "Option::is_none")]
85 pub associated_profiles: Option<Vec<ProfileViewBasic<S>>>,
86 #[serde(skip_serializing_if = "Option::is_none")]
88 pub associated_refs: Option<Vec<StrongRef<S>>>,
89 #[serde(skip_serializing_if = "Option::is_none")]
91 pub created_at: Option<Datetime>,
92 pub description: S,
93 #[serde(skip_serializing_if = "Option::is_none")]
94 pub labels: Option<Vec<Label<S>>>,
95 #[serde(skip_serializing_if = "Option::is_none")]
97 pub reading_time: Option<i64>,
98 #[serde(skip_serializing_if = "Option::is_none")]
99 pub source: Option<external::ViewExternalSource<S>>,
100 #[serde(skip_serializing_if = "Option::is_none")]
101 pub thumb: Option<UriValue<S>>,
102 pub title: S,
103 #[serde(skip_serializing_if = "Option::is_none")]
105 pub updated_at: Option<Datetime>,
106 pub uri: UriValue<S>,
107 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
108 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
109}
110
111#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
114#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
115pub struct ViewExternalSource<S: BosStr = DefaultStr> {
116 #[serde(skip_serializing_if = "Option::is_none")]
117 pub description: Option<S>,
118 #[serde(skip_serializing_if = "Option::is_none")]
120 pub icon: Option<UriValue<S>>,
121 #[serde(skip_serializing_if = "Option::is_none")]
122 pub theme: Option<external::ViewExternalSourceTheme<S>>,
123 pub title: S,
124 pub uri: UriValue<S>,
126 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
127 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
128}
129
130#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
133#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
134pub struct ViewExternalSourceTheme<S: BosStr = DefaultStr> {
135 #[serde(skip_serializing_if = "Option::is_none")]
136 pub accent_foreground_rgb: Option<external::ColorRgb<S>>,
137 #[serde(skip_serializing_if = "Option::is_none")]
138 pub accent_rgb: Option<external::ColorRgb<S>>,
139 #[serde(skip_serializing_if = "Option::is_none")]
140 pub background_rgb: Option<external::ColorRgb<S>>,
141 #[serde(skip_serializing_if = "Option::is_none")]
142 pub foreground_rgb: Option<external::ColorRgb<S>>,
143 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
144 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
145}
146
147impl<S: BosStr> LexiconSchema for ColorRgb<S> {
148 fn nsid() -> &'static str {
149 "app.bsky.embed.external"
150 }
151 fn def_name() -> &'static str {
152 "colorRGB"
153 }
154 fn lexicon_doc() -> LexiconDoc<'static> {
155 lexicon_doc_app_bsky_embed_external()
156 }
157 fn validate(&self) -> Result<(), ConstraintError> {
158 {
159 let value = &self.b;
160 if *value > 255i64 {
161 return Err(ConstraintError::Maximum {
162 path: ValidationPath::from_field("b"),
163 max: 255i64,
164 actual: *value,
165 });
166 }
167 }
168 {
169 let value = &self.b;
170 if *value < 0i64 {
171 return Err(ConstraintError::Minimum {
172 path: ValidationPath::from_field("b"),
173 min: 0i64,
174 actual: *value,
175 });
176 }
177 }
178 {
179 let value = &self.g;
180 if *value > 255i64 {
181 return Err(ConstraintError::Maximum {
182 path: ValidationPath::from_field("g"),
183 max: 255i64,
184 actual: *value,
185 });
186 }
187 }
188 {
189 let value = &self.g;
190 if *value < 0i64 {
191 return Err(ConstraintError::Minimum {
192 path: ValidationPath::from_field("g"),
193 min: 0i64,
194 actual: *value,
195 });
196 }
197 }
198 {
199 let value = &self.r;
200 if *value > 255i64 {
201 return Err(ConstraintError::Maximum {
202 path: ValidationPath::from_field("r"),
203 max: 255i64,
204 actual: *value,
205 });
206 }
207 }
208 {
209 let value = &self.r;
210 if *value < 0i64 {
211 return Err(ConstraintError::Minimum {
212 path: ValidationPath::from_field("r"),
213 min: 0i64,
214 actual: *value,
215 });
216 }
217 }
218 Ok(())
219 }
220}
221
222impl<S: BosStr> LexiconSchema for External<S> {
223 fn nsid() -> &'static str {
224 "app.bsky.embed.external"
225 }
226 fn def_name() -> &'static str {
227 "external"
228 }
229 fn lexicon_doc() -> LexiconDoc<'static> {
230 lexicon_doc_app_bsky_embed_external()
231 }
232 fn validate(&self) -> Result<(), ConstraintError> {
233 if let Some(ref value) = self.thumb {
234 {
235 let size = value.blob().size;
236 if size > 1000000usize {
237 return Err(ConstraintError::BlobTooLarge {
238 path: ValidationPath::from_field("thumb"),
239 max: 1000000usize,
240 actual: size,
241 });
242 }
243 }
244 }
245 if let Some(ref value) = self.thumb {
246 {
247 let mime = value.blob().mime_type.as_str();
248 let accepted: &[&str] = &["image/*"];
249 let matched = accepted
250 .iter()
251 .any(|pattern| {
252 if *pattern == "*/*" {
253 true
254 } else if pattern.ends_with("/*") {
255 let prefix = &pattern[..pattern.len() - 2];
256 mime.starts_with(prefix)
257 && mime.as_bytes().get(prefix.len()) == Some(&b'/')
258 } else {
259 mime == *pattern
260 }
261 });
262 if !matched {
263 return Err(ConstraintError::BlobMimeTypeNotAccepted {
264 path: ValidationPath::from_field("thumb"),
265 accepted: vec!["image/*".to_string()],
266 actual: mime.to_string(),
267 });
268 }
269 }
270 }
271 Ok(())
272 }
273}
274
275impl<S: BosStr> LexiconSchema for ExternalRecord<S> {
276 fn nsid() -> &'static str {
277 "app.bsky.embed.external"
278 }
279 fn def_name() -> &'static str {
280 "main"
281 }
282 fn lexicon_doc() -> LexiconDoc<'static> {
283 lexicon_doc_app_bsky_embed_external()
284 }
285 fn validate(&self) -> Result<(), ConstraintError> {
286 Ok(())
287 }
288}
289
290impl<S: BosStr> LexiconSchema for View<S> {
291 fn nsid() -> &'static str {
292 "app.bsky.embed.external"
293 }
294 fn def_name() -> &'static str {
295 "view"
296 }
297 fn lexicon_doc() -> LexiconDoc<'static> {
298 lexicon_doc_app_bsky_embed_external()
299 }
300 fn validate(&self) -> Result<(), ConstraintError> {
301 Ok(())
302 }
303}
304
305impl<S: BosStr> LexiconSchema for ViewExternal<S> {
306 fn nsid() -> &'static str {
307 "app.bsky.embed.external"
308 }
309 fn def_name() -> &'static str {
310 "viewExternal"
311 }
312 fn lexicon_doc() -> LexiconDoc<'static> {
313 lexicon_doc_app_bsky_embed_external()
314 }
315 fn validate(&self) -> Result<(), ConstraintError> {
316 Ok(())
317 }
318}
319
320impl<S: BosStr> LexiconSchema for ViewExternalSource<S> {
321 fn nsid() -> &'static str {
322 "app.bsky.embed.external"
323 }
324 fn def_name() -> &'static str {
325 "viewExternalSource"
326 }
327 fn lexicon_doc() -> LexiconDoc<'static> {
328 lexicon_doc_app_bsky_embed_external()
329 }
330 fn validate(&self) -> Result<(), ConstraintError> {
331 Ok(())
332 }
333}
334
335impl<S: BosStr> LexiconSchema for ViewExternalSourceTheme<S> {
336 fn nsid() -> &'static str {
337 "app.bsky.embed.external"
338 }
339 fn def_name() -> &'static str {
340 "viewExternalSourceTheme"
341 }
342 fn lexicon_doc() -> LexiconDoc<'static> {
343 lexicon_doc_app_bsky_embed_external()
344 }
345 fn validate(&self) -> Result<(), ConstraintError> {
346 Ok(())
347 }
348}
349
350pub mod color_rgb_state {
351
352 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
353 #[allow(unused)]
354 use ::core::marker::PhantomData;
355 mod sealed {
356 pub trait Sealed {}
357 }
358 pub trait State: sealed::Sealed {
360 type B;
361 type G;
362 type R;
363 }
364 pub struct Empty(());
366 impl sealed::Sealed for Empty {}
367 impl State for Empty {
368 type B = Unset;
369 type G = Unset;
370 type R = Unset;
371 }
372 pub struct SetB<St: State = Empty>(PhantomData<fn() -> St>);
374 impl<St: State> sealed::Sealed for SetB<St> {}
375 impl<St: State> State for SetB<St> {
376 type B = Set<members::b>;
377 type G = St::G;
378 type R = St::R;
379 }
380 pub struct SetG<St: State = Empty>(PhantomData<fn() -> St>);
382 impl<St: State> sealed::Sealed for SetG<St> {}
383 impl<St: State> State for SetG<St> {
384 type B = St::B;
385 type G = Set<members::g>;
386 type R = St::R;
387 }
388 pub struct SetR<St: State = Empty>(PhantomData<fn() -> St>);
390 impl<St: State> sealed::Sealed for SetR<St> {}
391 impl<St: State> State for SetR<St> {
392 type B = St::B;
393 type G = St::G;
394 type R = Set<members::r>;
395 }
396 #[allow(non_camel_case_types)]
398 pub mod members {
399 pub struct b(());
401 pub struct g(());
403 pub struct r(());
405 }
406}
407
408pub struct ColorRgbBuilder<St: color_rgb_state::State, S: BosStr = DefaultStr> {
410 _state: PhantomData<fn() -> St>,
411 _fields: (Option<i64>, Option<i64>, Option<i64>),
412 _type: PhantomData<fn() -> S>,
413}
414
415impl ColorRgb<DefaultStr> {
416 pub fn new() -> ColorRgbBuilder<color_rgb_state::Empty, DefaultStr> {
418 ColorRgbBuilder::new()
419 }
420}
421
422impl<S: BosStr> ColorRgb<S> {
423 pub fn builder() -> ColorRgbBuilder<color_rgb_state::Empty, S> {
425 ColorRgbBuilder::builder()
426 }
427}
428
429impl ColorRgbBuilder<color_rgb_state::Empty, DefaultStr> {
430 pub fn new() -> Self {
432 ColorRgbBuilder {
433 _state: PhantomData,
434 _fields: (None, None, None),
435 _type: PhantomData,
436 }
437 }
438}
439
440impl<S: BosStr> ColorRgbBuilder<color_rgb_state::Empty, S> {
441 pub fn builder() -> Self {
443 ColorRgbBuilder {
444 _state: PhantomData,
445 _fields: (None, None, None),
446 _type: PhantomData,
447 }
448 }
449}
450
451impl<St, S: BosStr> ColorRgbBuilder<St, S>
452where
453 St: color_rgb_state::State,
454 St::B: color_rgb_state::IsUnset,
455{
456 pub fn b(
458 mut self,
459 value: impl Into<i64>,
460 ) -> ColorRgbBuilder<color_rgb_state::SetB<St>, S> {
461 self._fields.0 = Option::Some(value.into());
462 ColorRgbBuilder {
463 _state: PhantomData,
464 _fields: self._fields,
465 _type: PhantomData,
466 }
467 }
468}
469
470impl<St, S: BosStr> ColorRgbBuilder<St, S>
471where
472 St: color_rgb_state::State,
473 St::G: color_rgb_state::IsUnset,
474{
475 pub fn g(
477 mut self,
478 value: impl Into<i64>,
479 ) -> ColorRgbBuilder<color_rgb_state::SetG<St>, S> {
480 self._fields.1 = Option::Some(value.into());
481 ColorRgbBuilder {
482 _state: PhantomData,
483 _fields: self._fields,
484 _type: PhantomData,
485 }
486 }
487}
488
489impl<St, S: BosStr> ColorRgbBuilder<St, S>
490where
491 St: color_rgb_state::State,
492 St::R: color_rgb_state::IsUnset,
493{
494 pub fn r(
496 mut self,
497 value: impl Into<i64>,
498 ) -> ColorRgbBuilder<color_rgb_state::SetR<St>, S> {
499 self._fields.2 = Option::Some(value.into());
500 ColorRgbBuilder {
501 _state: PhantomData,
502 _fields: self._fields,
503 _type: PhantomData,
504 }
505 }
506}
507
508impl<St, S: BosStr> ColorRgbBuilder<St, S>
509where
510 St: color_rgb_state::State,
511 St::B: color_rgb_state::IsSet,
512 St::G: color_rgb_state::IsSet,
513 St::R: color_rgb_state::IsSet,
514{
515 pub fn build(self) -> ColorRgb<S> {
517 ColorRgb {
518 b: self._fields.0.unwrap(),
519 g: self._fields.1.unwrap(),
520 r: self._fields.2.unwrap(),
521 extra_data: Default::default(),
522 }
523 }
524 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ColorRgb<S> {
526 ColorRgb {
527 b: self._fields.0.unwrap(),
528 g: self._fields.1.unwrap(),
529 r: self._fields.2.unwrap(),
530 extra_data: Some(extra_data),
531 }
532 }
533}
534
535fn lexicon_doc_app_bsky_embed_external() -> LexiconDoc<'static> {
536 #[allow(unused_imports)]
537 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
538 use jacquard_lexicon::lexicon::*;
539 use alloc::collections::BTreeMap;
540 LexiconDoc {
541 lexicon: Lexicon::Lexicon1,
542 id: CowStr::new_static("app.bsky.embed.external"),
543 defs: {
544 let mut map = BTreeMap::new();
545 map.insert(
546 SmolStr::new_static("colorRGB"),
547 LexUserType::Object(LexObject {
548 description: Some(
549 CowStr::new_static(
550 "RGB color definition, inspired by site.standard.theme.color#rgb",
551 ),
552 ),
553 required: Some(
554 vec![
555 SmolStr::new_static("r"), SmolStr::new_static("g"),
556 SmolStr::new_static("b")
557 ],
558 ),
559 properties: {
560 #[allow(unused_mut)]
561 let mut map = BTreeMap::new();
562 map.insert(
563 SmolStr::new_static("b"),
564 LexObjectProperty::Integer(LexInteger {
565 minimum: Some(0i64),
566 maximum: Some(255i64),
567 ..Default::default()
568 }),
569 );
570 map.insert(
571 SmolStr::new_static("g"),
572 LexObjectProperty::Integer(LexInteger {
573 minimum: Some(0i64),
574 maximum: Some(255i64),
575 ..Default::default()
576 }),
577 );
578 map.insert(
579 SmolStr::new_static("r"),
580 LexObjectProperty::Integer(LexInteger {
581 minimum: Some(0i64),
582 maximum: Some(255i64),
583 ..Default::default()
584 }),
585 );
586 map
587 },
588 ..Default::default()
589 }),
590 );
591 map.insert(
592 SmolStr::new_static("external"),
593 LexUserType::Object(LexObject {
594 required: Some(
595 vec![
596 SmolStr::new_static("uri"), SmolStr::new_static("title"),
597 SmolStr::new_static("description")
598 ],
599 ),
600 properties: {
601 #[allow(unused_mut)]
602 let mut map = BTreeMap::new();
603 map.insert(
604 SmolStr::new_static("associatedRefs"),
605 LexObjectProperty::Array(LexArray {
606 description: Some(
607 CowStr::new_static(
608 "StrongRefs (uri+cid) of the Atmosphere records that backed this view.",
609 ),
610 ),
611 items: LexArrayItem::Ref(LexRef {
612 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
613 ..Default::default()
614 }),
615 ..Default::default()
616 }),
617 );
618 map.insert(
619 SmolStr::new_static("description"),
620 LexObjectProperty::String(LexString { ..Default::default() }),
621 );
622 map.insert(
623 SmolStr::new_static("thumb"),
624 LexObjectProperty::Blob(LexBlob { ..Default::default() }),
625 );
626 map.insert(
627 SmolStr::new_static("title"),
628 LexObjectProperty::String(LexString { ..Default::default() }),
629 );
630 map.insert(
631 SmolStr::new_static("uri"),
632 LexObjectProperty::String(LexString {
633 format: Some(LexStringFormat::Uri),
634 ..Default::default()
635 }),
636 );
637 map
638 },
639 ..Default::default()
640 }),
641 );
642 map.insert(
643 SmolStr::new_static("main"),
644 LexUserType::Object(LexObject {
645 description: Some(
646 CowStr::new_static(
647 "A representation of some externally linked content (eg, a URL and 'card'), embedded in a Bluesky record (eg, a post).",
648 ),
649 ),
650 required: Some(vec![SmolStr::new_static("external")]),
651 properties: {
652 #[allow(unused_mut)]
653 let mut map = BTreeMap::new();
654 map.insert(
655 SmolStr::new_static("external"),
656 LexObjectProperty::Ref(LexRef {
657 r#ref: CowStr::new_static("#external"),
658 ..Default::default()
659 }),
660 );
661 map
662 },
663 ..Default::default()
664 }),
665 );
666 map.insert(
667 SmolStr::new_static("view"),
668 LexUserType::Object(LexObject {
669 required: Some(vec![SmolStr::new_static("external")]),
670 properties: {
671 #[allow(unused_mut)]
672 let mut map = BTreeMap::new();
673 map.insert(
674 SmolStr::new_static("external"),
675 LexObjectProperty::Ref(LexRef {
676 r#ref: CowStr::new_static("#viewExternal"),
677 ..Default::default()
678 }),
679 );
680 map
681 },
682 ..Default::default()
683 }),
684 );
685 map.insert(
686 SmolStr::new_static("viewExternal"),
687 LexUserType::Object(LexObject {
688 required: Some(
689 vec![
690 SmolStr::new_static("uri"), SmolStr::new_static("title"),
691 SmolStr::new_static("description")
692 ],
693 ),
694 properties: {
695 #[allow(unused_mut)]
696 let mut map = BTreeMap::new();
697 map.insert(
698 SmolStr::new_static("associatedProfiles"),
699 LexObjectProperty::Array(LexArray {
700 description: Some(
701 CowStr::new_static(
702 "Profiles of the owners of the Atmosphere records that backed this view.",
703 ),
704 ),
705 items: LexArrayItem::Ref(LexRef {
706 r#ref: CowStr::new_static(
707 "app.bsky.actor.defs#profileViewBasic",
708 ),
709 ..Default::default()
710 }),
711 ..Default::default()
712 }),
713 );
714 map.insert(
715 SmolStr::new_static("associatedRefs"),
716 LexObjectProperty::Array(LexArray {
717 description: Some(
718 CowStr::new_static(
719 "StrongRefs (uri+cid) of the Atmosphere records that backed this view.",
720 ),
721 ),
722 items: LexArrayItem::Ref(LexRef {
723 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
724 ..Default::default()
725 }),
726 ..Default::default()
727 }),
728 );
729 map.insert(
730 SmolStr::new_static("createdAt"),
731 LexObjectProperty::String(LexString {
732 description: Some(
733 CowStr::new_static(
734 "When the external content was created, if available. Example: a publication date, for an article.",
735 ),
736 ),
737 format: Some(LexStringFormat::Datetime),
738 ..Default::default()
739 }),
740 );
741 map.insert(
742 SmolStr::new_static("description"),
743 LexObjectProperty::String(LexString { ..Default::default() }),
744 );
745 map.insert(
746 SmolStr::new_static("labels"),
747 LexObjectProperty::Array(LexArray {
748 items: LexArrayItem::Ref(LexRef {
749 r#ref: CowStr::new_static("com.atproto.label.defs#label"),
750 ..Default::default()
751 }),
752 ..Default::default()
753 }),
754 );
755 map.insert(
756 SmolStr::new_static("readingTime"),
757 LexObjectProperty::Integer(LexInteger {
758 ..Default::default()
759 }),
760 );
761 map.insert(
762 SmolStr::new_static("source"),
763 LexObjectProperty::Ref(LexRef {
764 r#ref: CowStr::new_static("#viewExternalSource"),
765 ..Default::default()
766 }),
767 );
768 map.insert(
769 SmolStr::new_static("thumb"),
770 LexObjectProperty::String(LexString {
771 format: Some(LexStringFormat::Uri),
772 ..Default::default()
773 }),
774 );
775 map.insert(
776 SmolStr::new_static("title"),
777 LexObjectProperty::String(LexString { ..Default::default() }),
778 );
779 map.insert(
780 SmolStr::new_static("updatedAt"),
781 LexObjectProperty::String(LexString {
782 description: Some(
783 CowStr::new_static(
784 "When the external content was updated, if available.",
785 ),
786 ),
787 format: Some(LexStringFormat::Datetime),
788 ..Default::default()
789 }),
790 );
791 map.insert(
792 SmolStr::new_static("uri"),
793 LexObjectProperty::String(LexString {
794 format: Some(LexStringFormat::Uri),
795 ..Default::default()
796 }),
797 );
798 map
799 },
800 ..Default::default()
801 }),
802 );
803 map.insert(
804 SmolStr::new_static("viewExternalSource"),
805 LexUserType::Object(LexObject {
806 description: Some(
807 CowStr::new_static(
808 "The source of an external embed, such as a standard.site publication.",
809 ),
810 ),
811 required: Some(
812 vec![SmolStr::new_static("uri"), SmolStr::new_static("title")],
813 ),
814 properties: {
815 #[allow(unused_mut)]
816 let mut map = BTreeMap::new();
817 map.insert(
818 SmolStr::new_static("description"),
819 LexObjectProperty::String(LexString { ..Default::default() }),
820 );
821 map.insert(
822 SmolStr::new_static("icon"),
823 LexObjectProperty::String(LexString {
824 description: Some(
825 CowStr::new_static(
826 "Fully-qualified URL where an icon representing the source can be fetched. For example, CDN location provided by the App View.",
827 ),
828 ),
829 format: Some(LexStringFormat::Uri),
830 ..Default::default()
831 }),
832 );
833 map.insert(
834 SmolStr::new_static("theme"),
835 LexObjectProperty::Ref(LexRef {
836 r#ref: CowStr::new_static("#viewExternalSourceTheme"),
837 ..Default::default()
838 }),
839 );
840 map.insert(
841 SmolStr::new_static("title"),
842 LexObjectProperty::String(LexString { ..Default::default() }),
843 );
844 map.insert(
845 SmolStr::new_static("uri"),
846 LexObjectProperty::String(LexString {
847 description: Some(
848 CowStr::new_static(
849 "URI of the source, if available. Example: the https:// URL of a site.standard.publication record.",
850 ),
851 ),
852 format: Some(LexStringFormat::Uri),
853 ..Default::default()
854 }),
855 );
856 map
857 },
858 ..Default::default()
859 }),
860 );
861 map.insert(
862 SmolStr::new_static("viewExternalSourceTheme"),
863 LexUserType::Object(LexObject {
864 description: Some(
865 CowStr::new_static(
866 "The theme colors of an external source, such as a site.standard.publication. These colors may be used when rendering an embed from that source.",
867 ),
868 ),
869 properties: {
870 #[allow(unused_mut)]
871 let mut map = BTreeMap::new();
872 map.insert(
873 SmolStr::new_static("accentForegroundRGB"),
874 LexObjectProperty::Ref(LexRef {
875 r#ref: CowStr::new_static("#colorRGB"),
876 ..Default::default()
877 }),
878 );
879 map.insert(
880 SmolStr::new_static("accentRGB"),
881 LexObjectProperty::Ref(LexRef {
882 r#ref: CowStr::new_static("#colorRGB"),
883 ..Default::default()
884 }),
885 );
886 map.insert(
887 SmolStr::new_static("backgroundRGB"),
888 LexObjectProperty::Ref(LexRef {
889 r#ref: CowStr::new_static("#colorRGB"),
890 ..Default::default()
891 }),
892 );
893 map.insert(
894 SmolStr::new_static("foregroundRGB"),
895 LexObjectProperty::Ref(LexRef {
896 r#ref: CowStr::new_static("#colorRGB"),
897 ..Default::default()
898 }),
899 );
900 map
901 },
902 ..Default::default()
903 }),
904 );
905 map
906 },
907 ..Default::default()
908 }
909}
910
911pub mod external_state {
912
913 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
914 #[allow(unused)]
915 use ::core::marker::PhantomData;
916 mod sealed {
917 pub trait Sealed {}
918 }
919 pub trait State: sealed::Sealed {
921 type Description;
922 type Title;
923 type Uri;
924 }
925 pub struct Empty(());
927 impl sealed::Sealed for Empty {}
928 impl State for Empty {
929 type Description = Unset;
930 type Title = Unset;
931 type Uri = Unset;
932 }
933 pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>);
935 impl<St: State> sealed::Sealed for SetDescription<St> {}
936 impl<St: State> State for SetDescription<St> {
937 type Description = Set<members::description>;
938 type Title = St::Title;
939 type Uri = St::Uri;
940 }
941 pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
943 impl<St: State> sealed::Sealed for SetTitle<St> {}
944 impl<St: State> State for SetTitle<St> {
945 type Description = St::Description;
946 type Title = Set<members::title>;
947 type Uri = St::Uri;
948 }
949 pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
951 impl<St: State> sealed::Sealed for SetUri<St> {}
952 impl<St: State> State for SetUri<St> {
953 type Description = St::Description;
954 type Title = St::Title;
955 type Uri = Set<members::uri>;
956 }
957 #[allow(non_camel_case_types)]
959 pub mod members {
960 pub struct description(());
962 pub struct title(());
964 pub struct uri(());
966 }
967}
968
969pub struct ExternalBuilder<St: external_state::State, S: BosStr = DefaultStr> {
971 _state: PhantomData<fn() -> St>,
972 _fields: (
973 Option<Vec<StrongRef<S>>>,
974 Option<S>,
975 Option<BlobRef<S>>,
976 Option<S>,
977 Option<UriValue<S>>,
978 ),
979 _type: PhantomData<fn() -> S>,
980}
981
982impl External<DefaultStr> {
983 pub fn new() -> ExternalBuilder<external_state::Empty, DefaultStr> {
985 ExternalBuilder::new()
986 }
987}
988
989impl<S: BosStr> External<S> {
990 pub fn builder() -> ExternalBuilder<external_state::Empty, S> {
992 ExternalBuilder::builder()
993 }
994}
995
996impl ExternalBuilder<external_state::Empty, DefaultStr> {
997 pub fn new() -> Self {
999 ExternalBuilder {
1000 _state: PhantomData,
1001 _fields: (None, None, None, None, None),
1002 _type: PhantomData,
1003 }
1004 }
1005}
1006
1007impl<S: BosStr> ExternalBuilder<external_state::Empty, S> {
1008 pub fn builder() -> Self {
1010 ExternalBuilder {
1011 _state: PhantomData,
1012 _fields: (None, None, None, None, None),
1013 _type: PhantomData,
1014 }
1015 }
1016}
1017
1018impl<St: external_state::State, S: BosStr> ExternalBuilder<St, S> {
1019 pub fn associated_refs(
1021 mut self,
1022 value: impl Into<Option<Vec<StrongRef<S>>>>,
1023 ) -> Self {
1024 self._fields.0 = value.into();
1025 self
1026 }
1027 pub fn maybe_associated_refs(mut self, value: Option<Vec<StrongRef<S>>>) -> Self {
1029 self._fields.0 = value;
1030 self
1031 }
1032}
1033
1034impl<St, S: BosStr> ExternalBuilder<St, S>
1035where
1036 St: external_state::State,
1037 St::Description: external_state::IsUnset,
1038{
1039 pub fn description(
1041 mut self,
1042 value: impl Into<S>,
1043 ) -> ExternalBuilder<external_state::SetDescription<St>, S> {
1044 self._fields.1 = Option::Some(value.into());
1045 ExternalBuilder {
1046 _state: PhantomData,
1047 _fields: self._fields,
1048 _type: PhantomData,
1049 }
1050 }
1051}
1052
1053impl<St: external_state::State, S: BosStr> ExternalBuilder<St, S> {
1054 pub fn thumb(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
1056 self._fields.2 = value.into();
1057 self
1058 }
1059 pub fn maybe_thumb(mut self, value: Option<BlobRef<S>>) -> Self {
1061 self._fields.2 = value;
1062 self
1063 }
1064}
1065
1066impl<St, S: BosStr> ExternalBuilder<St, S>
1067where
1068 St: external_state::State,
1069 St::Title: external_state::IsUnset,
1070{
1071 pub fn title(
1073 mut self,
1074 value: impl Into<S>,
1075 ) -> ExternalBuilder<external_state::SetTitle<St>, S> {
1076 self._fields.3 = Option::Some(value.into());
1077 ExternalBuilder {
1078 _state: PhantomData,
1079 _fields: self._fields,
1080 _type: PhantomData,
1081 }
1082 }
1083}
1084
1085impl<St, S: BosStr> ExternalBuilder<St, S>
1086where
1087 St: external_state::State,
1088 St::Uri: external_state::IsUnset,
1089{
1090 pub fn uri(
1092 mut self,
1093 value: impl Into<UriValue<S>>,
1094 ) -> ExternalBuilder<external_state::SetUri<St>, S> {
1095 self._fields.4 = Option::Some(value.into());
1096 ExternalBuilder {
1097 _state: PhantomData,
1098 _fields: self._fields,
1099 _type: PhantomData,
1100 }
1101 }
1102}
1103
1104impl<St, S: BosStr> ExternalBuilder<St, S>
1105where
1106 St: external_state::State,
1107 St::Description: external_state::IsSet,
1108 St::Title: external_state::IsSet,
1109 St::Uri: external_state::IsSet,
1110{
1111 pub fn build(self) -> External<S> {
1113 External {
1114 associated_refs: self._fields.0,
1115 description: self._fields.1.unwrap(),
1116 thumb: self._fields.2,
1117 title: self._fields.3.unwrap(),
1118 uri: self._fields.4.unwrap(),
1119 extra_data: Default::default(),
1120 }
1121 }
1122 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> External<S> {
1124 External {
1125 associated_refs: self._fields.0,
1126 description: self._fields.1.unwrap(),
1127 thumb: self._fields.2,
1128 title: self._fields.3.unwrap(),
1129 uri: self._fields.4.unwrap(),
1130 extra_data: Some(extra_data),
1131 }
1132 }
1133}
1134
1135pub mod external_record_state {
1136
1137 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1138 #[allow(unused)]
1139 use ::core::marker::PhantomData;
1140 mod sealed {
1141 pub trait Sealed {}
1142 }
1143 pub trait State: sealed::Sealed {
1145 type External;
1146 }
1147 pub struct Empty(());
1149 impl sealed::Sealed for Empty {}
1150 impl State for Empty {
1151 type External = Unset;
1152 }
1153 pub struct SetExternal<St: State = Empty>(PhantomData<fn() -> St>);
1155 impl<St: State> sealed::Sealed for SetExternal<St> {}
1156 impl<St: State> State for SetExternal<St> {
1157 type External = Set<members::external>;
1158 }
1159 #[allow(non_camel_case_types)]
1161 pub mod members {
1162 pub struct external(());
1164 }
1165}
1166
1167pub struct ExternalRecordBuilder<
1169 St: external_record_state::State,
1170 S: BosStr = DefaultStr,
1171> {
1172 _state: PhantomData<fn() -> St>,
1173 _fields: (Option<external::External<S>>,),
1174 _type: PhantomData<fn() -> S>,
1175}
1176
1177impl ExternalRecord<DefaultStr> {
1178 pub fn new() -> ExternalRecordBuilder<external_record_state::Empty, DefaultStr> {
1180 ExternalRecordBuilder::new()
1181 }
1182}
1183
1184impl<S: BosStr> ExternalRecord<S> {
1185 pub fn builder() -> ExternalRecordBuilder<external_record_state::Empty, S> {
1187 ExternalRecordBuilder::builder()
1188 }
1189}
1190
1191impl ExternalRecordBuilder<external_record_state::Empty, DefaultStr> {
1192 pub fn new() -> Self {
1194 ExternalRecordBuilder {
1195 _state: PhantomData,
1196 _fields: (None,),
1197 _type: PhantomData,
1198 }
1199 }
1200}
1201
1202impl<S: BosStr> ExternalRecordBuilder<external_record_state::Empty, S> {
1203 pub fn builder() -> Self {
1205 ExternalRecordBuilder {
1206 _state: PhantomData,
1207 _fields: (None,),
1208 _type: PhantomData,
1209 }
1210 }
1211}
1212
1213impl<St, S: BosStr> ExternalRecordBuilder<St, S>
1214where
1215 St: external_record_state::State,
1216 St::External: external_record_state::IsUnset,
1217{
1218 pub fn external(
1220 mut self,
1221 value: impl Into<external::External<S>>,
1222 ) -> ExternalRecordBuilder<external_record_state::SetExternal<St>, S> {
1223 self._fields.0 = Option::Some(value.into());
1224 ExternalRecordBuilder {
1225 _state: PhantomData,
1226 _fields: self._fields,
1227 _type: PhantomData,
1228 }
1229 }
1230}
1231
1232impl<St, S: BosStr> ExternalRecordBuilder<St, S>
1233where
1234 St: external_record_state::State,
1235 St::External: external_record_state::IsSet,
1236{
1237 pub fn build(self) -> ExternalRecord<S> {
1239 ExternalRecord {
1240 external: self._fields.0.unwrap(),
1241 extra_data: Default::default(),
1242 }
1243 }
1244 pub fn build_with_data(
1246 self,
1247 extra_data: BTreeMap<SmolStr, Data<S>>,
1248 ) -> ExternalRecord<S> {
1249 ExternalRecord {
1250 external: self._fields.0.unwrap(),
1251 extra_data: Some(extra_data),
1252 }
1253 }
1254}
1255
1256pub mod view_state {
1257
1258 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1259 #[allow(unused)]
1260 use ::core::marker::PhantomData;
1261 mod sealed {
1262 pub trait Sealed {}
1263 }
1264 pub trait State: sealed::Sealed {
1266 type External;
1267 }
1268 pub struct Empty(());
1270 impl sealed::Sealed for Empty {}
1271 impl State for Empty {
1272 type External = Unset;
1273 }
1274 pub struct SetExternal<St: State = Empty>(PhantomData<fn() -> St>);
1276 impl<St: State> sealed::Sealed for SetExternal<St> {}
1277 impl<St: State> State for SetExternal<St> {
1278 type External = Set<members::external>;
1279 }
1280 #[allow(non_camel_case_types)]
1282 pub mod members {
1283 pub struct external(());
1285 }
1286}
1287
1288pub struct ViewBuilder<St: view_state::State, S: BosStr = DefaultStr> {
1290 _state: PhantomData<fn() -> St>,
1291 _fields: (Option<external::ViewExternal<S>>,),
1292 _type: PhantomData<fn() -> S>,
1293}
1294
1295impl View<DefaultStr> {
1296 pub fn new() -> ViewBuilder<view_state::Empty, DefaultStr> {
1298 ViewBuilder::new()
1299 }
1300}
1301
1302impl<S: BosStr> View<S> {
1303 pub fn builder() -> ViewBuilder<view_state::Empty, S> {
1305 ViewBuilder::builder()
1306 }
1307}
1308
1309impl ViewBuilder<view_state::Empty, DefaultStr> {
1310 pub fn new() -> Self {
1312 ViewBuilder {
1313 _state: PhantomData,
1314 _fields: (None,),
1315 _type: PhantomData,
1316 }
1317 }
1318}
1319
1320impl<S: BosStr> ViewBuilder<view_state::Empty, S> {
1321 pub fn builder() -> Self {
1323 ViewBuilder {
1324 _state: PhantomData,
1325 _fields: (None,),
1326 _type: PhantomData,
1327 }
1328 }
1329}
1330
1331impl<St, S: BosStr> ViewBuilder<St, S>
1332where
1333 St: view_state::State,
1334 St::External: view_state::IsUnset,
1335{
1336 pub fn external(
1338 mut self,
1339 value: impl Into<external::ViewExternal<S>>,
1340 ) -> ViewBuilder<view_state::SetExternal<St>, S> {
1341 self._fields.0 = Option::Some(value.into());
1342 ViewBuilder {
1343 _state: PhantomData,
1344 _fields: self._fields,
1345 _type: PhantomData,
1346 }
1347 }
1348}
1349
1350impl<St, S: BosStr> ViewBuilder<St, S>
1351where
1352 St: view_state::State,
1353 St::External: view_state::IsSet,
1354{
1355 pub fn build(self) -> View<S> {
1357 View {
1358 external: self._fields.0.unwrap(),
1359 extra_data: Default::default(),
1360 }
1361 }
1362 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> View<S> {
1364 View {
1365 external: self._fields.0.unwrap(),
1366 extra_data: Some(extra_data),
1367 }
1368 }
1369}
1370
1371pub mod view_external_state {
1372
1373 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1374 #[allow(unused)]
1375 use ::core::marker::PhantomData;
1376 mod sealed {
1377 pub trait Sealed {}
1378 }
1379 pub trait State: sealed::Sealed {
1381 type Description;
1382 type Title;
1383 type Uri;
1384 }
1385 pub struct Empty(());
1387 impl sealed::Sealed for Empty {}
1388 impl State for Empty {
1389 type Description = Unset;
1390 type Title = Unset;
1391 type Uri = Unset;
1392 }
1393 pub struct SetDescription<St: State = Empty>(PhantomData<fn() -> St>);
1395 impl<St: State> sealed::Sealed for SetDescription<St> {}
1396 impl<St: State> State for SetDescription<St> {
1397 type Description = Set<members::description>;
1398 type Title = St::Title;
1399 type Uri = St::Uri;
1400 }
1401 pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
1403 impl<St: State> sealed::Sealed for SetTitle<St> {}
1404 impl<St: State> State for SetTitle<St> {
1405 type Description = St::Description;
1406 type Title = Set<members::title>;
1407 type Uri = St::Uri;
1408 }
1409 pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
1411 impl<St: State> sealed::Sealed for SetUri<St> {}
1412 impl<St: State> State for SetUri<St> {
1413 type Description = St::Description;
1414 type Title = St::Title;
1415 type Uri = Set<members::uri>;
1416 }
1417 #[allow(non_camel_case_types)]
1419 pub mod members {
1420 pub struct description(());
1422 pub struct title(());
1424 pub struct uri(());
1426 }
1427}
1428
1429pub struct ViewExternalBuilder<St: view_external_state::State, S: BosStr = DefaultStr> {
1431 _state: PhantomData<fn() -> St>,
1432 _fields: (
1433 Option<Vec<ProfileViewBasic<S>>>,
1434 Option<Vec<StrongRef<S>>>,
1435 Option<Datetime>,
1436 Option<S>,
1437 Option<Vec<Label<S>>>,
1438 Option<i64>,
1439 Option<external::ViewExternalSource<S>>,
1440 Option<UriValue<S>>,
1441 Option<S>,
1442 Option<Datetime>,
1443 Option<UriValue<S>>,
1444 ),
1445 _type: PhantomData<fn() -> S>,
1446}
1447
1448impl ViewExternal<DefaultStr> {
1449 pub fn new() -> ViewExternalBuilder<view_external_state::Empty, DefaultStr> {
1451 ViewExternalBuilder::new()
1452 }
1453}
1454
1455impl<S: BosStr> ViewExternal<S> {
1456 pub fn builder() -> ViewExternalBuilder<view_external_state::Empty, S> {
1458 ViewExternalBuilder::builder()
1459 }
1460}
1461
1462impl ViewExternalBuilder<view_external_state::Empty, DefaultStr> {
1463 pub fn new() -> Self {
1465 ViewExternalBuilder {
1466 _state: PhantomData,
1467 _fields: (None, None, None, None, None, None, None, None, None, None, None),
1468 _type: PhantomData,
1469 }
1470 }
1471}
1472
1473impl<S: BosStr> ViewExternalBuilder<view_external_state::Empty, S> {
1474 pub fn builder() -> Self {
1476 ViewExternalBuilder {
1477 _state: PhantomData,
1478 _fields: (None, None, None, None, None, None, None, None, None, None, None),
1479 _type: PhantomData,
1480 }
1481 }
1482}
1483
1484impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1485 pub fn associated_profiles(
1487 mut self,
1488 value: impl Into<Option<Vec<ProfileViewBasic<S>>>>,
1489 ) -> Self {
1490 self._fields.0 = value.into();
1491 self
1492 }
1493 pub fn maybe_associated_profiles(
1495 mut self,
1496 value: Option<Vec<ProfileViewBasic<S>>>,
1497 ) -> Self {
1498 self._fields.0 = value;
1499 self
1500 }
1501}
1502
1503impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1504 pub fn associated_refs(
1506 mut self,
1507 value: impl Into<Option<Vec<StrongRef<S>>>>,
1508 ) -> Self {
1509 self._fields.1 = value.into();
1510 self
1511 }
1512 pub fn maybe_associated_refs(mut self, value: Option<Vec<StrongRef<S>>>) -> Self {
1514 self._fields.1 = value;
1515 self
1516 }
1517}
1518
1519impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1520 pub fn created_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
1522 self._fields.2 = value.into();
1523 self
1524 }
1525 pub fn maybe_created_at(mut self, value: Option<Datetime>) -> Self {
1527 self._fields.2 = value;
1528 self
1529 }
1530}
1531
1532impl<St, S: BosStr> ViewExternalBuilder<St, S>
1533where
1534 St: view_external_state::State,
1535 St::Description: view_external_state::IsUnset,
1536{
1537 pub fn description(
1539 mut self,
1540 value: impl Into<S>,
1541 ) -> ViewExternalBuilder<view_external_state::SetDescription<St>, S> {
1542 self._fields.3 = Option::Some(value.into());
1543 ViewExternalBuilder {
1544 _state: PhantomData,
1545 _fields: self._fields,
1546 _type: PhantomData,
1547 }
1548 }
1549}
1550
1551impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1552 pub fn labels(mut self, value: impl Into<Option<Vec<Label<S>>>>) -> Self {
1554 self._fields.4 = value.into();
1555 self
1556 }
1557 pub fn maybe_labels(mut self, value: Option<Vec<Label<S>>>) -> Self {
1559 self._fields.4 = value;
1560 self
1561 }
1562}
1563
1564impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1565 pub fn reading_time(mut self, value: impl Into<Option<i64>>) -> Self {
1567 self._fields.5 = value.into();
1568 self
1569 }
1570 pub fn maybe_reading_time(mut self, value: Option<i64>) -> Self {
1572 self._fields.5 = value;
1573 self
1574 }
1575}
1576
1577impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1578 pub fn source(
1580 mut self,
1581 value: impl Into<Option<external::ViewExternalSource<S>>>,
1582 ) -> Self {
1583 self._fields.6 = value.into();
1584 self
1585 }
1586 pub fn maybe_source(
1588 mut self,
1589 value: Option<external::ViewExternalSource<S>>,
1590 ) -> Self {
1591 self._fields.6 = value;
1592 self
1593 }
1594}
1595
1596impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1597 pub fn thumb(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
1599 self._fields.7 = value.into();
1600 self
1601 }
1602 pub fn maybe_thumb(mut self, value: Option<UriValue<S>>) -> Self {
1604 self._fields.7 = value;
1605 self
1606 }
1607}
1608
1609impl<St, S: BosStr> ViewExternalBuilder<St, S>
1610where
1611 St: view_external_state::State,
1612 St::Title: view_external_state::IsUnset,
1613{
1614 pub fn title(
1616 mut self,
1617 value: impl Into<S>,
1618 ) -> ViewExternalBuilder<view_external_state::SetTitle<St>, S> {
1619 self._fields.8 = Option::Some(value.into());
1620 ViewExternalBuilder {
1621 _state: PhantomData,
1622 _fields: self._fields,
1623 _type: PhantomData,
1624 }
1625 }
1626}
1627
1628impl<St: view_external_state::State, S: BosStr> ViewExternalBuilder<St, S> {
1629 pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
1631 self._fields.9 = value.into();
1632 self
1633 }
1634 pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
1636 self._fields.9 = value;
1637 self
1638 }
1639}
1640
1641impl<St, S: BosStr> ViewExternalBuilder<St, S>
1642where
1643 St: view_external_state::State,
1644 St::Uri: view_external_state::IsUnset,
1645{
1646 pub fn uri(
1648 mut self,
1649 value: impl Into<UriValue<S>>,
1650 ) -> ViewExternalBuilder<view_external_state::SetUri<St>, S> {
1651 self._fields.10 = Option::Some(value.into());
1652 ViewExternalBuilder {
1653 _state: PhantomData,
1654 _fields: self._fields,
1655 _type: PhantomData,
1656 }
1657 }
1658}
1659
1660impl<St, S: BosStr> ViewExternalBuilder<St, S>
1661where
1662 St: view_external_state::State,
1663 St::Description: view_external_state::IsSet,
1664 St::Title: view_external_state::IsSet,
1665 St::Uri: view_external_state::IsSet,
1666{
1667 pub fn build(self) -> ViewExternal<S> {
1669 ViewExternal {
1670 associated_profiles: self._fields.0,
1671 associated_refs: self._fields.1,
1672 created_at: self._fields.2,
1673 description: self._fields.3.unwrap(),
1674 labels: self._fields.4,
1675 reading_time: self._fields.5,
1676 source: self._fields.6,
1677 thumb: self._fields.7,
1678 title: self._fields.8.unwrap(),
1679 updated_at: self._fields.9,
1680 uri: self._fields.10.unwrap(),
1681 extra_data: Default::default(),
1682 }
1683 }
1684 pub fn build_with_data(
1686 self,
1687 extra_data: BTreeMap<SmolStr, Data<S>>,
1688 ) -> ViewExternal<S> {
1689 ViewExternal {
1690 associated_profiles: self._fields.0,
1691 associated_refs: self._fields.1,
1692 created_at: self._fields.2,
1693 description: self._fields.3.unwrap(),
1694 labels: self._fields.4,
1695 reading_time: self._fields.5,
1696 source: self._fields.6,
1697 thumb: self._fields.7,
1698 title: self._fields.8.unwrap(),
1699 updated_at: self._fields.9,
1700 uri: self._fields.10.unwrap(),
1701 extra_data: Some(extra_data),
1702 }
1703 }
1704}
1705
1706pub mod view_external_source_state {
1707
1708 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1709 #[allow(unused)]
1710 use ::core::marker::PhantomData;
1711 mod sealed {
1712 pub trait Sealed {}
1713 }
1714 pub trait State: sealed::Sealed {
1716 type Title;
1717 type Uri;
1718 }
1719 pub struct Empty(());
1721 impl sealed::Sealed for Empty {}
1722 impl State for Empty {
1723 type Title = Unset;
1724 type Uri = Unset;
1725 }
1726 pub struct SetTitle<St: State = Empty>(PhantomData<fn() -> St>);
1728 impl<St: State> sealed::Sealed for SetTitle<St> {}
1729 impl<St: State> State for SetTitle<St> {
1730 type Title = Set<members::title>;
1731 type Uri = St::Uri;
1732 }
1733 pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
1735 impl<St: State> sealed::Sealed for SetUri<St> {}
1736 impl<St: State> State for SetUri<St> {
1737 type Title = St::Title;
1738 type Uri = Set<members::uri>;
1739 }
1740 #[allow(non_camel_case_types)]
1742 pub mod members {
1743 pub struct title(());
1745 pub struct uri(());
1747 }
1748}
1749
1750pub struct ViewExternalSourceBuilder<
1752 St: view_external_source_state::State,
1753 S: BosStr = DefaultStr,
1754> {
1755 _state: PhantomData<fn() -> St>,
1756 _fields: (
1757 Option<S>,
1758 Option<UriValue<S>>,
1759 Option<external::ViewExternalSourceTheme<S>>,
1760 Option<S>,
1761 Option<UriValue<S>>,
1762 ),
1763 _type: PhantomData<fn() -> S>,
1764}
1765
1766impl ViewExternalSource<DefaultStr> {
1767 pub fn new() -> ViewExternalSourceBuilder<
1769 view_external_source_state::Empty,
1770 DefaultStr,
1771 > {
1772 ViewExternalSourceBuilder::new()
1773 }
1774}
1775
1776impl<S: BosStr> ViewExternalSource<S> {
1777 pub fn builder() -> ViewExternalSourceBuilder<view_external_source_state::Empty, S> {
1779 ViewExternalSourceBuilder::builder()
1780 }
1781}
1782
1783impl ViewExternalSourceBuilder<view_external_source_state::Empty, DefaultStr> {
1784 pub fn new() -> Self {
1786 ViewExternalSourceBuilder {
1787 _state: PhantomData,
1788 _fields: (None, None, None, None, None),
1789 _type: PhantomData,
1790 }
1791 }
1792}
1793
1794impl<S: BosStr> ViewExternalSourceBuilder<view_external_source_state::Empty, S> {
1795 pub fn builder() -> Self {
1797 ViewExternalSourceBuilder {
1798 _state: PhantomData,
1799 _fields: (None, None, None, None, None),
1800 _type: PhantomData,
1801 }
1802 }
1803}
1804
1805impl<St: view_external_source_state::State, S: BosStr> ViewExternalSourceBuilder<St, S> {
1806 pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
1808 self._fields.0 = value.into();
1809 self
1810 }
1811 pub fn maybe_description(mut self, value: Option<S>) -> Self {
1813 self._fields.0 = value;
1814 self
1815 }
1816}
1817
1818impl<St: view_external_source_state::State, S: BosStr> ViewExternalSourceBuilder<St, S> {
1819 pub fn icon(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
1821 self._fields.1 = value.into();
1822 self
1823 }
1824 pub fn maybe_icon(mut self, value: Option<UriValue<S>>) -> Self {
1826 self._fields.1 = value;
1827 self
1828 }
1829}
1830
1831impl<St: view_external_source_state::State, S: BosStr> ViewExternalSourceBuilder<St, S> {
1832 pub fn theme(
1834 mut self,
1835 value: impl Into<Option<external::ViewExternalSourceTheme<S>>>,
1836 ) -> Self {
1837 self._fields.2 = value.into();
1838 self
1839 }
1840 pub fn maybe_theme(
1842 mut self,
1843 value: Option<external::ViewExternalSourceTheme<S>>,
1844 ) -> Self {
1845 self._fields.2 = value;
1846 self
1847 }
1848}
1849
1850impl<St, S: BosStr> ViewExternalSourceBuilder<St, S>
1851where
1852 St: view_external_source_state::State,
1853 St::Title: view_external_source_state::IsUnset,
1854{
1855 pub fn title(
1857 mut self,
1858 value: impl Into<S>,
1859 ) -> ViewExternalSourceBuilder<view_external_source_state::SetTitle<St>, S> {
1860 self._fields.3 = Option::Some(value.into());
1861 ViewExternalSourceBuilder {
1862 _state: PhantomData,
1863 _fields: self._fields,
1864 _type: PhantomData,
1865 }
1866 }
1867}
1868
1869impl<St, S: BosStr> ViewExternalSourceBuilder<St, S>
1870where
1871 St: view_external_source_state::State,
1872 St::Uri: view_external_source_state::IsUnset,
1873{
1874 pub fn uri(
1876 mut self,
1877 value: impl Into<UriValue<S>>,
1878 ) -> ViewExternalSourceBuilder<view_external_source_state::SetUri<St>, S> {
1879 self._fields.4 = Option::Some(value.into());
1880 ViewExternalSourceBuilder {
1881 _state: PhantomData,
1882 _fields: self._fields,
1883 _type: PhantomData,
1884 }
1885 }
1886}
1887
1888impl<St, S: BosStr> ViewExternalSourceBuilder<St, S>
1889where
1890 St: view_external_source_state::State,
1891 St::Title: view_external_source_state::IsSet,
1892 St::Uri: view_external_source_state::IsSet,
1893{
1894 pub fn build(self) -> ViewExternalSource<S> {
1896 ViewExternalSource {
1897 description: self._fields.0,
1898 icon: self._fields.1,
1899 theme: self._fields.2,
1900 title: self._fields.3.unwrap(),
1901 uri: self._fields.4.unwrap(),
1902 extra_data: Default::default(),
1903 }
1904 }
1905 pub fn build_with_data(
1907 self,
1908 extra_data: BTreeMap<SmolStr, Data<S>>,
1909 ) -> ViewExternalSource<S> {
1910 ViewExternalSource {
1911 description: self._fields.0,
1912 icon: self._fields.1,
1913 theme: self._fields.2,
1914 title: self._fields.3.unwrap(),
1915 uri: self._fields.4.unwrap(),
1916 extra_data: Some(extra_data),
1917 }
1918 }
1919}