A better Rust ATProto crate
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: org.devcon.event.test
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[jacquard_derive::lexicon]
9#[derive(
10 serde::Serialize,
11 serde::Deserialize,
12 Debug,
13 Clone,
14 PartialEq,
15 Eq,
16 jacquard_derive::IntoStatic
17)]
18#[serde(rename_all = "camelCase")]
19pub struct Test<'a> {
20 #[serde(skip_serializing_if = "std::option::Option::is_none")]
21 pub created_at: std::option::Option<jacquard_common::types::string::Datetime>,
22 /// Description of the event
23 #[serde(skip_serializing_if = "std::option::Option::is_none")]
24 #[serde(borrow)]
25 pub description: std::option::Option<jacquard_common::CowStr<'a>>,
26 /// End time of the event
27 pub end: jacquard_common::types::string::Datetime,
28 /// Location of the event
29 #[serde(skip_serializing_if = "std::option::Option::is_none")]
30 #[serde(borrow)]
31 pub location: std::option::Option<jacquard_common::CowStr<'a>>,
32 /// Start time of the event
33 pub start: jacquard_common::types::string::Datetime,
34 /// Title of the event
35 #[serde(borrow)]
36 pub title: jacquard_common::CowStr<'a>,
37 /// URL of the event
38 #[serde(skip_serializing_if = "std::option::Option::is_none")]
39 #[serde(borrow)]
40 pub url: std::option::Option<jacquard_common::CowStr<'a>>,
41}
42
43pub mod test_state {
44
45 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
46 #[allow(unused)]
47 use ::core::marker::PhantomData;
48 mod sealed {
49 pub trait Sealed {}
50 }
51 /// State trait tracking which required fields have been set
52 pub trait State: sealed::Sealed {
53 type Title;
54 type End;
55 type Start;
56 }
57 /// Empty state - all required fields are unset
58 pub struct Empty(());
59 impl sealed::Sealed for Empty {}
60 impl State for Empty {
61 type Title = Unset;
62 type End = Unset;
63 type Start = Unset;
64 }
65 ///State transition - sets the `title` field to Set
66 pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
67 impl<S: State> sealed::Sealed for SetTitle<S> {}
68 impl<S: State> State for SetTitle<S> {
69 type Title = Set<members::title>;
70 type End = S::End;
71 type Start = S::Start;
72 }
73 ///State transition - sets the `end` field to Set
74 pub struct SetEnd<S: State = Empty>(PhantomData<fn() -> S>);
75 impl<S: State> sealed::Sealed for SetEnd<S> {}
76 impl<S: State> State for SetEnd<S> {
77 type Title = S::Title;
78 type End = Set<members::end>;
79 type Start = S::Start;
80 }
81 ///State transition - sets the `start` field to Set
82 pub struct SetStart<S: State = Empty>(PhantomData<fn() -> S>);
83 impl<S: State> sealed::Sealed for SetStart<S> {}
84 impl<S: State> State for SetStart<S> {
85 type Title = S::Title;
86 type End = S::End;
87 type Start = Set<members::start>;
88 }
89 /// Marker types for field names
90 #[allow(non_camel_case_types)]
91 pub mod members {
92 ///Marker type for the `title` field
93 pub struct title(());
94 ///Marker type for the `end` field
95 pub struct end(());
96 ///Marker type for the `start` field
97 pub struct start(());
98 }
99}
100
101/// Builder for constructing an instance of this type
102pub struct TestBuilder<'a, S: test_state::State> {
103 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
104 __unsafe_private_named: (
105 ::core::option::Option<jacquard_common::types::string::Datetime>,
106 ::core::option::Option<jacquard_common::CowStr<'a>>,
107 ::core::option::Option<jacquard_common::types::string::Datetime>,
108 ::core::option::Option<jacquard_common::CowStr<'a>>,
109 ::core::option::Option<jacquard_common::types::string::Datetime>,
110 ::core::option::Option<jacquard_common::CowStr<'a>>,
111 ::core::option::Option<jacquard_common::CowStr<'a>>,
112 ),
113 _phantom: ::core::marker::PhantomData<&'a ()>,
114}
115
116impl<'a> Test<'a> {
117 /// Create a new builder for this type
118 pub fn new() -> TestBuilder<'a, test_state::Empty> {
119 TestBuilder::new()
120 }
121}
122
123impl<'a> TestBuilder<'a, test_state::Empty> {
124 /// Create a new builder with all fields unset
125 pub fn new() -> Self {
126 TestBuilder {
127 _phantom_state: ::core::marker::PhantomData,
128 __unsafe_private_named: (None, None, None, None, None, None, None),
129 _phantom: ::core::marker::PhantomData,
130 }
131 }
132}
133
134impl<'a, S: test_state::State> TestBuilder<'a, S> {
135 /// Set the `createdAt` field (optional)
136 pub fn created_at(
137 mut self,
138 value: impl Into<Option<jacquard_common::types::string::Datetime>>,
139 ) -> Self {
140 self.__unsafe_private_named.0 = value.into();
141 self
142 }
143 /// Set the `createdAt` field to an Option value (optional)
144 pub fn maybe_created_at(
145 mut self,
146 value: Option<jacquard_common::types::string::Datetime>,
147 ) -> Self {
148 self.__unsafe_private_named.0 = value;
149 self
150 }
151}
152
153impl<'a, S: test_state::State> TestBuilder<'a, S> {
154 /// Set the `description` field (optional)
155 pub fn description(
156 mut self,
157 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
158 ) -> Self {
159 self.__unsafe_private_named.1 = value.into();
160 self
161 }
162 /// Set the `description` field to an Option value (optional)
163 pub fn maybe_description(
164 mut self,
165 value: Option<jacquard_common::CowStr<'a>>,
166 ) -> Self {
167 self.__unsafe_private_named.1 = value;
168 self
169 }
170}
171
172impl<'a, S> TestBuilder<'a, S>
173where
174 S: test_state::State,
175 S::End: test_state::IsUnset,
176{
177 /// Set the `end` field (required)
178 pub fn end(
179 mut self,
180 value: impl Into<jacquard_common::types::string::Datetime>,
181 ) -> TestBuilder<'a, test_state::SetEnd<S>> {
182 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
183 TestBuilder {
184 _phantom_state: ::core::marker::PhantomData,
185 __unsafe_private_named: self.__unsafe_private_named,
186 _phantom: ::core::marker::PhantomData,
187 }
188 }
189}
190
191impl<'a, S: test_state::State> TestBuilder<'a, S> {
192 /// Set the `location` field (optional)
193 pub fn location(
194 mut self,
195 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
196 ) -> Self {
197 self.__unsafe_private_named.3 = value.into();
198 self
199 }
200 /// Set the `location` field to an Option value (optional)
201 pub fn maybe_location(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
202 self.__unsafe_private_named.3 = value;
203 self
204 }
205}
206
207impl<'a, S> TestBuilder<'a, S>
208where
209 S: test_state::State,
210 S::Start: test_state::IsUnset,
211{
212 /// Set the `start` field (required)
213 pub fn start(
214 mut self,
215 value: impl Into<jacquard_common::types::string::Datetime>,
216 ) -> TestBuilder<'a, test_state::SetStart<S>> {
217 self.__unsafe_private_named.4 = ::core::option::Option::Some(value.into());
218 TestBuilder {
219 _phantom_state: ::core::marker::PhantomData,
220 __unsafe_private_named: self.__unsafe_private_named,
221 _phantom: ::core::marker::PhantomData,
222 }
223 }
224}
225
226impl<'a, S> TestBuilder<'a, S>
227where
228 S: test_state::State,
229 S::Title: test_state::IsUnset,
230{
231 /// Set the `title` field (required)
232 pub fn title(
233 mut self,
234 value: impl Into<jacquard_common::CowStr<'a>>,
235 ) -> TestBuilder<'a, test_state::SetTitle<S>> {
236 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
237 TestBuilder {
238 _phantom_state: ::core::marker::PhantomData,
239 __unsafe_private_named: self.__unsafe_private_named,
240 _phantom: ::core::marker::PhantomData,
241 }
242 }
243}
244
245impl<'a, S: test_state::State> TestBuilder<'a, S> {
246 /// Set the `url` field (optional)
247 pub fn url(mut self, value: impl Into<Option<jacquard_common::CowStr<'a>>>) -> Self {
248 self.__unsafe_private_named.6 = value.into();
249 self
250 }
251 /// Set the `url` field to an Option value (optional)
252 pub fn maybe_url(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
253 self.__unsafe_private_named.6 = value;
254 self
255 }
256}
257
258impl<'a, S> TestBuilder<'a, S>
259where
260 S: test_state::State,
261 S::Title: test_state::IsSet,
262 S::End: test_state::IsSet,
263 S::Start: test_state::IsSet,
264{
265 /// Build the final struct
266 pub fn build(self) -> Test<'a> {
267 Test {
268 created_at: self.__unsafe_private_named.0,
269 description: self.__unsafe_private_named.1,
270 end: self.__unsafe_private_named.2.unwrap(),
271 location: self.__unsafe_private_named.3,
272 start: self.__unsafe_private_named.4.unwrap(),
273 title: self.__unsafe_private_named.5.unwrap(),
274 url: self.__unsafe_private_named.6,
275 extra_data: Default::default(),
276 }
277 }
278 /// Build the final struct with custom extra_data
279 pub fn build_with_data(
280 self,
281 extra_data: std::collections::BTreeMap<
282 jacquard_common::smol_str::SmolStr,
283 jacquard_common::types::value::Data<'a>,
284 >,
285 ) -> Test<'a> {
286 Test {
287 created_at: self.__unsafe_private_named.0,
288 description: self.__unsafe_private_named.1,
289 end: self.__unsafe_private_named.2.unwrap(),
290 location: self.__unsafe_private_named.3,
291 start: self.__unsafe_private_named.4.unwrap(),
292 title: self.__unsafe_private_named.5.unwrap(),
293 url: self.__unsafe_private_named.6,
294 extra_data: Some(extra_data),
295 }
296 }
297}
298
299impl<'a> Test<'a> {
300 pub fn uri(
301 uri: impl Into<jacquard_common::CowStr<'a>>,
302 ) -> Result<
303 jacquard_common::types::uri::RecordUri<'a, TestRecord>,
304 jacquard_common::types::uri::UriError,
305 > {
306 jacquard_common::types::uri::RecordUri::try_from_uri(
307 jacquard_common::types::string::AtUri::new_cow(uri.into())?,
308 )
309 }
310}
311
312/// Typed wrapper for GetRecord response with this collection's record type.
313#[derive(
314 serde::Serialize,
315 serde::Deserialize,
316 Debug,
317 Clone,
318 PartialEq,
319 Eq,
320 jacquard_derive::IntoStatic
321)]
322#[serde(rename_all = "camelCase")]
323pub struct TestGetRecordOutput<'a> {
324 #[serde(skip_serializing_if = "std::option::Option::is_none")]
325 #[serde(borrow)]
326 pub cid: std::option::Option<jacquard_common::types::string::Cid<'a>>,
327 #[serde(borrow)]
328 pub uri: jacquard_common::types::string::AtUri<'a>,
329 #[serde(borrow)]
330 pub value: Test<'a>,
331}
332
333impl From<TestGetRecordOutput<'_>> for Test<'_> {
334 fn from(output: TestGetRecordOutput<'_>) -> Self {
335 use jacquard_common::IntoStatic;
336 output.value.into_static()
337 }
338}
339
340impl jacquard_common::types::collection::Collection for Test<'_> {
341 const NSID: &'static str = "org.devcon.event.test";
342 type Record = TestRecord;
343}
344
345/// Marker type for deserializing records from this collection.
346#[derive(Debug, serde::Serialize, serde::Deserialize)]
347pub struct TestRecord;
348impl jacquard_common::xrpc::XrpcResp for TestRecord {
349 const NSID: &'static str = "org.devcon.event.test";
350 const ENCODING: &'static str = "application/json";
351 type Output<'de> = TestGetRecordOutput<'de>;
352 type Err<'de> = jacquard_common::types::collection::RecordError<'de>;
353}
354
355impl jacquard_common::types::collection::Collection for TestRecord {
356 const NSID: &'static str = "org.devcon.event.test";
357 type Record = TestRecord;
358}
359
360impl<'a> ::jacquard_lexicon::schema::LexiconSchema for Test<'a> {
361 fn nsid() -> &'static str {
362 "org.devcon.event.test"
363 }
364 fn def_name() -> &'static str {
365 "main"
366 }
367 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
368 lexicon_doc_org_devcon_event_test()
369 }
370 fn validate(
371 &self,
372 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
373 Ok(())
374 }
375}
376
377fn lexicon_doc_org_devcon_event_test() -> ::jacquard_lexicon::lexicon::LexiconDoc<
378 'static,
379> {
380 ::jacquard_lexicon::lexicon::LexiconDoc {
381 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
382 id: ::jacquard_common::CowStr::new_static("org.devcon.event.test"),
383 revision: None,
384 description: None,
385 defs: {
386 let mut map = ::alloc::collections::BTreeMap::new();
387 map.insert(
388 ::jacquard_common::smol_str::SmolStr::new_static("main"),
389 ::jacquard_lexicon::lexicon::LexUserType::Record(::jacquard_lexicon::lexicon::LexRecord {
390 description: None,
391 key: Some(::jacquard_common::CowStr::new_static("tid")),
392 record: ::jacquard_lexicon::lexicon::LexRecordRecord::Object(::jacquard_lexicon::lexicon::LexObject {
393 description: None,
394 required: Some(
395 vec![
396 ::jacquard_common::smol_str::SmolStr::new_static("title"),
397 ::jacquard_common::smol_str::SmolStr::new_static("start"),
398 ::jacquard_common::smol_str::SmolStr::new_static("end")
399 ],
400 ),
401 nullable: None,
402 properties: {
403 #[allow(unused_mut)]
404 let mut map = ::alloc::collections::BTreeMap::new();
405 map.insert(
406 ::jacquard_common::smol_str::SmolStr::new_static(
407 "createdAt",
408 ),
409 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
410 description: None,
411 format: Some(
412 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
413 ),
414 default: None,
415 min_length: None,
416 max_length: None,
417 min_graphemes: None,
418 max_graphemes: None,
419 r#enum: None,
420 r#const: None,
421 known_values: None,
422 }),
423 );
424 map.insert(
425 ::jacquard_common::smol_str::SmolStr::new_static(
426 "description",
427 ),
428 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
429 description: Some(
430 ::jacquard_common::CowStr::new_static(
431 "Description of the event",
432 ),
433 ),
434 format: None,
435 default: None,
436 min_length: None,
437 max_length: None,
438 min_graphemes: None,
439 max_graphemes: None,
440 r#enum: None,
441 r#const: None,
442 known_values: None,
443 }),
444 );
445 map.insert(
446 ::jacquard_common::smol_str::SmolStr::new_static("end"),
447 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
448 description: Some(
449 ::jacquard_common::CowStr::new_static(
450 "End time of the event",
451 ),
452 ),
453 format: Some(
454 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
455 ),
456 default: None,
457 min_length: None,
458 max_length: None,
459 min_graphemes: None,
460 max_graphemes: None,
461 r#enum: None,
462 r#const: None,
463 known_values: None,
464 }),
465 );
466 map.insert(
467 ::jacquard_common::smol_str::SmolStr::new_static(
468 "location",
469 ),
470 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
471 description: Some(
472 ::jacquard_common::CowStr::new_static(
473 "Location of the event",
474 ),
475 ),
476 format: None,
477 default: None,
478 min_length: None,
479 max_length: None,
480 min_graphemes: None,
481 max_graphemes: None,
482 r#enum: None,
483 r#const: None,
484 known_values: None,
485 }),
486 );
487 map.insert(
488 ::jacquard_common::smol_str::SmolStr::new_static("start"),
489 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
490 description: Some(
491 ::jacquard_common::CowStr::new_static(
492 "Start time of the event",
493 ),
494 ),
495 format: Some(
496 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
497 ),
498 default: None,
499 min_length: None,
500 max_length: None,
501 min_graphemes: None,
502 max_graphemes: None,
503 r#enum: None,
504 r#const: None,
505 known_values: None,
506 }),
507 );
508 map.insert(
509 ::jacquard_common::smol_str::SmolStr::new_static("title"),
510 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
511 description: Some(
512 ::jacquard_common::CowStr::new_static("Title of the event"),
513 ),
514 format: None,
515 default: None,
516 min_length: None,
517 max_length: None,
518 min_graphemes: None,
519 max_graphemes: None,
520 r#enum: None,
521 r#const: None,
522 known_values: None,
523 }),
524 );
525 map.insert(
526 ::jacquard_common::smol_str::SmolStr::new_static("url"),
527 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
528 description: Some(
529 ::jacquard_common::CowStr::new_static("URL of the event"),
530 ),
531 format: None,
532 default: None,
533 min_length: None,
534 max_length: None,
535 min_graphemes: None,
536 max_graphemes: None,
537 r#enum: None,
538 r#const: None,
539 known_values: None,
540 }),
541 );
542 map
543 },
544 }),
545 }),
546 );
547 map
548 },
549 }
550}