jacquard_api/site_standard/theme/
basic.rs1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13
14#[allow(unused_imports)]
15use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
16use jacquard_derive::{IntoStatic, lexicon};
17use jacquard_lexicon::lexicon::LexiconDoc;
18use jacquard_lexicon::schema::LexiconSchema;
19
20#[allow(unused_imports)]
21use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
22use serde::{Serialize, Deserialize};
23use crate::site_standard::theme::color::Rgb;
24
25#[lexicon]
26#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
27#[serde(rename_all = "camelCase")]
28pub struct Basic<'a> {
29 #[serde(borrow)]
30 pub accent: Rgb<'a>,
31 #[serde(borrow)]
32 pub accent_foreground: Rgb<'a>,
33 #[serde(borrow)]
34 pub background: Rgb<'a>,
35 #[serde(borrow)]
36 pub foreground: Rgb<'a>,
37}
38
39impl<'a> LexiconSchema for Basic<'a> {
40 fn nsid() -> &'static str {
41 "site.standard.theme.basic"
42 }
43 fn def_name() -> &'static str {
44 "main"
45 }
46 fn lexicon_doc() -> LexiconDoc<'static> {
47 lexicon_doc_site_standard_theme_basic()
48 }
49 fn validate(&self) -> Result<(), ConstraintError> {
50 Ok(())
51 }
52}
53
54pub mod basic_state {
55
56 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
57 #[allow(unused)]
58 use ::core::marker::PhantomData;
59 mod sealed {
60 pub trait Sealed {}
61 }
62 pub trait State: sealed::Sealed {
64 type AccentForeground;
65 type Background;
66 type Foreground;
67 type Accent;
68 }
69 pub struct Empty(());
71 impl sealed::Sealed for Empty {}
72 impl State for Empty {
73 type AccentForeground = Unset;
74 type Background = Unset;
75 type Foreground = Unset;
76 type Accent = Unset;
77 }
78 pub struct SetAccentForeground<S: State = Empty>(PhantomData<fn() -> S>);
80 impl<S: State> sealed::Sealed for SetAccentForeground<S> {}
81 impl<S: State> State for SetAccentForeground<S> {
82 type AccentForeground = Set<members::accent_foreground>;
83 type Background = S::Background;
84 type Foreground = S::Foreground;
85 type Accent = S::Accent;
86 }
87 pub struct SetBackground<S: State = Empty>(PhantomData<fn() -> S>);
89 impl<S: State> sealed::Sealed for SetBackground<S> {}
90 impl<S: State> State for SetBackground<S> {
91 type AccentForeground = S::AccentForeground;
92 type Background = Set<members::background>;
93 type Foreground = S::Foreground;
94 type Accent = S::Accent;
95 }
96 pub struct SetForeground<S: State = Empty>(PhantomData<fn() -> S>);
98 impl<S: State> sealed::Sealed for SetForeground<S> {}
99 impl<S: State> State for SetForeground<S> {
100 type AccentForeground = S::AccentForeground;
101 type Background = S::Background;
102 type Foreground = Set<members::foreground>;
103 type Accent = S::Accent;
104 }
105 pub struct SetAccent<S: State = Empty>(PhantomData<fn() -> S>);
107 impl<S: State> sealed::Sealed for SetAccent<S> {}
108 impl<S: State> State for SetAccent<S> {
109 type AccentForeground = S::AccentForeground;
110 type Background = S::Background;
111 type Foreground = S::Foreground;
112 type Accent = Set<members::accent>;
113 }
114 #[allow(non_camel_case_types)]
116 pub mod members {
117 pub struct accent_foreground(());
119 pub struct background(());
121 pub struct foreground(());
123 pub struct accent(());
125 }
126}
127
128pub struct BasicBuilder<'a, S: basic_state::State> {
130 _state: PhantomData<fn() -> S>,
131 _fields: (Option<Rgb<'a>>, Option<Rgb<'a>>, Option<Rgb<'a>>, Option<Rgb<'a>>),
132 _lifetime: PhantomData<&'a ()>,
133}
134
135impl<'a> Basic<'a> {
136 pub fn new() -> BasicBuilder<'a, basic_state::Empty> {
138 BasicBuilder::new()
139 }
140}
141
142impl<'a> BasicBuilder<'a, basic_state::Empty> {
143 pub fn new() -> Self {
145 BasicBuilder {
146 _state: PhantomData,
147 _fields: (None, None, None, None),
148 _lifetime: PhantomData,
149 }
150 }
151}
152
153impl<'a, S> BasicBuilder<'a, S>
154where
155 S: basic_state::State,
156 S::Accent: basic_state::IsUnset,
157{
158 pub fn accent(
160 mut self,
161 value: impl Into<Rgb<'a>>,
162 ) -> BasicBuilder<'a, basic_state::SetAccent<S>> {
163 self._fields.0 = Option::Some(value.into());
164 BasicBuilder {
165 _state: PhantomData,
166 _fields: self._fields,
167 _lifetime: PhantomData,
168 }
169 }
170}
171
172impl<'a, S> BasicBuilder<'a, S>
173where
174 S: basic_state::State,
175 S::AccentForeground: basic_state::IsUnset,
176{
177 pub fn accent_foreground(
179 mut self,
180 value: impl Into<Rgb<'a>>,
181 ) -> BasicBuilder<'a, basic_state::SetAccentForeground<S>> {
182 self._fields.1 = Option::Some(value.into());
183 BasicBuilder {
184 _state: PhantomData,
185 _fields: self._fields,
186 _lifetime: PhantomData,
187 }
188 }
189}
190
191impl<'a, S> BasicBuilder<'a, S>
192where
193 S: basic_state::State,
194 S::Background: basic_state::IsUnset,
195{
196 pub fn background(
198 mut self,
199 value: impl Into<Rgb<'a>>,
200 ) -> BasicBuilder<'a, basic_state::SetBackground<S>> {
201 self._fields.2 = Option::Some(value.into());
202 BasicBuilder {
203 _state: PhantomData,
204 _fields: self._fields,
205 _lifetime: PhantomData,
206 }
207 }
208}
209
210impl<'a, S> BasicBuilder<'a, S>
211where
212 S: basic_state::State,
213 S::Foreground: basic_state::IsUnset,
214{
215 pub fn foreground(
217 mut self,
218 value: impl Into<Rgb<'a>>,
219 ) -> BasicBuilder<'a, basic_state::SetForeground<S>> {
220 self._fields.3 = Option::Some(value.into());
221 BasicBuilder {
222 _state: PhantomData,
223 _fields: self._fields,
224 _lifetime: PhantomData,
225 }
226 }
227}
228
229impl<'a, S> BasicBuilder<'a, S>
230where
231 S: basic_state::State,
232 S::AccentForeground: basic_state::IsSet,
233 S::Background: basic_state::IsSet,
234 S::Foreground: basic_state::IsSet,
235 S::Accent: basic_state::IsSet,
236{
237 pub fn build(self) -> Basic<'a> {
239 Basic {
240 accent: self._fields.0.unwrap(),
241 accent_foreground: self._fields.1.unwrap(),
242 background: self._fields.2.unwrap(),
243 foreground: self._fields.3.unwrap(),
244 extra_data: Default::default(),
245 }
246 }
247 pub fn build_with_data(
249 self,
250 extra_data: BTreeMap<
251 jacquard_common::deps::smol_str::SmolStr,
252 jacquard_common::types::value::Data<'a>,
253 >,
254 ) -> Basic<'a> {
255 Basic {
256 accent: self._fields.0.unwrap(),
257 accent_foreground: self._fields.1.unwrap(),
258 background: self._fields.2.unwrap(),
259 foreground: self._fields.3.unwrap(),
260 extra_data: Some(extra_data),
261 }
262 }
263}
264
265fn lexicon_doc_site_standard_theme_basic() -> LexiconDoc<'static> {
266 #[allow(unused_imports)]
267 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
268 use jacquard_lexicon::lexicon::*;
269 use alloc::collections::BTreeMap;
270 LexiconDoc {
271 lexicon: Lexicon::Lexicon1,
272 id: CowStr::new_static("site.standard.theme.basic"),
273 defs: {
274 let mut map = BTreeMap::new();
275 map.insert(
276 SmolStr::new_static("main"),
277 LexUserType::Object(LexObject {
278 required: Some(
279 vec![
280 SmolStr::new_static("background"),
281 SmolStr::new_static("foreground"),
282 SmolStr::new_static("accent"),
283 SmolStr::new_static("accentForeground")
284 ],
285 ),
286 properties: {
287 #[allow(unused_mut)]
288 let mut map = BTreeMap::new();
289 map.insert(
290 SmolStr::new_static("accent"),
291 LexObjectProperty::Union(LexRefUnion {
292 refs: vec![
293 CowStr::new_static("site.standard.theme.color#rgb")
294 ],
295 ..Default::default()
296 }),
297 );
298 map.insert(
299 SmolStr::new_static("accentForeground"),
300 LexObjectProperty::Union(LexRefUnion {
301 refs: vec![
302 CowStr::new_static("site.standard.theme.color#rgb")
303 ],
304 ..Default::default()
305 }),
306 );
307 map.insert(
308 SmolStr::new_static("background"),
309 LexObjectProperty::Union(LexRefUnion {
310 refs: vec![
311 CowStr::new_static("site.standard.theme.color#rgb")
312 ],
313 ..Default::default()
314 }),
315 );
316 map.insert(
317 SmolStr::new_static("foreground"),
318 LexObjectProperty::Union(LexRefUnion {
319 refs: vec![
320 CowStr::new_static("site.standard.theme.color#rgb")
321 ],
322 ..Default::default()
323 }),
324 );
325 map
326 },
327 ..Default::default()
328 }),
329 );
330 map
331 },
332 ..Default::default()
333 }
334}