Skip to main content

jacquard_api/pub_leaflet/
publication.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: pub.leaflet.publication
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::collection::{Collection, RecordError};
19use jacquard_common::types::string::{AtUri, Cid};
20use jacquard_common::types::uri::{RecordUri, UriError};
21use jacquard_common::xrpc::XrpcResp;
22use jacquard_derive::{IntoStatic, lexicon, open_union};
23use jacquard_lexicon::lexicon::LexiconDoc;
24use jacquard_lexicon::schema::LexiconSchema;
25
26#[allow(unused_imports)]
27use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
28use serde::{Serialize, Deserialize};
29use crate::pub_leaflet::theme::background_image::BackgroundImage;
30use crate::pub_leaflet::theme::color::Rgb;
31use crate::pub_leaflet::theme::color::Rgba;
32use crate::pub_leaflet::publication;
33/// Record declaring a publication
34
35#[lexicon]
36#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
37#[serde(rename_all = "camelCase", rename = "pub.leaflet.publication", tag = "$type")]
38pub struct Publication<'a> {
39    #[serde(skip_serializing_if = "Option::is_none")]
40    #[serde(borrow)]
41    pub base_path: Option<CowStr<'a>>,
42    #[serde(skip_serializing_if = "Option::is_none")]
43    #[serde(borrow)]
44    pub description: Option<CowStr<'a>>,
45    #[serde(skip_serializing_if = "Option::is_none")]
46    #[serde(borrow)]
47    pub icon: Option<BlobRef<'a>>,
48    #[serde(borrow)]
49    pub name: CowStr<'a>,
50    #[serde(skip_serializing_if = "Option::is_none")]
51    #[serde(borrow)]
52    pub preferences: Option<publication::Preferences<'a>>,
53    #[serde(skip_serializing_if = "Option::is_none")]
54    #[serde(borrow)]
55    pub theme: Option<publication::Theme<'a>>,
56}
57
58/// Typed wrapper for GetRecord response with this collection's record type.
59
60#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
61#[serde(rename_all = "camelCase")]
62pub struct PublicationGetRecordOutput<'a> {
63    #[serde(skip_serializing_if = "Option::is_none")]
64    #[serde(borrow)]
65    pub cid: Option<Cid<'a>>,
66    #[serde(borrow)]
67    pub uri: AtUri<'a>,
68    #[serde(borrow)]
69    pub value: Publication<'a>,
70}
71
72
73#[lexicon]
74#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
75#[serde(rename_all = "camelCase")]
76pub struct Preferences<'a> {
77    /// Defaults to `true`.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    #[serde(default = "_default_preferences_show_comments")]
80    pub show_comments: Option<bool>,
81    /// Defaults to `true`.
82    #[serde(skip_serializing_if = "Option::is_none")]
83    #[serde(default = "_default_preferences_show_in_discover")]
84    pub show_in_discover: Option<bool>,
85    /// Defaults to `true`.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    #[serde(default = "_default_preferences_show_mentions")]
88    pub show_mentions: Option<bool>,
89    /// Defaults to `true`.
90    #[serde(skip_serializing_if = "Option::is_none")]
91    #[serde(default = "_default_preferences_show_prev_next")]
92    pub show_prev_next: Option<bool>,
93    /// Defaults to `true`.
94    #[serde(skip_serializing_if = "Option::is_none")]
95    #[serde(default = "_default_preferences_show_recommends")]
96    pub show_recommends: Option<bool>,
97}
98
99
100#[lexicon]
101#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
102#[serde(rename_all = "camelCase")]
103pub struct Theme<'a> {
104    #[serde(skip_serializing_if = "Option::is_none")]
105    #[serde(borrow)]
106    pub accent_background: Option<ThemeAccentBackground<'a>>,
107    #[serde(skip_serializing_if = "Option::is_none")]
108    #[serde(borrow)]
109    pub accent_text: Option<ThemeAccentText<'a>>,
110    #[serde(skip_serializing_if = "Option::is_none")]
111    #[serde(borrow)]
112    pub background_color: Option<ThemeBackgroundColor<'a>>,
113    #[serde(skip_serializing_if = "Option::is_none")]
114    #[serde(borrow)]
115    pub background_image: Option<BackgroundImage<'a>>,
116    #[serde(skip_serializing_if = "Option::is_none")]
117    #[serde(borrow)]
118    pub body_font: Option<CowStr<'a>>,
119    #[serde(skip_serializing_if = "Option::is_none")]
120    #[serde(borrow)]
121    pub heading_font: Option<CowStr<'a>>,
122    #[serde(skip_serializing_if = "Option::is_none")]
123    #[serde(borrow)]
124    pub page_background: Option<ThemePageBackground<'a>>,
125    #[serde(skip_serializing_if = "Option::is_none")]
126    pub page_width: Option<i64>,
127    #[serde(skip_serializing_if = "Option::is_none")]
128    #[serde(borrow)]
129    pub primary: Option<ThemePrimary<'a>>,
130    /// Defaults to `false`.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    #[serde(default = "_default_theme_show_page_background")]
133    pub show_page_background: Option<bool>,
134}
135
136
137#[open_union]
138#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
139#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
140pub enum ThemeAccentBackground<'a> {
141    #[serde(rename = "pub.leaflet.theme.color#rgba")]
142    ColorRgba(Box<Rgba<'a>>),
143    #[serde(rename = "pub.leaflet.theme.color#rgb")]
144    ColorRgb(Box<Rgb<'a>>),
145}
146
147
148#[open_union]
149#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
150#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
151pub enum ThemeAccentText<'a> {
152    #[serde(rename = "pub.leaflet.theme.color#rgba")]
153    ColorRgba(Box<Rgba<'a>>),
154    #[serde(rename = "pub.leaflet.theme.color#rgb")]
155    ColorRgb(Box<Rgb<'a>>),
156}
157
158
159#[open_union]
160#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
161#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
162pub enum ThemeBackgroundColor<'a> {
163    #[serde(rename = "pub.leaflet.theme.color#rgba")]
164    ColorRgba(Box<Rgba<'a>>),
165    #[serde(rename = "pub.leaflet.theme.color#rgb")]
166    ColorRgb(Box<Rgb<'a>>),
167}
168
169
170#[open_union]
171#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
172#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
173pub enum ThemePageBackground<'a> {
174    #[serde(rename = "pub.leaflet.theme.color#rgba")]
175    ColorRgba(Box<Rgba<'a>>),
176    #[serde(rename = "pub.leaflet.theme.color#rgb")]
177    ColorRgb(Box<Rgb<'a>>),
178}
179
180
181#[open_union]
182#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
183#[serde(tag = "$type", bound(deserialize = "'de: 'a"))]
184pub enum ThemePrimary<'a> {
185    #[serde(rename = "pub.leaflet.theme.color#rgba")]
186    ColorRgba(Box<Rgba<'a>>),
187    #[serde(rename = "pub.leaflet.theme.color#rgb")]
188    ColorRgb(Box<Rgb<'a>>),
189}
190
191impl<'a> Publication<'a> {
192    pub fn uri(
193        uri: impl Into<CowStr<'a>>,
194    ) -> Result<RecordUri<'a, PublicationRecord>, UriError> {
195        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
196    }
197}
198
199/// Marker type for deserializing records from this collection.
200
201#[derive(Debug, Serialize, Deserialize)]
202pub struct PublicationRecord;
203impl XrpcResp for PublicationRecord {
204    const NSID: &'static str = "pub.leaflet.publication";
205    const ENCODING: &'static str = "application/json";
206    type Output<'de> = PublicationGetRecordOutput<'de>;
207    type Err<'de> = RecordError<'de>;
208}
209
210impl From<PublicationGetRecordOutput<'_>> for Publication<'_> {
211    fn from(output: PublicationGetRecordOutput<'_>) -> Self {
212        use jacquard_common::IntoStatic;
213        output.value.into_static()
214    }
215}
216
217impl Collection for Publication<'_> {
218    const NSID: &'static str = "pub.leaflet.publication";
219    type Record = PublicationRecord;
220}
221
222impl Collection for PublicationRecord {
223    const NSID: &'static str = "pub.leaflet.publication";
224    type Record = PublicationRecord;
225}
226
227impl<'a> LexiconSchema for Publication<'a> {
228    fn nsid() -> &'static str {
229        "pub.leaflet.publication"
230    }
231    fn def_name() -> &'static str {
232        "main"
233    }
234    fn lexicon_doc() -> LexiconDoc<'static> {
235        lexicon_doc_pub_leaflet_publication()
236    }
237    fn validate(&self) -> Result<(), ConstraintError> {
238        if let Some(ref value) = self.description {
239            #[allow(unused_comparisons)]
240            if <str>::len(value.as_ref()) > 2000usize {
241                return Err(ConstraintError::MaxLength {
242                    path: ValidationPath::from_field("description"),
243                    max: 2000usize,
244                    actual: <str>::len(value.as_ref()),
245                });
246            }
247        }
248        if let Some(ref value) = self.icon {
249            {
250                let size = value.blob().size;
251                if size > 1000000usize {
252                    return Err(ConstraintError::BlobTooLarge {
253                        path: ValidationPath::from_field("icon"),
254                        max: 1000000usize,
255                        actual: size,
256                    });
257                }
258            }
259        }
260        if let Some(ref value) = self.icon {
261            {
262                let mime = value.blob().mime_type.as_str();
263                let accepted: &[&str] = &["image/*"];
264                let matched = accepted
265                    .iter()
266                    .any(|pattern| {
267                        if *pattern == "*/*" {
268                            true
269                        } else if pattern.ends_with("/*") {
270                            let prefix = &pattern[..pattern.len() - 2];
271                            mime.starts_with(prefix)
272                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
273                        } else {
274                            mime == *pattern
275                        }
276                    });
277                if !matched {
278                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
279                        path: ValidationPath::from_field("icon"),
280                        accepted: vec!["image/*".to_string()],
281                        actual: mime.to_string(),
282                    });
283                }
284            }
285        }
286        {
287            let value = &self.name;
288            #[allow(unused_comparisons)]
289            if <str>::len(value.as_ref()) > 2000usize {
290                return Err(ConstraintError::MaxLength {
291                    path: ValidationPath::from_field("name"),
292                    max: 2000usize,
293                    actual: <str>::len(value.as_ref()),
294                });
295            }
296        }
297        Ok(())
298    }
299}
300
301impl<'a> LexiconSchema for Preferences<'a> {
302    fn nsid() -> &'static str {
303        "pub.leaflet.publication"
304    }
305    fn def_name() -> &'static str {
306        "preferences"
307    }
308    fn lexicon_doc() -> LexiconDoc<'static> {
309        lexicon_doc_pub_leaflet_publication()
310    }
311    fn validate(&self) -> Result<(), ConstraintError> {
312        Ok(())
313    }
314}
315
316impl<'a> LexiconSchema for Theme<'a> {
317    fn nsid() -> &'static str {
318        "pub.leaflet.publication"
319    }
320    fn def_name() -> &'static str {
321        "theme"
322    }
323    fn lexicon_doc() -> LexiconDoc<'static> {
324        lexicon_doc_pub_leaflet_publication()
325    }
326    fn validate(&self) -> Result<(), ConstraintError> {
327        if let Some(ref value) = self.body_font {
328            #[allow(unused_comparisons)]
329            if <str>::len(value.as_ref()) > 100usize {
330                return Err(ConstraintError::MaxLength {
331                    path: ValidationPath::from_field("body_font"),
332                    max: 100usize,
333                    actual: <str>::len(value.as_ref()),
334                });
335            }
336        }
337        if let Some(ref value) = self.heading_font {
338            #[allow(unused_comparisons)]
339            if <str>::len(value.as_ref()) > 100usize {
340                return Err(ConstraintError::MaxLength {
341                    path: ValidationPath::from_field("heading_font"),
342                    max: 100usize,
343                    actual: <str>::len(value.as_ref()),
344                });
345            }
346        }
347        if let Some(ref value) = self.page_width {
348            if *value > 1600i64 {
349                return Err(ConstraintError::Maximum {
350                    path: ValidationPath::from_field("page_width"),
351                    max: 1600i64,
352                    actual: *value,
353                });
354            }
355        }
356        if let Some(ref value) = self.page_width {
357            if *value < 0i64 {
358                return Err(ConstraintError::Minimum {
359                    path: ValidationPath::from_field("page_width"),
360                    min: 0i64,
361                    actual: *value,
362                });
363            }
364        }
365        Ok(())
366    }
367}
368
369pub mod publication_state {
370
371    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
372    #[allow(unused)]
373    use ::core::marker::PhantomData;
374    mod sealed {
375        pub trait Sealed {}
376    }
377    /// State trait tracking which required fields have been set
378    pub trait State: sealed::Sealed {
379        type Name;
380    }
381    /// Empty state - all required fields are unset
382    pub struct Empty(());
383    impl sealed::Sealed for Empty {}
384    impl State for Empty {
385        type Name = Unset;
386    }
387    ///State transition - sets the `name` field to Set
388    pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
389    impl<S: State> sealed::Sealed for SetName<S> {}
390    impl<S: State> State for SetName<S> {
391        type Name = Set<members::name>;
392    }
393    /// Marker types for field names
394    #[allow(non_camel_case_types)]
395    pub mod members {
396        ///Marker type for the `name` field
397        pub struct name(());
398    }
399}
400
401/// Builder for constructing an instance of this type
402pub struct PublicationBuilder<'a, S: publication_state::State> {
403    _state: PhantomData<fn() -> S>,
404    _fields: (
405        Option<CowStr<'a>>,
406        Option<CowStr<'a>>,
407        Option<BlobRef<'a>>,
408        Option<CowStr<'a>>,
409        Option<publication::Preferences<'a>>,
410        Option<publication::Theme<'a>>,
411    ),
412    _lifetime: PhantomData<&'a ()>,
413}
414
415impl<'a> Publication<'a> {
416    /// Create a new builder for this type
417    pub fn new() -> PublicationBuilder<'a, publication_state::Empty> {
418        PublicationBuilder::new()
419    }
420}
421
422impl<'a> PublicationBuilder<'a, publication_state::Empty> {
423    /// Create a new builder with all fields unset
424    pub fn new() -> Self {
425        PublicationBuilder {
426            _state: PhantomData,
427            _fields: (None, None, None, None, None, None),
428            _lifetime: PhantomData,
429        }
430    }
431}
432
433impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
434    /// Set the `base_path` field (optional)
435    pub fn base_path(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
436        self._fields.0 = value.into();
437        self
438    }
439    /// Set the `base_path` field to an Option value (optional)
440    pub fn maybe_base_path(mut self, value: Option<CowStr<'a>>) -> Self {
441        self._fields.0 = value;
442        self
443    }
444}
445
446impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
447    /// Set the `description` field (optional)
448    pub fn description(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
449        self._fields.1 = value.into();
450        self
451    }
452    /// Set the `description` field to an Option value (optional)
453    pub fn maybe_description(mut self, value: Option<CowStr<'a>>) -> Self {
454        self._fields.1 = value;
455        self
456    }
457}
458
459impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
460    /// Set the `icon` field (optional)
461    pub fn icon(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
462        self._fields.2 = value.into();
463        self
464    }
465    /// Set the `icon` field to an Option value (optional)
466    pub fn maybe_icon(mut self, value: Option<BlobRef<'a>>) -> Self {
467        self._fields.2 = value;
468        self
469    }
470}
471
472impl<'a, S> PublicationBuilder<'a, S>
473where
474    S: publication_state::State,
475    S::Name: publication_state::IsUnset,
476{
477    /// Set the `name` field (required)
478    pub fn name(
479        mut self,
480        value: impl Into<CowStr<'a>>,
481    ) -> PublicationBuilder<'a, publication_state::SetName<S>> {
482        self._fields.3 = Option::Some(value.into());
483        PublicationBuilder {
484            _state: PhantomData,
485            _fields: self._fields,
486            _lifetime: PhantomData,
487        }
488    }
489}
490
491impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
492    /// Set the `preferences` field (optional)
493    pub fn preferences(
494        mut self,
495        value: impl Into<Option<publication::Preferences<'a>>>,
496    ) -> Self {
497        self._fields.4 = value.into();
498        self
499    }
500    /// Set the `preferences` field to an Option value (optional)
501    pub fn maybe_preferences(
502        mut self,
503        value: Option<publication::Preferences<'a>>,
504    ) -> Self {
505        self._fields.4 = value;
506        self
507    }
508}
509
510impl<'a, S: publication_state::State> PublicationBuilder<'a, S> {
511    /// Set the `theme` field (optional)
512    pub fn theme(mut self, value: impl Into<Option<publication::Theme<'a>>>) -> Self {
513        self._fields.5 = value.into();
514        self
515    }
516    /// Set the `theme` field to an Option value (optional)
517    pub fn maybe_theme(mut self, value: Option<publication::Theme<'a>>) -> Self {
518        self._fields.5 = value;
519        self
520    }
521}
522
523impl<'a, S> PublicationBuilder<'a, S>
524where
525    S: publication_state::State,
526    S::Name: publication_state::IsSet,
527{
528    /// Build the final struct
529    pub fn build(self) -> Publication<'a> {
530        Publication {
531            base_path: self._fields.0,
532            description: self._fields.1,
533            icon: self._fields.2,
534            name: self._fields.3.unwrap(),
535            preferences: self._fields.4,
536            theme: self._fields.5,
537            extra_data: Default::default(),
538        }
539    }
540    /// Build the final struct with custom extra_data
541    pub fn build_with_data(
542        self,
543        extra_data: BTreeMap<
544            jacquard_common::deps::smol_str::SmolStr,
545            jacquard_common::types::value::Data<'a>,
546        >,
547    ) -> Publication<'a> {
548        Publication {
549            base_path: self._fields.0,
550            description: self._fields.1,
551            icon: self._fields.2,
552            name: self._fields.3.unwrap(),
553            preferences: self._fields.4,
554            theme: self._fields.5,
555            extra_data: Some(extra_data),
556        }
557    }
558}
559
560fn lexicon_doc_pub_leaflet_publication() -> LexiconDoc<'static> {
561    #[allow(unused_imports)]
562    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
563    use jacquard_lexicon::lexicon::*;
564    use alloc::collections::BTreeMap;
565    LexiconDoc {
566        lexicon: Lexicon::Lexicon1,
567        id: CowStr::new_static("pub.leaflet.publication"),
568        defs: {
569            let mut map = BTreeMap::new();
570            map.insert(
571                SmolStr::new_static("main"),
572                LexUserType::Record(LexRecord {
573                    description: Some(
574                        CowStr::new_static("Record declaring a publication"),
575                    ),
576                    key: Some(CowStr::new_static("tid")),
577                    record: LexRecordRecord::Object(LexObject {
578                        required: Some(vec![SmolStr::new_static("name")]),
579                        properties: {
580                            #[allow(unused_mut)]
581                            let mut map = BTreeMap::new();
582                            map.insert(
583                                SmolStr::new_static("base_path"),
584                                LexObjectProperty::String(LexString {
585                                    ..Default::default()
586                                }),
587                            );
588                            map.insert(
589                                SmolStr::new_static("description"),
590                                LexObjectProperty::String(LexString {
591                                    max_length: Some(2000usize),
592                                    ..Default::default()
593                                }),
594                            );
595                            map.insert(
596                                SmolStr::new_static("icon"),
597                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
598                            );
599                            map.insert(
600                                SmolStr::new_static("name"),
601                                LexObjectProperty::String(LexString {
602                                    max_length: Some(2000usize),
603                                    ..Default::default()
604                                }),
605                            );
606                            map.insert(
607                                SmolStr::new_static("preferences"),
608                                LexObjectProperty::Ref(LexRef {
609                                    r#ref: CowStr::new_static("#preferences"),
610                                    ..Default::default()
611                                }),
612                            );
613                            map.insert(
614                                SmolStr::new_static("theme"),
615                                LexObjectProperty::Ref(LexRef {
616                                    r#ref: CowStr::new_static("#theme"),
617                                    ..Default::default()
618                                }),
619                            );
620                            map
621                        },
622                        ..Default::default()
623                    }),
624                    ..Default::default()
625                }),
626            );
627            map.insert(
628                SmolStr::new_static("preferences"),
629                LexUserType::Object(LexObject {
630                    properties: {
631                        #[allow(unused_mut)]
632                        let mut map = BTreeMap::new();
633                        map.insert(
634                            SmolStr::new_static("showComments"),
635                            LexObjectProperty::Boolean(LexBoolean {
636                                ..Default::default()
637                            }),
638                        );
639                        map.insert(
640                            SmolStr::new_static("showInDiscover"),
641                            LexObjectProperty::Boolean(LexBoolean {
642                                ..Default::default()
643                            }),
644                        );
645                        map.insert(
646                            SmolStr::new_static("showMentions"),
647                            LexObjectProperty::Boolean(LexBoolean {
648                                ..Default::default()
649                            }),
650                        );
651                        map.insert(
652                            SmolStr::new_static("showPrevNext"),
653                            LexObjectProperty::Boolean(LexBoolean {
654                                ..Default::default()
655                            }),
656                        );
657                        map.insert(
658                            SmolStr::new_static("showRecommends"),
659                            LexObjectProperty::Boolean(LexBoolean {
660                                ..Default::default()
661                            }),
662                        );
663                        map
664                    },
665                    ..Default::default()
666                }),
667            );
668            map.insert(
669                SmolStr::new_static("theme"),
670                LexUserType::Object(LexObject {
671                    properties: {
672                        #[allow(unused_mut)]
673                        let mut map = BTreeMap::new();
674                        map.insert(
675                            SmolStr::new_static("accentBackground"),
676                            LexObjectProperty::Union(LexRefUnion {
677                                refs: vec![
678                                    CowStr::new_static("pub.leaflet.theme.color#rgba"),
679                                    CowStr::new_static("pub.leaflet.theme.color#rgb")
680                                ],
681                                ..Default::default()
682                            }),
683                        );
684                        map.insert(
685                            SmolStr::new_static("accentText"),
686                            LexObjectProperty::Union(LexRefUnion {
687                                refs: vec![
688                                    CowStr::new_static("pub.leaflet.theme.color#rgba"),
689                                    CowStr::new_static("pub.leaflet.theme.color#rgb")
690                                ],
691                                ..Default::default()
692                            }),
693                        );
694                        map.insert(
695                            SmolStr::new_static("backgroundColor"),
696                            LexObjectProperty::Union(LexRefUnion {
697                                refs: vec![
698                                    CowStr::new_static("pub.leaflet.theme.color#rgba"),
699                                    CowStr::new_static("pub.leaflet.theme.color#rgb")
700                                ],
701                                ..Default::default()
702                            }),
703                        );
704                        map.insert(
705                            SmolStr::new_static("backgroundImage"),
706                            LexObjectProperty::Ref(LexRef {
707                                r#ref: CowStr::new_static(
708                                    "pub.leaflet.theme.backgroundImage",
709                                ),
710                                ..Default::default()
711                            }),
712                        );
713                        map.insert(
714                            SmolStr::new_static("bodyFont"),
715                            LexObjectProperty::String(LexString {
716                                max_length: Some(100usize),
717                                ..Default::default()
718                            }),
719                        );
720                        map.insert(
721                            SmolStr::new_static("headingFont"),
722                            LexObjectProperty::String(LexString {
723                                max_length: Some(100usize),
724                                ..Default::default()
725                            }),
726                        );
727                        map.insert(
728                            SmolStr::new_static("pageBackground"),
729                            LexObjectProperty::Union(LexRefUnion {
730                                refs: vec![
731                                    CowStr::new_static("pub.leaflet.theme.color#rgba"),
732                                    CowStr::new_static("pub.leaflet.theme.color#rgb")
733                                ],
734                                ..Default::default()
735                            }),
736                        );
737                        map.insert(
738                            SmolStr::new_static("pageWidth"),
739                            LexObjectProperty::Integer(LexInteger {
740                                minimum: Some(0i64),
741                                maximum: Some(1600i64),
742                                ..Default::default()
743                            }),
744                        );
745                        map.insert(
746                            SmolStr::new_static("primary"),
747                            LexObjectProperty::Union(LexRefUnion {
748                                refs: vec![
749                                    CowStr::new_static("pub.leaflet.theme.color#rgba"),
750                                    CowStr::new_static("pub.leaflet.theme.color#rgb")
751                                ],
752                                ..Default::default()
753                            }),
754                        );
755                        map.insert(
756                            SmolStr::new_static("showPageBackground"),
757                            LexObjectProperty::Boolean(LexBoolean {
758                                ..Default::default()
759                            }),
760                        );
761                        map
762                    },
763                    ..Default::default()
764                }),
765            );
766            map
767        },
768        ..Default::default()
769    }
770}
771
772fn _default_preferences_show_comments() -> Option<bool> {
773    Some(true)
774}
775
776fn _default_preferences_show_in_discover() -> Option<bool> {
777    Some(true)
778}
779
780fn _default_preferences_show_mentions() -> Option<bool> {
781    Some(true)
782}
783
784fn _default_preferences_show_prev_next() -> Option<bool> {
785    Some(true)
786}
787
788fn _default_preferences_show_recommends() -> Option<bool> {
789    Some(true)
790}
791
792impl Default for Preferences<'_> {
793    fn default() -> Self {
794        Self {
795            show_comments: Some(true),
796            show_in_discover: Some(true),
797            show_mentions: Some(true),
798            show_prev_next: Some(true),
799            show_recommends: Some(true),
800            extra_data: Default::default(),
801        }
802    }
803}
804
805fn _default_theme_show_page_background() -> Option<bool> {
806    Some(false)
807}
808
809impl Default for Theme<'_> {
810    fn default() -> Self {
811        Self {
812            accent_background: None,
813            accent_text: None,
814            background_color: None,
815            background_image: None,
816            body_font: None,
817            heading_font: None,
818            page_background: None,
819            page_width: None,
820            primary: None,
821            show_page_background: Some(false),
822            extra_data: Default::default(),
823        }
824    }
825}