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::collection::{Collection, RecordError};
19use jacquard_common::types::string::{AtUri, Cid, Datetime};
20use jacquard_common::types::uri::{RecordUri, UriError};
21use jacquard_common::types::value::Data;
22use jacquard_common::xrpc::XrpcResp;
23use jacquard_derive::{IntoStatic, lexicon};
24use jacquard_lexicon::lexicon::LexiconDoc;
25use jacquard_lexicon::schema::LexiconSchema;
26
27#[allow(unused_imports)]
28use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
29use serde::{Serialize, Deserialize};
30use crate::games_gamesgamesgamesgames::MediaItem;
31use crate::games_gamesgamesgamesgames::Website;
32#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
35#[serde(
36 rename_all = "camelCase",
37 rename = "games.gamesgamesgamesgames.engine",
38 tag = "$type",
39 bound(deserialize = "S: Deserialize<'de> + BosStr")
40)]
41pub struct Engine<S: BosStr = DefaultStr> {
42 #[serde(skip_serializing_if = "Option::is_none")]
43 pub companies: Option<Vec<AtUri<S>>>,
44 pub created_at: Datetime,
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub description: Option<S>,
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub media: Option<Vec<MediaItem<S>>>,
49 pub name: S,
50 #[serde(skip_serializing_if = "Option::is_none")]
51 pub platforms: Option<Vec<AtUri<S>>>,
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub websites: Option<Vec<Website<S>>>,
54 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
55 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
56}
57
58#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
61#[serde(rename_all = "camelCase")]
62pub struct EngineGetRecordOutput<S: BosStr = DefaultStr> {
63 #[serde(skip_serializing_if = "Option::is_none")]
64 pub cid: Option<Cid<S>>,
65 pub uri: AtUri<S>,
66 pub value: Engine<S>,
67}
68
69impl<S: BosStr> Engine<S> {
70 pub fn uri(uri: S) -> Result<RecordUri<S, EngineRecord>, UriError> {
71 RecordUri::try_from_uri(AtUri::new(uri)?)
72 }
73}
74
75#[derive(Debug, Serialize, Deserialize)]
78pub struct EngineRecord;
79impl XrpcResp for EngineRecord {
80 const NSID: &'static str = "games.gamesgamesgamesgames.engine";
81 const ENCODING: &'static str = "application/json";
82 type Output<S: BosStr> = EngineGetRecordOutput<S>;
83 type Err = RecordError;
84}
85
86impl<S: BosStr> From<EngineGetRecordOutput<S>> for Engine<S> {
87 fn from(output: EngineGetRecordOutput<S>) -> Self {
88 output.value
89 }
90}
91
92impl<S: BosStr> Collection for Engine<S> {
93 const NSID: &'static str = "games.gamesgamesgamesgames.engine";
94 type Record = EngineRecord;
95}
96
97impl Collection for EngineRecord {
98 const NSID: &'static str = "games.gamesgamesgamesgames.engine";
99 type Record = EngineRecord;
100}
101
102impl<S: BosStr> LexiconSchema for Engine<S> {
103 fn nsid() -> &'static str {
104 "games.gamesgamesgamesgames.engine"
105 }
106 fn def_name() -> &'static str {
107 "main"
108 }
109 fn lexicon_doc() -> LexiconDoc<'static> {
110 lexicon_doc_games_gamesgamesgamesgames_engine()
111 }
112 fn validate(&self) -> Result<(), ConstraintError> {
113 Ok(())
114 }
115}
116
117pub mod engine_state {
118
119 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
120 #[allow(unused)]
121 use ::core::marker::PhantomData;
122 mod sealed {
123 pub trait Sealed {}
124 }
125 pub trait State: sealed::Sealed {
127 type CreatedAt;
128 type Name;
129 }
130 pub struct Empty(());
132 impl sealed::Sealed for Empty {}
133 impl State for Empty {
134 type CreatedAt = Unset;
135 type Name = Unset;
136 }
137 pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
139 impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
140 impl<St: State> State for SetCreatedAt<St> {
141 type CreatedAt = Set<members::created_at>;
142 type Name = St::Name;
143 }
144 pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
146 impl<St: State> sealed::Sealed for SetName<St> {}
147 impl<St: State> State for SetName<St> {
148 type CreatedAt = St::CreatedAt;
149 type Name = Set<members::name>;
150 }
151 #[allow(non_camel_case_types)]
153 pub mod members {
154 pub struct created_at(());
156 pub struct name(());
158 }
159}
160
161pub struct EngineBuilder<St: engine_state::State, S: BosStr = DefaultStr> {
163 _state: PhantomData<fn() -> St>,
164 _fields: (
165 Option<Vec<AtUri<S>>>,
166 Option<Datetime>,
167 Option<S>,
168 Option<Vec<MediaItem<S>>>,
169 Option<S>,
170 Option<Vec<AtUri<S>>>,
171 Option<Vec<Website<S>>>,
172 ),
173 _type: PhantomData<fn() -> S>,
174}
175
176impl Engine<DefaultStr> {
177 pub fn new() -> EngineBuilder<engine_state::Empty, DefaultStr> {
179 EngineBuilder::new()
180 }
181}
182
183impl<S: BosStr> Engine<S> {
184 pub fn builder() -> EngineBuilder<engine_state::Empty, S> {
186 EngineBuilder::builder()
187 }
188}
189
190impl EngineBuilder<engine_state::Empty, DefaultStr> {
191 pub fn new() -> Self {
193 EngineBuilder {
194 _state: PhantomData,
195 _fields: (None, None, None, None, None, None, None),
196 _type: PhantomData,
197 }
198 }
199}
200
201impl<S: BosStr> EngineBuilder<engine_state::Empty, S> {
202 pub fn builder() -> Self {
204 EngineBuilder {
205 _state: PhantomData,
206 _fields: (None, None, None, None, None, None, None),
207 _type: PhantomData,
208 }
209 }
210}
211
212impl<St: engine_state::State, S: BosStr> EngineBuilder<St, S> {
213 pub fn companies(mut self, value: impl Into<Option<Vec<AtUri<S>>>>) -> Self {
215 self._fields.0 = value.into();
216 self
217 }
218 pub fn maybe_companies(mut self, value: Option<Vec<AtUri<S>>>) -> Self {
220 self._fields.0 = value;
221 self
222 }
223}
224
225impl<St, S: BosStr> EngineBuilder<St, S>
226where
227 St: engine_state::State,
228 St::CreatedAt: engine_state::IsUnset,
229{
230 pub fn created_at(
232 mut self,
233 value: impl Into<Datetime>,
234 ) -> EngineBuilder<engine_state::SetCreatedAt<St>, S> {
235 self._fields.1 = Option::Some(value.into());
236 EngineBuilder {
237 _state: PhantomData,
238 _fields: self._fields,
239 _type: PhantomData,
240 }
241 }
242}
243
244impl<St: engine_state::State, S: BosStr> EngineBuilder<St, S> {
245 pub fn description(mut self, value: impl Into<Option<S>>) -> Self {
247 self._fields.2 = value.into();
248 self
249 }
250 pub fn maybe_description(mut self, value: Option<S>) -> Self {
252 self._fields.2 = value;
253 self
254 }
255}
256
257impl<St: engine_state::State, S: BosStr> EngineBuilder<St, S> {
258 pub fn media(mut self, value: impl Into<Option<Vec<MediaItem<S>>>>) -> Self {
260 self._fields.3 = value.into();
261 self
262 }
263 pub fn maybe_media(mut self, value: Option<Vec<MediaItem<S>>>) -> Self {
265 self._fields.3 = value;
266 self
267 }
268}
269
270impl<St, S: BosStr> EngineBuilder<St, S>
271where
272 St: engine_state::State,
273 St::Name: engine_state::IsUnset,
274{
275 pub fn name(
277 mut self,
278 value: impl Into<S>,
279 ) -> EngineBuilder<engine_state::SetName<St>, S> {
280 self._fields.4 = Option::Some(value.into());
281 EngineBuilder {
282 _state: PhantomData,
283 _fields: self._fields,
284 _type: PhantomData,
285 }
286 }
287}
288
289impl<St: engine_state::State, S: BosStr> EngineBuilder<St, S> {
290 pub fn platforms(mut self, value: impl Into<Option<Vec<AtUri<S>>>>) -> Self {
292 self._fields.5 = value.into();
293 self
294 }
295 pub fn maybe_platforms(mut self, value: Option<Vec<AtUri<S>>>) -> Self {
297 self._fields.5 = value;
298 self
299 }
300}
301
302impl<St: engine_state::State, S: BosStr> EngineBuilder<St, S> {
303 pub fn websites(mut self, value: impl Into<Option<Vec<Website<S>>>>) -> Self {
305 self._fields.6 = value.into();
306 self
307 }
308 pub fn maybe_websites(mut self, value: Option<Vec<Website<S>>>) -> Self {
310 self._fields.6 = value;
311 self
312 }
313}
314
315impl<St, S: BosStr> EngineBuilder<St, S>
316where
317 St: engine_state::State,
318 St::CreatedAt: engine_state::IsSet,
319 St::Name: engine_state::IsSet,
320{
321 pub fn build(self) -> Engine<S> {
323 Engine {
324 companies: self._fields.0,
325 created_at: self._fields.1.unwrap(),
326 description: self._fields.2,
327 media: self._fields.3,
328 name: self._fields.4.unwrap(),
329 platforms: self._fields.5,
330 websites: self._fields.6,
331 extra_data: Default::default(),
332 }
333 }
334 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Engine<S> {
336 Engine {
337 companies: self._fields.0,
338 created_at: self._fields.1.unwrap(),
339 description: self._fields.2,
340 media: self._fields.3,
341 name: self._fields.4.unwrap(),
342 platforms: self._fields.5,
343 websites: self._fields.6,
344 extra_data: Some(extra_data),
345 }
346 }
347}
348
349fn lexicon_doc_games_gamesgamesgamesgames_engine() -> LexiconDoc<'static> {
350 #[allow(unused_imports)]
351 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
352 use jacquard_lexicon::lexicon::*;
353 use alloc::collections::BTreeMap;
354 LexiconDoc {
355 lexicon: Lexicon::Lexicon1,
356 id: CowStr::new_static("games.gamesgamesgamesgames.engine"),
357 defs: {
358 let mut map = BTreeMap::new();
359 map.insert(
360 SmolStr::new_static("main"),
361 LexUserType::Record(LexRecord {
362 description: Some(CowStr::new_static("A game engine.")),
363 key: Some(CowStr::new_static("tid")),
364 record: LexRecordRecord::Object(LexObject {
365 required: Some(
366 vec![
367 SmolStr::new_static("name"),
368 SmolStr::new_static("createdAt")
369 ],
370 ),
371 properties: {
372 #[allow(unused_mut)]
373 let mut map = BTreeMap::new();
374 map.insert(
375 SmolStr::new_static("companies"),
376 LexObjectProperty::Array(LexArray {
377 items: LexArrayItem::String(LexString {
378 format: Some(LexStringFormat::AtUri),
379 ..Default::default()
380 }),
381 ..Default::default()
382 }),
383 );
384 map.insert(
385 SmolStr::new_static("createdAt"),
386 LexObjectProperty::String(LexString {
387 format: Some(LexStringFormat::Datetime),
388 ..Default::default()
389 }),
390 );
391 map.insert(
392 SmolStr::new_static("description"),
393 LexObjectProperty::String(LexString {
394 ..Default::default()
395 }),
396 );
397 map.insert(
398 SmolStr::new_static("media"),
399 LexObjectProperty::Array(LexArray {
400 items: LexArrayItem::Ref(LexRef {
401 r#ref: CowStr::new_static(
402 "games.gamesgamesgamesgames.defs#mediaItem",
403 ),
404 ..Default::default()
405 }),
406 ..Default::default()
407 }),
408 );
409 map.insert(
410 SmolStr::new_static("name"),
411 LexObjectProperty::String(LexString {
412 ..Default::default()
413 }),
414 );
415 map.insert(
416 SmolStr::new_static("platforms"),
417 LexObjectProperty::Array(LexArray {
418 items: LexArrayItem::String(LexString {
419 format: Some(LexStringFormat::AtUri),
420 ..Default::default()
421 }),
422 ..Default::default()
423 }),
424 );
425 map.insert(
426 SmolStr::new_static("websites"),
427 LexObjectProperty::Array(LexArray {
428 items: LexArrayItem::Ref(LexRef {
429 r#ref: CowStr::new_static(
430 "games.gamesgamesgamesgames.defs#website",
431 ),
432 ..Default::default()
433 }),
434 ..Default::default()
435 }),
436 );
437 map
438 },
439 ..Default::default()
440 }),
441 ..Default::default()
442 }),
443 );
444 map
445 },
446 ..Default::default()
447 }
448}