atproto blogging
1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: tools.ozone.communication.defs
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8pub mod create_template;
9pub mod delete_template;
10pub mod list_templates;
11pub mod update_template;
12
13#[jacquard_derive::lexicon]
14#[derive(
15 serde::Serialize,
16 serde::Deserialize,
17 Debug,
18 Clone,
19 PartialEq,
20 Eq,
21 jacquard_derive::IntoStatic
22)]
23#[serde(rename_all = "camelCase")]
24pub struct TemplateView<'a> {
25 /// Subject of the message, used in emails.
26 #[serde(borrow)]
27 pub content_markdown: jacquard_common::CowStr<'a>,
28 pub created_at: jacquard_common::types::string::Datetime,
29 pub disabled: bool,
30 #[serde(borrow)]
31 pub id: jacquard_common::CowStr<'a>,
32 /// Message language.
33 #[serde(skip_serializing_if = "std::option::Option::is_none")]
34 pub lang: std::option::Option<jacquard_common::types::string::Language>,
35 /// DID of the user who last updated the template.
36 #[serde(borrow)]
37 pub last_updated_by: jacquard_common::types::string::Did<'a>,
38 /// Name of the template.
39 #[serde(borrow)]
40 pub name: jacquard_common::CowStr<'a>,
41 /// Content of the template, can contain markdown and variable placeholders.
42 #[serde(skip_serializing_if = "std::option::Option::is_none")]
43 #[serde(borrow)]
44 pub subject: std::option::Option<jacquard_common::CowStr<'a>>,
45 pub updated_at: jacquard_common::types::string::Datetime,
46}
47
48pub mod template_view_state {
49
50 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
51 #[allow(unused)]
52 use ::core::marker::PhantomData;
53 mod sealed {
54 pub trait Sealed {}
55 }
56 /// State trait tracking which required fields have been set
57 pub trait State: sealed::Sealed {
58 type UpdatedAt;
59 type Id;
60 type LastUpdatedBy;
61 type Name;
62 type ContentMarkdown;
63 type Disabled;
64 type CreatedAt;
65 }
66 /// Empty state - all required fields are unset
67 pub struct Empty(());
68 impl sealed::Sealed for Empty {}
69 impl State for Empty {
70 type UpdatedAt = Unset;
71 type Id = Unset;
72 type LastUpdatedBy = Unset;
73 type Name = Unset;
74 type ContentMarkdown = Unset;
75 type Disabled = Unset;
76 type CreatedAt = Unset;
77 }
78 ///State transition - sets the `updated_at` field to Set
79 pub struct SetUpdatedAt<S: State = Empty>(PhantomData<fn() -> S>);
80 impl<S: State> sealed::Sealed for SetUpdatedAt<S> {}
81 impl<S: State> State for SetUpdatedAt<S> {
82 type UpdatedAt = Set<members::updated_at>;
83 type Id = S::Id;
84 type LastUpdatedBy = S::LastUpdatedBy;
85 type Name = S::Name;
86 type ContentMarkdown = S::ContentMarkdown;
87 type Disabled = S::Disabled;
88 type CreatedAt = S::CreatedAt;
89 }
90 ///State transition - sets the `id` field to Set
91 pub struct SetId<S: State = Empty>(PhantomData<fn() -> S>);
92 impl<S: State> sealed::Sealed for SetId<S> {}
93 impl<S: State> State for SetId<S> {
94 type UpdatedAt = S::UpdatedAt;
95 type Id = Set<members::id>;
96 type LastUpdatedBy = S::LastUpdatedBy;
97 type Name = S::Name;
98 type ContentMarkdown = S::ContentMarkdown;
99 type Disabled = S::Disabled;
100 type CreatedAt = S::CreatedAt;
101 }
102 ///State transition - sets the `last_updated_by` field to Set
103 pub struct SetLastUpdatedBy<S: State = Empty>(PhantomData<fn() -> S>);
104 impl<S: State> sealed::Sealed for SetLastUpdatedBy<S> {}
105 impl<S: State> State for SetLastUpdatedBy<S> {
106 type UpdatedAt = S::UpdatedAt;
107 type Id = S::Id;
108 type LastUpdatedBy = Set<members::last_updated_by>;
109 type Name = S::Name;
110 type ContentMarkdown = S::ContentMarkdown;
111 type Disabled = S::Disabled;
112 type CreatedAt = S::CreatedAt;
113 }
114 ///State transition - sets the `name` field to Set
115 pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
116 impl<S: State> sealed::Sealed for SetName<S> {}
117 impl<S: State> State for SetName<S> {
118 type UpdatedAt = S::UpdatedAt;
119 type Id = S::Id;
120 type LastUpdatedBy = S::LastUpdatedBy;
121 type Name = Set<members::name>;
122 type ContentMarkdown = S::ContentMarkdown;
123 type Disabled = S::Disabled;
124 type CreatedAt = S::CreatedAt;
125 }
126 ///State transition - sets the `content_markdown` field to Set
127 pub struct SetContentMarkdown<S: State = Empty>(PhantomData<fn() -> S>);
128 impl<S: State> sealed::Sealed for SetContentMarkdown<S> {}
129 impl<S: State> State for SetContentMarkdown<S> {
130 type UpdatedAt = S::UpdatedAt;
131 type Id = S::Id;
132 type LastUpdatedBy = S::LastUpdatedBy;
133 type Name = S::Name;
134 type ContentMarkdown = Set<members::content_markdown>;
135 type Disabled = S::Disabled;
136 type CreatedAt = S::CreatedAt;
137 }
138 ///State transition - sets the `disabled` field to Set
139 pub struct SetDisabled<S: State = Empty>(PhantomData<fn() -> S>);
140 impl<S: State> sealed::Sealed for SetDisabled<S> {}
141 impl<S: State> State for SetDisabled<S> {
142 type UpdatedAt = S::UpdatedAt;
143 type Id = S::Id;
144 type LastUpdatedBy = S::LastUpdatedBy;
145 type Name = S::Name;
146 type ContentMarkdown = S::ContentMarkdown;
147 type Disabled = Set<members::disabled>;
148 type CreatedAt = S::CreatedAt;
149 }
150 ///State transition - sets the `created_at` field to Set
151 pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
152 impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
153 impl<S: State> State for SetCreatedAt<S> {
154 type UpdatedAt = S::UpdatedAt;
155 type Id = S::Id;
156 type LastUpdatedBy = S::LastUpdatedBy;
157 type Name = S::Name;
158 type ContentMarkdown = S::ContentMarkdown;
159 type Disabled = S::Disabled;
160 type CreatedAt = Set<members::created_at>;
161 }
162 /// Marker types for field names
163 #[allow(non_camel_case_types)]
164 pub mod members {
165 ///Marker type for the `updated_at` field
166 pub struct updated_at(());
167 ///Marker type for the `id` field
168 pub struct id(());
169 ///Marker type for the `last_updated_by` field
170 pub struct last_updated_by(());
171 ///Marker type for the `name` field
172 pub struct name(());
173 ///Marker type for the `content_markdown` field
174 pub struct content_markdown(());
175 ///Marker type for the `disabled` field
176 pub struct disabled(());
177 ///Marker type for the `created_at` field
178 pub struct created_at(());
179 }
180}
181
182/// Builder for constructing an instance of this type
183pub struct TemplateViewBuilder<'a, S: template_view_state::State> {
184 _phantom_state: ::core::marker::PhantomData<fn() -> S>,
185 __unsafe_private_named: (
186 ::core::option::Option<jacquard_common::CowStr<'a>>,
187 ::core::option::Option<jacquard_common::types::string::Datetime>,
188 ::core::option::Option<bool>,
189 ::core::option::Option<jacquard_common::CowStr<'a>>,
190 ::core::option::Option<jacquard_common::types::string::Language>,
191 ::core::option::Option<jacquard_common::types::string::Did<'a>>,
192 ::core::option::Option<jacquard_common::CowStr<'a>>,
193 ::core::option::Option<jacquard_common::CowStr<'a>>,
194 ::core::option::Option<jacquard_common::types::string::Datetime>,
195 ),
196 _phantom: ::core::marker::PhantomData<&'a ()>,
197}
198
199impl<'a> TemplateView<'a> {
200 /// Create a new builder for this type
201 pub fn new() -> TemplateViewBuilder<'a, template_view_state::Empty> {
202 TemplateViewBuilder::new()
203 }
204}
205
206impl<'a> TemplateViewBuilder<'a, template_view_state::Empty> {
207 /// Create a new builder with all fields unset
208 pub fn new() -> Self {
209 TemplateViewBuilder {
210 _phantom_state: ::core::marker::PhantomData,
211 __unsafe_private_named: (
212 None,
213 None,
214 None,
215 None,
216 None,
217 None,
218 None,
219 None,
220 None,
221 ),
222 _phantom: ::core::marker::PhantomData,
223 }
224 }
225}
226
227impl<'a, S> TemplateViewBuilder<'a, S>
228where
229 S: template_view_state::State,
230 S::ContentMarkdown: template_view_state::IsUnset,
231{
232 /// Set the `contentMarkdown` field (required)
233 pub fn content_markdown(
234 mut self,
235 value: impl Into<jacquard_common::CowStr<'a>>,
236 ) -> TemplateViewBuilder<'a, template_view_state::SetContentMarkdown<S>> {
237 self.__unsafe_private_named.0 = ::core::option::Option::Some(value.into());
238 TemplateViewBuilder {
239 _phantom_state: ::core::marker::PhantomData,
240 __unsafe_private_named: self.__unsafe_private_named,
241 _phantom: ::core::marker::PhantomData,
242 }
243 }
244}
245
246impl<'a, S> TemplateViewBuilder<'a, S>
247where
248 S: template_view_state::State,
249 S::CreatedAt: template_view_state::IsUnset,
250{
251 /// Set the `createdAt` field (required)
252 pub fn created_at(
253 mut self,
254 value: impl Into<jacquard_common::types::string::Datetime>,
255 ) -> TemplateViewBuilder<'a, template_view_state::SetCreatedAt<S>> {
256 self.__unsafe_private_named.1 = ::core::option::Option::Some(value.into());
257 TemplateViewBuilder {
258 _phantom_state: ::core::marker::PhantomData,
259 __unsafe_private_named: self.__unsafe_private_named,
260 _phantom: ::core::marker::PhantomData,
261 }
262 }
263}
264
265impl<'a, S> TemplateViewBuilder<'a, S>
266where
267 S: template_view_state::State,
268 S::Disabled: template_view_state::IsUnset,
269{
270 /// Set the `disabled` field (required)
271 pub fn disabled(
272 mut self,
273 value: impl Into<bool>,
274 ) -> TemplateViewBuilder<'a, template_view_state::SetDisabled<S>> {
275 self.__unsafe_private_named.2 = ::core::option::Option::Some(value.into());
276 TemplateViewBuilder {
277 _phantom_state: ::core::marker::PhantomData,
278 __unsafe_private_named: self.__unsafe_private_named,
279 _phantom: ::core::marker::PhantomData,
280 }
281 }
282}
283
284impl<'a, S> TemplateViewBuilder<'a, S>
285where
286 S: template_view_state::State,
287 S::Id: template_view_state::IsUnset,
288{
289 /// Set the `id` field (required)
290 pub fn id(
291 mut self,
292 value: impl Into<jacquard_common::CowStr<'a>>,
293 ) -> TemplateViewBuilder<'a, template_view_state::SetId<S>> {
294 self.__unsafe_private_named.3 = ::core::option::Option::Some(value.into());
295 TemplateViewBuilder {
296 _phantom_state: ::core::marker::PhantomData,
297 __unsafe_private_named: self.__unsafe_private_named,
298 _phantom: ::core::marker::PhantomData,
299 }
300 }
301}
302
303impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, S> {
304 /// Set the `lang` field (optional)
305 pub fn lang(
306 mut self,
307 value: impl Into<Option<jacquard_common::types::string::Language>>,
308 ) -> Self {
309 self.__unsafe_private_named.4 = value.into();
310 self
311 }
312 /// Set the `lang` field to an Option value (optional)
313 pub fn maybe_lang(
314 mut self,
315 value: Option<jacquard_common::types::string::Language>,
316 ) -> Self {
317 self.__unsafe_private_named.4 = value;
318 self
319 }
320}
321
322impl<'a, S> TemplateViewBuilder<'a, S>
323where
324 S: template_view_state::State,
325 S::LastUpdatedBy: template_view_state::IsUnset,
326{
327 /// Set the `lastUpdatedBy` field (required)
328 pub fn last_updated_by(
329 mut self,
330 value: impl Into<jacquard_common::types::string::Did<'a>>,
331 ) -> TemplateViewBuilder<'a, template_view_state::SetLastUpdatedBy<S>> {
332 self.__unsafe_private_named.5 = ::core::option::Option::Some(value.into());
333 TemplateViewBuilder {
334 _phantom_state: ::core::marker::PhantomData,
335 __unsafe_private_named: self.__unsafe_private_named,
336 _phantom: ::core::marker::PhantomData,
337 }
338 }
339}
340
341impl<'a, S> TemplateViewBuilder<'a, S>
342where
343 S: template_view_state::State,
344 S::Name: template_view_state::IsUnset,
345{
346 /// Set the `name` field (required)
347 pub fn name(
348 mut self,
349 value: impl Into<jacquard_common::CowStr<'a>>,
350 ) -> TemplateViewBuilder<'a, template_view_state::SetName<S>> {
351 self.__unsafe_private_named.6 = ::core::option::Option::Some(value.into());
352 TemplateViewBuilder {
353 _phantom_state: ::core::marker::PhantomData,
354 __unsafe_private_named: self.__unsafe_private_named,
355 _phantom: ::core::marker::PhantomData,
356 }
357 }
358}
359
360impl<'a, S: template_view_state::State> TemplateViewBuilder<'a, S> {
361 /// Set the `subject` field (optional)
362 pub fn subject(
363 mut self,
364 value: impl Into<Option<jacquard_common::CowStr<'a>>>,
365 ) -> Self {
366 self.__unsafe_private_named.7 = value.into();
367 self
368 }
369 /// Set the `subject` field to an Option value (optional)
370 pub fn maybe_subject(mut self, value: Option<jacquard_common::CowStr<'a>>) -> Self {
371 self.__unsafe_private_named.7 = value;
372 self
373 }
374}
375
376impl<'a, S> TemplateViewBuilder<'a, S>
377where
378 S: template_view_state::State,
379 S::UpdatedAt: template_view_state::IsUnset,
380{
381 /// Set the `updatedAt` field (required)
382 pub fn updated_at(
383 mut self,
384 value: impl Into<jacquard_common::types::string::Datetime>,
385 ) -> TemplateViewBuilder<'a, template_view_state::SetUpdatedAt<S>> {
386 self.__unsafe_private_named.8 = ::core::option::Option::Some(value.into());
387 TemplateViewBuilder {
388 _phantom_state: ::core::marker::PhantomData,
389 __unsafe_private_named: self.__unsafe_private_named,
390 _phantom: ::core::marker::PhantomData,
391 }
392 }
393}
394
395impl<'a, S> TemplateViewBuilder<'a, S>
396where
397 S: template_view_state::State,
398 S::UpdatedAt: template_view_state::IsSet,
399 S::Id: template_view_state::IsSet,
400 S::LastUpdatedBy: template_view_state::IsSet,
401 S::Name: template_view_state::IsSet,
402 S::ContentMarkdown: template_view_state::IsSet,
403 S::Disabled: template_view_state::IsSet,
404 S::CreatedAt: template_view_state::IsSet,
405{
406 /// Build the final struct
407 pub fn build(self) -> TemplateView<'a> {
408 TemplateView {
409 content_markdown: self.__unsafe_private_named.0.unwrap(),
410 created_at: self.__unsafe_private_named.1.unwrap(),
411 disabled: self.__unsafe_private_named.2.unwrap(),
412 id: self.__unsafe_private_named.3.unwrap(),
413 lang: self.__unsafe_private_named.4,
414 last_updated_by: self.__unsafe_private_named.5.unwrap(),
415 name: self.__unsafe_private_named.6.unwrap(),
416 subject: self.__unsafe_private_named.7,
417 updated_at: self.__unsafe_private_named.8.unwrap(),
418 extra_data: Default::default(),
419 }
420 }
421 /// Build the final struct with custom extra_data
422 pub fn build_with_data(
423 self,
424 extra_data: std::collections::BTreeMap<
425 jacquard_common::smol_str::SmolStr,
426 jacquard_common::types::value::Data<'a>,
427 >,
428 ) -> TemplateView<'a> {
429 TemplateView {
430 content_markdown: self.__unsafe_private_named.0.unwrap(),
431 created_at: self.__unsafe_private_named.1.unwrap(),
432 disabled: self.__unsafe_private_named.2.unwrap(),
433 id: self.__unsafe_private_named.3.unwrap(),
434 lang: self.__unsafe_private_named.4,
435 last_updated_by: self.__unsafe_private_named.5.unwrap(),
436 name: self.__unsafe_private_named.6.unwrap(),
437 subject: self.__unsafe_private_named.7,
438 updated_at: self.__unsafe_private_named.8.unwrap(),
439 extra_data: Some(extra_data),
440 }
441 }
442}
443
444fn lexicon_doc_tools_ozone_communication_defs() -> ::jacquard_lexicon::lexicon::LexiconDoc<
445 'static,
446> {
447 ::jacquard_lexicon::lexicon::LexiconDoc {
448 lexicon: ::jacquard_lexicon::lexicon::Lexicon::Lexicon1,
449 id: ::jacquard_common::CowStr::new_static("tools.ozone.communication.defs"),
450 revision: None,
451 description: None,
452 defs: {
453 let mut map = ::alloc::collections::BTreeMap::new();
454 map.insert(
455 ::jacquard_common::smol_str::SmolStr::new_static("templateView"),
456 ::jacquard_lexicon::lexicon::LexUserType::Object(::jacquard_lexicon::lexicon::LexObject {
457 description: None,
458 required: Some(
459 vec![
460 ::jacquard_common::smol_str::SmolStr::new_static("id"),
461 ::jacquard_common::smol_str::SmolStr::new_static("name"),
462 ::jacquard_common::smol_str::SmolStr::new_static("contentMarkdown"),
463 ::jacquard_common::smol_str::SmolStr::new_static("disabled"),
464 ::jacquard_common::smol_str::SmolStr::new_static("lastUpdatedBy"),
465 ::jacquard_common::smol_str::SmolStr::new_static("createdAt"),
466 ::jacquard_common::smol_str::SmolStr::new_static("updatedAt")
467 ],
468 ),
469 nullable: None,
470 properties: {
471 #[allow(unused_mut)]
472 let mut map = ::alloc::collections::BTreeMap::new();
473 map.insert(
474 ::jacquard_common::smol_str::SmolStr::new_static(
475 "contentMarkdown",
476 ),
477 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
478 description: Some(
479 ::jacquard_common::CowStr::new_static(
480 "Subject of the message, used in emails.",
481 ),
482 ),
483 format: None,
484 default: None,
485 min_length: None,
486 max_length: None,
487 min_graphemes: None,
488 max_graphemes: None,
489 r#enum: None,
490 r#const: None,
491 known_values: None,
492 }),
493 );
494 map.insert(
495 ::jacquard_common::smol_str::SmolStr::new_static(
496 "createdAt",
497 ),
498 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
499 description: None,
500 format: Some(
501 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
502 ),
503 default: None,
504 min_length: None,
505 max_length: None,
506 min_graphemes: None,
507 max_graphemes: None,
508 r#enum: None,
509 r#const: None,
510 known_values: None,
511 }),
512 );
513 map.insert(
514 ::jacquard_common::smol_str::SmolStr::new_static("disabled"),
515 ::jacquard_lexicon::lexicon::LexObjectProperty::Boolean(::jacquard_lexicon::lexicon::LexBoolean {
516 description: None,
517 default: None,
518 r#const: None,
519 }),
520 );
521 map.insert(
522 ::jacquard_common::smol_str::SmolStr::new_static("id"),
523 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
524 description: None,
525 format: None,
526 default: None,
527 min_length: None,
528 max_length: None,
529 min_graphemes: None,
530 max_graphemes: None,
531 r#enum: None,
532 r#const: None,
533 known_values: None,
534 }),
535 );
536 map.insert(
537 ::jacquard_common::smol_str::SmolStr::new_static("lang"),
538 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
539 description: Some(
540 ::jacquard_common::CowStr::new_static("Message language."),
541 ),
542 format: Some(
543 ::jacquard_lexicon::lexicon::LexStringFormat::Language,
544 ),
545 default: None,
546 min_length: None,
547 max_length: None,
548 min_graphemes: None,
549 max_graphemes: None,
550 r#enum: None,
551 r#const: None,
552 known_values: None,
553 }),
554 );
555 map.insert(
556 ::jacquard_common::smol_str::SmolStr::new_static(
557 "lastUpdatedBy",
558 ),
559 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
560 description: Some(
561 ::jacquard_common::CowStr::new_static(
562 "DID of the user who last updated the template.",
563 ),
564 ),
565 format: Some(
566 ::jacquard_lexicon::lexicon::LexStringFormat::Did,
567 ),
568 default: None,
569 min_length: None,
570 max_length: None,
571 min_graphemes: None,
572 max_graphemes: None,
573 r#enum: None,
574 r#const: None,
575 known_values: None,
576 }),
577 );
578 map.insert(
579 ::jacquard_common::smol_str::SmolStr::new_static("name"),
580 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
581 description: Some(
582 ::jacquard_common::CowStr::new_static(
583 "Name of the template.",
584 ),
585 ),
586 format: None,
587 default: None,
588 min_length: None,
589 max_length: None,
590 min_graphemes: None,
591 max_graphemes: None,
592 r#enum: None,
593 r#const: None,
594 known_values: None,
595 }),
596 );
597 map.insert(
598 ::jacquard_common::smol_str::SmolStr::new_static("subject"),
599 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
600 description: Some(
601 ::jacquard_common::CowStr::new_static(
602 "Content of the template, can contain markdown and variable placeholders.",
603 ),
604 ),
605 format: None,
606 default: None,
607 min_length: None,
608 max_length: None,
609 min_graphemes: None,
610 max_graphemes: None,
611 r#enum: None,
612 r#const: None,
613 known_values: None,
614 }),
615 );
616 map.insert(
617 ::jacquard_common::smol_str::SmolStr::new_static(
618 "updatedAt",
619 ),
620 ::jacquard_lexicon::lexicon::LexObjectProperty::String(::jacquard_lexicon::lexicon::LexString {
621 description: None,
622 format: Some(
623 ::jacquard_lexicon::lexicon::LexStringFormat::Datetime,
624 ),
625 default: None,
626 min_length: None,
627 max_length: None,
628 min_graphemes: None,
629 max_graphemes: None,
630 r#enum: None,
631 r#const: None,
632 known_values: None,
633 }),
634 );
635 map
636 },
637 }),
638 );
639 map
640 },
641 }
642}
643
644impl<'a> ::jacquard_lexicon::schema::LexiconSchema for TemplateView<'a> {
645 fn nsid() -> &'static str {
646 "tools.ozone.communication.defs"
647 }
648 fn def_name() -> &'static str {
649 "templateView"
650 }
651 fn lexicon_doc() -> ::jacquard_lexicon::lexicon::LexiconDoc<'static> {
652 lexicon_doc_tools_ozone_communication_defs()
653 }
654 fn validate(
655 &self,
656 ) -> ::core::result::Result<(), ::jacquard_lexicon::validation::ConstraintError> {
657 Ok(())
658 }
659}