// @generated by jacquard-lexicon. DO NOT EDIT. // // Lexicon: pub.leaflet.publication // // This file was automatically generated from Lexicon schemas. // Any manual changes will be overwritten on the next regeneration. /// Record declaring a publication #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct Publication<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub base_path: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub description: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub icon: std::option::Option>, #[serde(borrow)] pub name: jacquard_common::CowStr<'a>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub preferences: std::option::Option< crate::pub_leaflet::publication::Preferences<'a>, >, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub theme: std::option::Option>, } pub mod publication_state { pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; #[allow(unused)] use ::core::marker::PhantomData; mod sealed { pub trait Sealed {} } /// State trait tracking which required fields have been set pub trait State: sealed::Sealed { type Name; } /// Empty state - all required fields are unset pub struct Empty(()); impl sealed::Sealed for Empty {} impl State for Empty { type Name = Unset; } ///State transition - sets the `name` field to Set pub struct SetName(PhantomData S>); impl sealed::Sealed for SetName {} impl State for SetName { type Name = Set; } /// Marker types for field names #[allow(non_camel_case_types)] pub mod members { ///Marker type for the `name` field pub struct name(()); } } /// Builder for constructing an instance of this type pub struct PublicationBuilder<'a, S: publication_state::State> { _phantom_state: ::core::marker::PhantomData S>, __unsafe_private_named: ( ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ::core::option::Option>, ), _phantom: ::core::marker::PhantomData<&'a ()>, } impl<'a> Publication<'a> { /// Create a new builder for this type pub fn new() -> PublicationBuilder<'a, publication_state::Empty> { PublicationBuilder::new() } } impl<'a> PublicationBuilder<'a, publication_state::Empty> { /// Create a new builder with all fields unset pub fn new() -> Self { PublicationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: (None, None, None, None, None, None), _phantom: ::core::marker::PhantomData, } } } impl<'a, S: publication_state::State> PublicationBuilder<'a, S> { /// Set the `base_path` field (optional) pub fn base_path( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.0 = value.into(); self } /// Set the `base_path` field to an Option value (optional) pub fn maybe_base_path( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.0 = value; self } } impl<'a, S: publication_state::State> PublicationBuilder<'a, S> { /// Set the `description` field (optional) pub fn description( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.1 = value.into(); self } /// Set the `description` field to an Option value (optional) pub fn maybe_description( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.1 = value; self } } impl<'a, S: publication_state::State> PublicationBuilder<'a, S> { /// Set the `icon` field (optional) pub fn icon( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.2 = value.into(); self } /// Set the `icon` field to an Option value (optional) pub fn maybe_icon( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.2 = value; self } } impl<'a, S> PublicationBuilder<'a, S> where S: publication_state::State, S::Name: publication_state::IsUnset, { /// Set the `name` field (required) pub fn name( mut self, value: impl Into>, ) -> PublicationBuilder<'a, publication_state::SetName> { self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); PublicationBuilder { _phantom_state: ::core::marker::PhantomData, __unsafe_private_named: self.__unsafe_private_named, _phantom: ::core::marker::PhantomData, } } } impl<'a, S: publication_state::State> PublicationBuilder<'a, S> { /// Set the `preferences` field (optional) pub fn preferences( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.4 = value.into(); self } /// Set the `preferences` field to an Option value (optional) pub fn maybe_preferences( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.4 = value; self } } impl<'a, S: publication_state::State> PublicationBuilder<'a, S> { /// Set the `theme` field (optional) pub fn theme( mut self, value: impl Into>>, ) -> Self { self.__unsafe_private_named.5 = value.into(); self } /// Set the `theme` field to an Option value (optional) pub fn maybe_theme( mut self, value: Option>, ) -> Self { self.__unsafe_private_named.5 = value; self } } impl<'a, S> PublicationBuilder<'a, S> where S: publication_state::State, S::Name: publication_state::IsSet, { /// Build the final struct pub fn build(self) -> Publication<'a> { Publication { base_path: self.__unsafe_private_named.0, description: self.__unsafe_private_named.1, icon: self.__unsafe_private_named.2, name: self.__unsafe_private_named.3.unwrap(), preferences: self.__unsafe_private_named.4, theme: self.__unsafe_private_named.5, extra_data: Default::default(), } } /// Build the final struct with custom extra_data pub fn build_with_data( self, extra_data: std::collections::BTreeMap< jacquard_common::smol_str::SmolStr, jacquard_common::types::value::Data<'a>, >, ) -> Publication<'a> { Publication { base_path: self.__unsafe_private_named.0, description: self.__unsafe_private_named.1, icon: self.__unsafe_private_named.2, name: self.__unsafe_private_named.3.unwrap(), preferences: self.__unsafe_private_named.4, theme: self.__unsafe_private_named.5, extra_data: Some(extra_data), } } } impl<'a> Publication<'a> { pub fn uri( uri: impl Into>, ) -> Result< jacquard_common::types::uri::RecordUri<'a, PublicationRecord>, jacquard_common::types::uri::UriError, > { jacquard_common::types::uri::RecordUri::try_from_uri( jacquard_common::types::string::AtUri::new_cow(uri.into())?, ) } } /// Typed wrapper for GetRecord response with this collection's record type. #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(rename_all = "camelCase")] pub struct PublicationGetRecordOutput<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub cid: std::option::Option>, #[serde(borrow)] pub uri: jacquard_common::types::string::AtUri<'a>, #[serde(borrow)] pub value: Publication<'a>, } impl From> for Publication<'_> { fn from(output: PublicationGetRecordOutput<'_>) -> Self { use jacquard_common::IntoStatic; output.value.into_static() } } impl jacquard_common::types::collection::Collection for Publication<'_> { const NSID: &'static str = "pub.leaflet.publication"; type Record = PublicationRecord; } /// Marker type for deserializing records from this collection. #[derive(Debug, serde::Serialize, serde::Deserialize)] pub struct PublicationRecord; impl jacquard_common::xrpc::XrpcResp for PublicationRecord { const NSID: &'static str = "pub.leaflet.publication"; const ENCODING: &'static str = "application/json"; type Output<'de> = PublicationGetRecordOutput<'de>; type Err<'de> = jacquard_common::types::collection::RecordError<'de>; } impl jacquard_common::types::collection::Collection for PublicationRecord { const NSID: &'static str = "pub.leaflet.publication"; type Record = PublicationRecord; } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Publication<'a> { fn nsid() -> &'static str { "pub.leaflet.publication" } fn def_name() -> &'static str { "main" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_pub_leaflet_publication() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { if let Some(ref value) = self.description { #[allow(unused_comparisons)] if ::len(value.as_ref()) > 2000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "description", ), max: 2000usize, actual: ::len(value.as_ref()), }); } } { let value = &self.name; #[allow(unused_comparisons)] if ::len(value.as_ref()) > 2000usize { return Err(::jacquard_lexicon::validation::ConstraintError::MaxLength { path: ::jacquard_lexicon::validation::ValidationPath::from_field( "name", ), max: 2000usize, actual: ::len(value.as_ref()), }); } } Ok(()) } } fn lexicon_doc_pub_leaflet_publication() -> ::jacquard_lexicon::lexicon::LexiconDoc< 'static, > { ::jacquard_lexicon::lexicon::LexiconDoc { lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, id: ::jacquard_common::CowStr::new_static("pub.leaflet.publication"), revision: None, description: None, defs: { let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("main"), ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord { description: Some( ::jacquard_common::CowStr::new_static( "Record declaring a publication", ), ), key: Some(::jacquard_common::CowStr::new_static("tid")), record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: Some( vec![ ::jacquard_common::smol_str::SmolStr::new_static("name") ], ), nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "base_path", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: None, min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "description", ), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(2000usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("icon"), ::jacquard_lexicon::lexicon::LexObjectProperty::Blob(::jacquard_lexicon::lexicon::LexBlob { description: None, accept: None, max_size: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("name"), ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString { description: None, format: None, default: None, min_length: None, max_length: Some(2000usize), min_graphemes: None, max_graphemes: None, r#enum: None, r#const: None, known_values: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "preferences", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#preferences"), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("theme"), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static("#theme"), }), ); map }, }), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("preferences"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: None, nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "showComments", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "showInDiscover", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map }, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("theme"), ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { description: None, required: None, nullable: None, properties: { #[allow(unused_mut)] let mut map = ::alloc::collections::BTreeMap::new(); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "accentBackground", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgba"), ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgb") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "accentText", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgba"), ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgb") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "backgroundColor", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgba"), ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgb") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "backgroundImage", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Ref(::jacquard_lexicon::lexicon::LexRef { description: None, r#ref: ::jacquard_common::CowStr::new_static( "pub.leaflet.theme.backgroundImage", ), }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "pageBackground", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgba"), ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgb") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static("primary"), ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { description: None, refs: vec![ ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgba"), ::jacquard_common::CowStr::new_static("pub.leaflet.theme.color#rgb") ], closed: None, }), ); map.insert( ::jacquard_common::smol_str::SmolStr::new_static( "showPageBackground", ), ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean { description: None, default: None, r#const: None, }), ); map }, }), ); map }, } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct Preferences<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] pub show_comments: std::option::Option, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub show_in_discover: std::option::Option, } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Preferences<'a> { fn nsid() -> &'static str { "pub.leaflet.publication" } fn def_name() -> &'static str { "preferences" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_pub_leaflet_publication() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } } #[jacquard_derive::lexicon] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic, Default )] #[serde(rename_all = "camelCase")] pub struct Theme<'a> { #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub accent_background: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub accent_text: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub background_color: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub background_image: std::option::Option< crate::pub_leaflet::theme::background_image::BackgroundImage<'a>, >, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub page_background: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] #[serde(borrow)] pub primary: std::option::Option>, #[serde(skip_serializing_if = "std::option::Option::is_none")] pub show_page_background: std::option::Option, } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum ThemeAccentBackground<'a> { #[serde(rename = "pub.leaflet.theme.color#rgba")] ColorRgba(Box>), #[serde(rename = "pub.leaflet.theme.color#rgb")] ColorRgb(Box>), } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum ThemeAccentText<'a> { #[serde(rename = "pub.leaflet.theme.color#rgba")] ColorRgba(Box>), #[serde(rename = "pub.leaflet.theme.color#rgb")] ColorRgb(Box>), } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum ThemeBackgroundColor<'a> { #[serde(rename = "pub.leaflet.theme.color#rgba")] ColorRgba(Box>), #[serde(rename = "pub.leaflet.theme.color#rgb")] ColorRgb(Box>), } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum ThemePageBackground<'a> { #[serde(rename = "pub.leaflet.theme.color#rgba")] ColorRgba(Box>), #[serde(rename = "pub.leaflet.theme.color#rgb")] ColorRgb(Box>), } #[jacquard_derive::open_union] #[derive( serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, jacquard_derive::IntoStatic )] #[serde(tag = "$type")] #[serde(bound(deserialize = "'de: 'a"))] pub enum ThemePrimary<'a> { #[serde(rename = "pub.leaflet.theme.color#rgba")] ColorRgba(Box>), #[serde(rename = "pub.leaflet.theme.color#rgb")] ColorRgb(Box>), } impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Theme<'a> { fn nsid() -> &'static str { "pub.leaflet.publication" } fn def_name() -> &'static str { "theme" } fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { lexicon_doc_pub_leaflet_publication() } fn validate( &self, ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { Ok(()) } }