atproto blogging
at main 367 lines 14 kB view raw
1// @generated by jacquard-lexicon. DO NOT EDIT. 2// 3// Lexicon: site.standard.theme.basic 4// 5// This file was automatically generated from Lexicon schemas. 6// Any manual changes will be overwritten on the next regeneration. 7 8/// A simplified theme definition for publications, providing basic color customization for content display across different platforms and applications. 9#[jacquard_derive::lexicon] 10#[derive( 11 serde::Serialize, 12 serde::Deserialize, 13 Debug, 14 Clone, 15 PartialEq, 16 Eq, 17 jacquard_derive::IntoStatic 18)] 19#[serde(rename_all = "camelCase")] 20pub struct Basic<'a> { 21 /// Color used for links and button backgrounds. 22 #[serde(borrow)] 23 pub accent: crate::site_standard::theme::color::Rgb<'a>, 24 /// Color used for button text. 25 #[serde(borrow)] 26 pub accent_foreground: crate::site_standard::theme::color::Rgb<'a>, 27 /// Color used for content background. 28 #[serde(borrow)] 29 pub background: crate::site_standard::theme::color::Rgb<'a>, 30 /// Color used for content text. 31 #[serde(borrow)] 32 pub foreground: crate::site_standard::theme::color::Rgb<'a>, 33} 34 35pub mod basic_state { 36 37 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset}; 38 #[allow(unused)] 39 use ::core::marker::PhantomData; 40 mod sealed { 41 pub trait Sealed {} 42 } 43 /// State trait tracking which required fields have been set 44 pub trait State: sealed::Sealed { 45 type Accent; 46 type Background; 47 type Foreground; 48 type AccentForeground; 49 } 50 /// Empty state - all required fields are unset 51 pub struct Empty(()); 52 impl sealed::Sealed for Empty {} 53 impl State for Empty { 54 type Accent = Unset; 55 type Background = Unset; 56 type Foreground = Unset; 57 type AccentForeground = Unset; 58 } 59 ///State transition - sets the `accent` field to Set 60 pub struct SetAccent<S: State = Empty>(PhantomData<fn() -> S>); 61 impl<S: State> sealed::Sealed for SetAccent<S> {} 62 impl<S: State> State for SetAccent<S> { 63 type Accent = Set<members::accent>; 64 type Background = S::Background; 65 type Foreground = S::Foreground; 66 type AccentForeground = S::AccentForeground; 67 } 68 ///State transition - sets the `background` field to Set 69 pub struct SetBackground<S: State = Empty>(PhantomData<fn() -> S>); 70 impl<S: State> sealed::Sealed for SetBackground<S> {} 71 impl<S: State> State for SetBackground<S> { 72 type Accent = S::Accent; 73 type Background = Set<members::background>; 74 type Foreground = S::Foreground; 75 type AccentForeground = S::AccentForeground; 76 } 77 ///State transition - sets the `foreground` field to Set 78 pub struct SetForeground<S: State = Empty>(PhantomData<fn() -> S>); 79 impl<S: State> sealed::Sealed for SetForeground<S> {} 80 impl<S: State> State for SetForeground<S> { 81 type Accent = S::Accent; 82 type Background = S::Background; 83 type Foreground = Set<members::foreground>; 84 type AccentForeground = S::AccentForeground; 85 } 86 ///State transition - sets the `accent_foreground` field to Set 87 pub struct SetAccentForeground<S: State = Empty>(PhantomData<fn() -> S>); 88 impl<S: State> sealed::Sealed for SetAccentForeground<S> {} 89 impl<S: State> State for SetAccentForeground<S> { 90 type Accent = S::Accent; 91 type Background = S::Background; 92 type Foreground = S::Foreground; 93 type AccentForeground = Set<members::accent_foreground>; 94 } 95 /// Marker types for field names 96 #[allow(non_camel_case_types)] 97 pub mod members { 98 ///Marker type for the `accent` field 99 pub struct accent(()); 100 ///Marker type for the `background` field 101 pub struct background(()); 102 ///Marker type for the `foreground` field 103 pub struct foreground(()); 104 ///Marker type for the `accent_foreground` field 105 pub struct accent_foreground(()); 106 } 107} 108 109/// Builder for constructing an instance of this type 110pub struct BasicBuilder<'a, S: basic_state::State> { 111 _phantom_state: ::core::marker::PhantomData<fn() -> S>, 112 __unsafe_private_named: ( 113 ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>, 114 ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>, 115 ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>, 116 ::core::option::Option<crate::site_standard::theme::color::Rgb<'a>>, 117 ), 118 _phantom: ::core::marker::PhantomData<&'a ()>, 119} 120 121impl<'a> Basic<'a> { 122 /// Create a new builder for this type 123 pub fn new() -> BasicBuilder<'a, basic_state::Empty> { 124 BasicBuilder::new() 125 } 126} 127 128impl<'a> BasicBuilder<'a, basic_state::Empty> { 129 /// Create a new builder with all fields unset 130 pub fn new() -> Self { 131 BasicBuilder { 132 _phantom_state: ::core::marker::PhantomData, 133 __unsafe_private_named: (None, None, None, None), 134 _phantom: ::core::marker::PhantomData, 135 } 136 } 137} 138 139impl<'a, S> BasicBuilder<'a, S> 140where 141 S: basic_state::State, 142 S::Accent: basic_state::IsUnset, 143{ 144 /// Set the `accent` field (required) 145 pub fn accent( 146 mut self, 147 value: impl Into<crate::site_standard::theme::color::Rgb<'a>>, 148 ) -> BasicBuilder<'a, basic_state::SetAccent<S>> { 149 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into()); 150 BasicBuilder { 151 _phantom_state: ::core::marker::PhantomData, 152 __unsafe_private_named: self.__unsafe_private_named, 153 _phantom: ::core::marker::PhantomData, 154 } 155 } 156} 157 158impl<'a, S> BasicBuilder<'a, S> 159where 160 S: basic_state::State, 161 S::AccentForeground: basic_state::IsUnset, 162{ 163 /// Set the `accentForeground` field (required) 164 pub fn accent_foreground( 165 mut self, 166 value: impl Into<crate::site_standard::theme::color::Rgb<'a>>, 167 ) -> BasicBuilder<'a, basic_state::SetAccentForeground<S>> { 168 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into()); 169 BasicBuilder { 170 _phantom_state: ::core::marker::PhantomData, 171 __unsafe_private_named: self.__unsafe_private_named, 172 _phantom: ::core::marker::PhantomData, 173 } 174 } 175} 176 177impl<'a, S> BasicBuilder<'a, S> 178where 179 S: basic_state::State, 180 S::Background: basic_state::IsUnset, 181{ 182 /// Set the `background` field (required) 183 pub fn background( 184 mut self, 185 value: impl Into<crate::site_standard::theme::color::Rgb<'a>>, 186 ) -> BasicBuilder<'a, basic_state::SetBackground<S>> { 187 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into()); 188 BasicBuilder { 189 _phantom_state: ::core::marker::PhantomData, 190 __unsafe_private_named: self.__unsafe_private_named, 191 _phantom: ::core::marker::PhantomData, 192 } 193 } 194} 195 196impl<'a, S> BasicBuilder<'a, S> 197where 198 S: basic_state::State, 199 S::Foreground: basic_state::IsUnset, 200{ 201 /// Set the `foreground` field (required) 202 pub fn foreground( 203 mut self, 204 value: impl Into<crate::site_standard::theme::color::Rgb<'a>>, 205 ) -> BasicBuilder<'a, basic_state::SetForeground<S>> { 206 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into()); 207 BasicBuilder { 208 _phantom_state: ::core::marker::PhantomData, 209 __unsafe_private_named: self.__unsafe_private_named, 210 _phantom: ::core::marker::PhantomData, 211 } 212 } 213} 214 215impl<'a, S> BasicBuilder<'a, S> 216where 217 S: basic_state::State, 218 S::Accent: basic_state::IsSet, 219 S::Background: basic_state::IsSet, 220 S::Foreground: basic_state::IsSet, 221 S::AccentForeground: basic_state::IsSet, 222{ 223 /// Build the final struct 224 pub fn build(self) -> Basic<'a> { 225 Basic { 226 accent: self.__unsafe_private_named.0.unwrap(), 227 accent_foreground: self.__unsafe_private_named.1.unwrap(), 228 background: self.__unsafe_private_named.2.unwrap(), 229 foreground: self.__unsafe_private_named.3.unwrap(), 230 extra_data: Default::default(), 231 } 232 } 233 /// Build the final struct with custom extra_data 234 pub fn build_with_data( 235 self, 236 extra_data: std::collections::BTreeMap< 237 jacquard_common::smol_str::SmolStr, 238 jacquard_common::types::value::Data<'a>, 239 >, 240 ) -> Basic<'a> { 241 Basic { 242 accent: self.__unsafe_private_named.0.unwrap(), 243 accent_foreground: self.__unsafe_private_named.1.unwrap(), 244 background: self.__unsafe_private_named.2.unwrap(), 245 foreground: self.__unsafe_private_named.3.unwrap(), 246 extra_data: Some(extra_data), 247 } 248 } 249} 250 251fn lexicon_doc_site_standard_theme_basic() -> ::jacquard_lexicon::lexicon::LexiconDoc< 252 'static, 253> { 254 ::jacquard_lexicon::lexicon::LexiconDoc { 255 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1, 256 id: ::jacquard_common::CowStr::new_static("site.standard.theme.basic"), 257 revision: None, 258 description: None, 259 defs: { 260 let mut map = ::alloc::collections::BTreeMap::new(); 261 map.insert( 262 ::jacquard_common::smol_str::SmolStr::new_static("main"), 263 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject { 264 description: Some( 265 ::jacquard_common::CowStr::new_static( 266 "A simplified theme definition for publications, providing basic color customization for content display across different platforms and applications.", 267 ), 268 ), 269 required: Some( 270 vec![ 271 ::jacquard_common::smol_str::SmolStr::new_static("background"), 272 ::jacquard_common::smol_str::SmolStr::new_static("foreground"), 273 ::jacquard_common::smol_str::SmolStr::new_static("accent"), 274 ::jacquard_common::smol_str::SmolStr::new_static("accentForeground") 275 ], 276 ), 277 nullable: None, 278 properties: { 279 #[allow(unused_mut)] 280 let mut map = ::alloc::collections::BTreeMap::new(); 281 map.insert( 282 ::jacquard_common::smol_str::SmolStr::new_static("accent"), 283 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 284 description: Some( 285 ::jacquard_common::CowStr::new_static( 286 "Color used for links and button backgrounds.", 287 ), 288 ), 289 refs: vec![ 290 ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb") 291 ], 292 closed: None, 293 }), 294 ); 295 map.insert( 296 ::jacquard_common::smol_str::SmolStr::new_static( 297 "accentForeground", 298 ), 299 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 300 description: Some( 301 ::jacquard_common::CowStr::new_static( 302 "Color used for button text.", 303 ), 304 ), 305 refs: vec![ 306 ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb") 307 ], 308 closed: None, 309 }), 310 ); 311 map.insert( 312 ::jacquard_common::smol_str::SmolStr::new_static( 313 "background", 314 ), 315 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 316 description: Some( 317 ::jacquard_common::CowStr::new_static( 318 "Color used for content background.", 319 ), 320 ), 321 refs: vec![ 322 ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb") 323 ], 324 closed: None, 325 }), 326 ); 327 map.insert( 328 ::jacquard_common::smol_str::SmolStr::new_static( 329 "foreground", 330 ), 331 ::jacquard_lexicon::lexicon::LexObjectProperty::Union(::jacquard_lexicon::lexicon::LexRefUnion { 332 description: Some( 333 ::jacquard_common::CowStr::new_static( 334 "Color used for content text.", 335 ), 336 ), 337 refs: vec![ 338 ::jacquard_common::CowStr::new_static("site.standard.theme.color#rgb") 339 ], 340 closed: None, 341 }), 342 ); 343 map 344 }, 345 }), 346 ); 347 map 348 }, 349 } 350} 351 352impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Basic<'a> { 353 fn nsid() -> &'static str { 354 "site.standard.theme.basic" 355 } 356 fn def_name() -> &'static str { 357 "main" 358 } 359 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> { 360 lexicon_doc_site_standard_theme_basic() 361 } 362 fn validate( 363 &self, 364 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> { 365 Ok(()) 366 } 367}