1pub mod create_draft;
10pub mod delete_draft;
11pub mod get_drafts;
12pub mod update_draft;
13
14#[allow(unused_imports)]
15use alloc::collections::BTreeMap;
16
17#[allow(unused_imports)]
18use core::marker::PhantomData;
19use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
20
21#[allow(unused_imports)]
22use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
23use jacquard_common::deps::smol_str::SmolStr;
24use jacquard_common::types::string::{Datetime, Language, Tid, UriValue};
25use jacquard_common::types::value::Data;
26use jacquard_derive::{IntoStatic, open_union};
27use jacquard_lexicon::lexicon::LexiconDoc;
28use jacquard_lexicon::schema::LexiconSchema;
29
30use crate::app_bsky::draft;
31use crate::app_bsky::feed::postgate::DisableRule;
32use crate::app_bsky::feed::threadgate::FollowerRule;
33use crate::app_bsky::feed::threadgate::FollowingRule;
34use crate::app_bsky::feed::threadgate::ListRule;
35use crate::app_bsky::feed::threadgate::MentionRule;
36use crate::com_atproto::label::SelfLabels;
37use crate::com_atproto::repo::strong_ref::StrongRef;
38#[allow(unused_imports)]
39use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
40use serde::{Deserialize, Serialize};
41#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
44#[serde(
45 rename_all = "camelCase",
46 bound(deserialize = "S: Deserialize<'de> + BosStr")
47)]
48pub struct Draft<S: BosStr = DefaultStr> {
49 #[serde(skip_serializing_if = "Option::is_none")]
51 pub device_id: Option<S>,
52 #[serde(skip_serializing_if = "Option::is_none")]
54 pub device_name: Option<S>,
55 #[serde(skip_serializing_if = "Option::is_none")]
57 pub langs: Option<Vec<Language>>,
58 #[serde(skip_serializing_if = "Option::is_none")]
60 pub postgate_embedding_rules: Option<Vec<DisableRule<S>>>,
61 pub posts: Vec<draft::DraftPost<S>>,
63 #[serde(skip_serializing_if = "Option::is_none")]
65 pub threadgate_allow: Option<Vec<DraftThreadgateAllowItem<S>>>,
66 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
67 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
68}
69
70#[open_union]
71#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
72#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
73pub enum DraftThreadgateAllowItem<S: BosStr = DefaultStr> {
74 #[serde(rename = "app.bsky.feed.threadgate#mentionRule")]
75 ThreadgateMentionRule(Box<MentionRule<S>>),
76 #[serde(rename = "app.bsky.feed.threadgate#followerRule")]
77 ThreadgateFollowerRule(Box<FollowerRule<S>>),
78 #[serde(rename = "app.bsky.feed.threadgate#followingRule")]
79 ThreadgateFollowingRule(Box<FollowingRule<S>>),
80 #[serde(rename = "app.bsky.feed.threadgate#listRule")]
81 ThreadgateListRule(Box<ListRule<S>>),
82}
83
84#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
85#[serde(
86 rename_all = "camelCase",
87 bound(deserialize = "S: Deserialize<'de> + BosStr")
88)]
89pub struct DraftEmbedCaption<S: BosStr = DefaultStr> {
90 pub content: S,
91 pub lang: Language,
92 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
93 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
94}
95
96#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
97#[serde(
98 rename_all = "camelCase",
99 bound(deserialize = "S: Deserialize<'de> + BosStr")
100)]
101pub struct DraftEmbedExternal<S: BosStr = DefaultStr> {
102 pub uri: UriValue<S>,
103 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
104 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
105}
106
107#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
108#[serde(
109 rename_all = "camelCase",
110 bound(deserialize = "S: Deserialize<'de> + BosStr")
111)]
112pub struct DraftEmbedGallery<S: BosStr = DefaultStr> {
113 pub items: draft::DraftEmbedGalleryItems<S>,
114 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
115 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
116}
117
118#[open_union]
119#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
120#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
121pub enum DraftEmbedGalleryItemsItem<S: BosStr = DefaultStr> {
122 #[serde(rename = "app.bsky.draft.defs#draftEmbedImage")]
123 DraftEmbedImage(Box<draft::DraftEmbedImage<S>>),
124}
125
126pub type DraftEmbedGalleryItems<S = DefaultStr> = Vec<DraftEmbedGalleryItemsItem<S>>;
128
129#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
130#[serde(
131 rename_all = "camelCase",
132 bound(deserialize = "S: Deserialize<'de> + BosStr")
133)]
134pub struct DraftEmbedImage<S: BosStr = DefaultStr> {
135 #[serde(skip_serializing_if = "Option::is_none")]
136 pub alt: Option<S>,
137 pub local_ref: draft::DraftEmbedLocalRef<S>,
138 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
139 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
140}
141
142#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
143#[serde(
144 rename_all = "camelCase",
145 bound(deserialize = "S: Deserialize<'de> + BosStr")
146)]
147pub struct DraftEmbedLocalRef<S: BosStr = DefaultStr> {
148 pub path: S,
150 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
151 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
152}
153
154#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
155#[serde(
156 rename_all = "camelCase",
157 bound(deserialize = "S: Deserialize<'de> + BosStr")
158)]
159pub struct DraftEmbedRecord<S: BosStr = DefaultStr> {
160 pub record: StrongRef<S>,
161 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
162 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
163}
164
165#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
166#[serde(
167 rename_all = "camelCase",
168 bound(deserialize = "S: Deserialize<'de> + BosStr")
169)]
170pub struct DraftEmbedVideo<S: BosStr = DefaultStr> {
171 #[serde(skip_serializing_if = "Option::is_none")]
172 pub alt: Option<S>,
173 #[serde(skip_serializing_if = "Option::is_none")]
174 pub captions: Option<Vec<draft::DraftEmbedCaption<S>>>,
175 pub local_ref: draft::DraftEmbedLocalRef<S>,
176 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
177 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
178}
179
180#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
183#[serde(
184 rename_all = "camelCase",
185 bound(deserialize = "S: Deserialize<'de> + BosStr")
186)]
187pub struct DraftPost<S: BosStr = DefaultStr> {
188 #[serde(skip_serializing_if = "Option::is_none")]
189 pub embed_externals: Option<Vec<draft::DraftEmbedExternal<S>>>,
190 #[serde(skip_serializing_if = "Option::is_none")]
191 pub embed_gallery: Option<draft::DraftEmbedGallery<S>>,
192 #[serde(skip_serializing_if = "Option::is_none")]
193 pub embed_images: Option<Vec<draft::DraftEmbedImage<S>>>,
194 #[serde(skip_serializing_if = "Option::is_none")]
195 pub embed_records: Option<Vec<draft::DraftEmbedRecord<S>>>,
196 #[serde(skip_serializing_if = "Option::is_none")]
197 pub embed_videos: Option<Vec<draft::DraftEmbedVideo<S>>>,
198 #[serde(skip_serializing_if = "Option::is_none")]
200 pub labels: Option<SelfLabels<S>>,
201 pub text: S,
203 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
204 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
205}
206
207#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
210#[serde(
211 rename_all = "camelCase",
212 bound(deserialize = "S: Deserialize<'de> + BosStr")
213)]
214pub struct DraftView<S: BosStr = DefaultStr> {
215 pub created_at: Datetime,
217 pub draft: draft::Draft<S>,
218 pub id: Tid,
220 pub updated_at: Datetime,
222 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
223 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
224}
225
226#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
229#[serde(
230 rename_all = "camelCase",
231 bound(deserialize = "S: Deserialize<'de> + BosStr")
232)]
233pub struct DraftWithId<S: BosStr = DefaultStr> {
234 pub draft: draft::Draft<S>,
235 pub id: Tid,
237 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
238 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
239}
240
241impl<S: BosStr> LexiconSchema for Draft<S> {
242 fn nsid() -> &'static str {
243 "app.bsky.draft.defs"
244 }
245 fn def_name() -> &'static str {
246 "draft"
247 }
248 fn lexicon_doc() -> LexiconDoc<'static> {
249 lexicon_doc_app_bsky_draft_defs()
250 }
251 fn validate(&self) -> Result<(), ConstraintError> {
252 if let Some(ref value) = self.device_id {
253 #[allow(unused_comparisons)]
254 if <str>::len(value.as_ref()) > 100usize {
255 return Err(ConstraintError::MaxLength {
256 path: ValidationPath::from_field("device_id"),
257 max: 100usize,
258 actual: <str>::len(value.as_ref()),
259 });
260 }
261 }
262 if let Some(ref value) = self.device_name {
263 #[allow(unused_comparisons)]
264 if <str>::len(value.as_ref()) > 100usize {
265 return Err(ConstraintError::MaxLength {
266 path: ValidationPath::from_field("device_name"),
267 max: 100usize,
268 actual: <str>::len(value.as_ref()),
269 });
270 }
271 }
272 if let Some(ref value) = self.langs {
273 #[allow(unused_comparisons)]
274 if value.len() > 3usize {
275 return Err(ConstraintError::MaxLength {
276 path: ValidationPath::from_field("langs"),
277 max: 3usize,
278 actual: value.len(),
279 });
280 }
281 }
282 if let Some(ref value) = self.postgate_embedding_rules {
283 #[allow(unused_comparisons)]
284 if value.len() > 5usize {
285 return Err(ConstraintError::MaxLength {
286 path: ValidationPath::from_field("postgate_embedding_rules"),
287 max: 5usize,
288 actual: value.len(),
289 });
290 }
291 }
292 {
293 let value = &self.posts;
294 #[allow(unused_comparisons)]
295 if value.len() > 100usize {
296 return Err(ConstraintError::MaxLength {
297 path: ValidationPath::from_field("posts"),
298 max: 100usize,
299 actual: value.len(),
300 });
301 }
302 }
303 {
304 let value = &self.posts;
305 #[allow(unused_comparisons)]
306 if value.len() < 1usize {
307 return Err(ConstraintError::MinLength {
308 path: ValidationPath::from_field("posts"),
309 min: 1usize,
310 actual: value.len(),
311 });
312 }
313 }
314 if let Some(ref value) = self.threadgate_allow {
315 #[allow(unused_comparisons)]
316 if value.len() > 5usize {
317 return Err(ConstraintError::MaxLength {
318 path: ValidationPath::from_field("threadgate_allow"),
319 max: 5usize,
320 actual: value.len(),
321 });
322 }
323 }
324 Ok(())
325 }
326}
327
328impl<S: BosStr> LexiconSchema for DraftEmbedCaption<S> {
329 fn nsid() -> &'static str {
330 "app.bsky.draft.defs"
331 }
332 fn def_name() -> &'static str {
333 "draftEmbedCaption"
334 }
335 fn lexicon_doc() -> LexiconDoc<'static> {
336 lexicon_doc_app_bsky_draft_defs()
337 }
338 fn validate(&self) -> Result<(), ConstraintError> {
339 {
340 let value = &self.content;
341 #[allow(unused_comparisons)]
342 if <str>::len(value.as_ref()) > 10000usize {
343 return Err(ConstraintError::MaxLength {
344 path: ValidationPath::from_field("content"),
345 max: 10000usize,
346 actual: <str>::len(value.as_ref()),
347 });
348 }
349 }
350 Ok(())
351 }
352}
353
354impl<S: BosStr> LexiconSchema for DraftEmbedExternal<S> {
355 fn nsid() -> &'static str {
356 "app.bsky.draft.defs"
357 }
358 fn def_name() -> &'static str {
359 "draftEmbedExternal"
360 }
361 fn lexicon_doc() -> LexiconDoc<'static> {
362 lexicon_doc_app_bsky_draft_defs()
363 }
364 fn validate(&self) -> Result<(), ConstraintError> {
365 Ok(())
366 }
367}
368
369impl<S: BosStr> LexiconSchema for DraftEmbedGallery<S> {
370 fn nsid() -> &'static str {
371 "app.bsky.draft.defs"
372 }
373 fn def_name() -> &'static str {
374 "draftEmbedGallery"
375 }
376 fn lexicon_doc() -> LexiconDoc<'static> {
377 lexicon_doc_app_bsky_draft_defs()
378 }
379 fn validate(&self) -> Result<(), ConstraintError> {
380 Ok(())
381 }
382}
383
384impl<S: BosStr> LexiconSchema for DraftEmbedImage<S> {
385 fn nsid() -> &'static str {
386 "app.bsky.draft.defs"
387 }
388 fn def_name() -> &'static str {
389 "draftEmbedImage"
390 }
391 fn lexicon_doc() -> LexiconDoc<'static> {
392 lexicon_doc_app_bsky_draft_defs()
393 }
394 fn validate(&self) -> Result<(), ConstraintError> {
395 if let Some(ref value) = self.alt {
396 {
397 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
398 if count > 2000usize {
399 return Err(ConstraintError::MaxGraphemes {
400 path: ValidationPath::from_field("alt"),
401 max: 2000usize,
402 actual: count,
403 });
404 }
405 }
406 }
407 Ok(())
408 }
409}
410
411impl<S: BosStr> LexiconSchema for DraftEmbedLocalRef<S> {
412 fn nsid() -> &'static str {
413 "app.bsky.draft.defs"
414 }
415 fn def_name() -> &'static str {
416 "draftEmbedLocalRef"
417 }
418 fn lexicon_doc() -> LexiconDoc<'static> {
419 lexicon_doc_app_bsky_draft_defs()
420 }
421 fn validate(&self) -> Result<(), ConstraintError> {
422 {
423 let value = &self.path;
424 #[allow(unused_comparisons)]
425 if <str>::len(value.as_ref()) > 1024usize {
426 return Err(ConstraintError::MaxLength {
427 path: ValidationPath::from_field("path"),
428 max: 1024usize,
429 actual: <str>::len(value.as_ref()),
430 });
431 }
432 }
433 {
434 let value = &self.path;
435 #[allow(unused_comparisons)]
436 if <str>::len(value.as_ref()) < 1usize {
437 return Err(ConstraintError::MinLength {
438 path: ValidationPath::from_field("path"),
439 min: 1usize,
440 actual: <str>::len(value.as_ref()),
441 });
442 }
443 }
444 Ok(())
445 }
446}
447
448impl<S: BosStr> LexiconSchema for DraftEmbedRecord<S> {
449 fn nsid() -> &'static str {
450 "app.bsky.draft.defs"
451 }
452 fn def_name() -> &'static str {
453 "draftEmbedRecord"
454 }
455 fn lexicon_doc() -> LexiconDoc<'static> {
456 lexicon_doc_app_bsky_draft_defs()
457 }
458 fn validate(&self) -> Result<(), ConstraintError> {
459 Ok(())
460 }
461}
462
463impl<S: BosStr> LexiconSchema for DraftEmbedVideo<S> {
464 fn nsid() -> &'static str {
465 "app.bsky.draft.defs"
466 }
467 fn def_name() -> &'static str {
468 "draftEmbedVideo"
469 }
470 fn lexicon_doc() -> LexiconDoc<'static> {
471 lexicon_doc_app_bsky_draft_defs()
472 }
473 fn validate(&self) -> Result<(), ConstraintError> {
474 if let Some(ref value) = self.alt {
475 {
476 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
477 if count > 2000usize {
478 return Err(ConstraintError::MaxGraphemes {
479 path: ValidationPath::from_field("alt"),
480 max: 2000usize,
481 actual: count,
482 });
483 }
484 }
485 }
486 if let Some(ref value) = self.captions {
487 #[allow(unused_comparisons)]
488 if value.len() > 20usize {
489 return Err(ConstraintError::MaxLength {
490 path: ValidationPath::from_field("captions"),
491 max: 20usize,
492 actual: value.len(),
493 });
494 }
495 }
496 Ok(())
497 }
498}
499
500impl<S: BosStr> LexiconSchema for DraftPost<S> {
501 fn nsid() -> &'static str {
502 "app.bsky.draft.defs"
503 }
504 fn def_name() -> &'static str {
505 "draftPost"
506 }
507 fn lexicon_doc() -> LexiconDoc<'static> {
508 lexicon_doc_app_bsky_draft_defs()
509 }
510 fn validate(&self) -> Result<(), ConstraintError> {
511 if let Some(ref value) = self.embed_externals {
512 #[allow(unused_comparisons)]
513 if value.len() > 1usize {
514 return Err(ConstraintError::MaxLength {
515 path: ValidationPath::from_field("embed_externals"),
516 max: 1usize,
517 actual: value.len(),
518 });
519 }
520 }
521 if let Some(ref value) = self.embed_images {
522 #[allow(unused_comparisons)]
523 if value.len() > 4usize {
524 return Err(ConstraintError::MaxLength {
525 path: ValidationPath::from_field("embed_images"),
526 max: 4usize,
527 actual: value.len(),
528 });
529 }
530 }
531 if let Some(ref value) = self.embed_records {
532 #[allow(unused_comparisons)]
533 if value.len() > 1usize {
534 return Err(ConstraintError::MaxLength {
535 path: ValidationPath::from_field("embed_records"),
536 max: 1usize,
537 actual: value.len(),
538 });
539 }
540 }
541 if let Some(ref value) = self.embed_videos {
542 #[allow(unused_comparisons)]
543 if value.len() > 1usize {
544 return Err(ConstraintError::MaxLength {
545 path: ValidationPath::from_field("embed_videos"),
546 max: 1usize,
547 actual: value.len(),
548 });
549 }
550 }
551 {
552 let value = &self.text;
553 #[allow(unused_comparisons)]
554 if <str>::len(value.as_ref()) > 10000usize {
555 return Err(ConstraintError::MaxLength {
556 path: ValidationPath::from_field("text"),
557 max: 10000usize,
558 actual: <str>::len(value.as_ref()),
559 });
560 }
561 }
562 {
563 let value = &self.text;
564 {
565 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
566 if count > 1000usize {
567 return Err(ConstraintError::MaxGraphemes {
568 path: ValidationPath::from_field("text"),
569 max: 1000usize,
570 actual: count,
571 });
572 }
573 }
574 }
575 Ok(())
576 }
577}
578
579impl<S: BosStr> LexiconSchema for DraftView<S> {
580 fn nsid() -> &'static str {
581 "app.bsky.draft.defs"
582 }
583 fn def_name() -> &'static str {
584 "draftView"
585 }
586 fn lexicon_doc() -> LexiconDoc<'static> {
587 lexicon_doc_app_bsky_draft_defs()
588 }
589 fn validate(&self) -> Result<(), ConstraintError> {
590 Ok(())
591 }
592}
593
594impl<S: BosStr> LexiconSchema for DraftWithId<S> {
595 fn nsid() -> &'static str {
596 "app.bsky.draft.defs"
597 }
598 fn def_name() -> &'static str {
599 "draftWithId"
600 }
601 fn lexicon_doc() -> LexiconDoc<'static> {
602 lexicon_doc_app_bsky_draft_defs()
603 }
604 fn validate(&self) -> Result<(), ConstraintError> {
605 Ok(())
606 }
607}
608
609pub mod draft_state {
610
611 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
612 #[allow(unused)]
613 use ::core::marker::PhantomData;
614 mod sealed {
615 pub trait Sealed {}
616 }
617 pub trait State: sealed::Sealed {
619 type Posts;
620 }
621 pub struct Empty(());
623 impl sealed::Sealed for Empty {}
624 impl State for Empty {
625 type Posts = Unset;
626 }
627 pub struct SetPosts<St: State = Empty>(PhantomData<fn() -> St>);
629 impl<St: State> sealed::Sealed for SetPosts<St> {}
630 impl<St: State> State for SetPosts<St> {
631 type Posts = Set<members::posts>;
632 }
633 #[allow(non_camel_case_types)]
635 pub mod members {
636 pub struct posts(());
638 }
639}
640
641pub struct DraftBuilder<St: draft_state::State, S: BosStr = DefaultStr> {
643 _state: PhantomData<fn() -> St>,
644 _fields: (
645 Option<S>,
646 Option<S>,
647 Option<Vec<Language>>,
648 Option<Vec<DisableRule<S>>>,
649 Option<Vec<draft::DraftPost<S>>>,
650 Option<Vec<DraftThreadgateAllowItem<S>>>,
651 ),
652 _type: PhantomData<fn() -> S>,
653}
654
655impl Draft<DefaultStr> {
656 pub fn new() -> DraftBuilder<draft_state::Empty, DefaultStr> {
658 DraftBuilder::new()
659 }
660}
661
662impl<S: BosStr> Draft<S> {
663 pub fn builder() -> DraftBuilder<draft_state::Empty, S> {
665 DraftBuilder::builder()
666 }
667}
668
669impl DraftBuilder<draft_state::Empty, DefaultStr> {
670 pub fn new() -> Self {
672 DraftBuilder {
673 _state: PhantomData,
674 _fields: (None, None, None, None, None, None),
675 _type: PhantomData,
676 }
677 }
678}
679
680impl<S: BosStr> DraftBuilder<draft_state::Empty, S> {
681 pub fn builder() -> Self {
683 DraftBuilder {
684 _state: PhantomData,
685 _fields: (None, None, None, None, None, None),
686 _type: PhantomData,
687 }
688 }
689}
690
691impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
692 pub fn device_id(mut self, value: impl Into<Option<S>>) -> Self {
694 self._fields.0 = value.into();
695 self
696 }
697 pub fn maybe_device_id(mut self, value: Option<S>) -> Self {
699 self._fields.0 = value;
700 self
701 }
702}
703
704impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
705 pub fn device_name(mut self, value: impl Into<Option<S>>) -> Self {
707 self._fields.1 = value.into();
708 self
709 }
710 pub fn maybe_device_name(mut self, value: Option<S>) -> Self {
712 self._fields.1 = value;
713 self
714 }
715}
716
717impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
718 pub fn langs(mut self, value: impl Into<Option<Vec<Language>>>) -> Self {
720 self._fields.2 = value.into();
721 self
722 }
723 pub fn maybe_langs(mut self, value: Option<Vec<Language>>) -> Self {
725 self._fields.2 = value;
726 self
727 }
728}
729
730impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
731 pub fn postgate_embedding_rules(
733 mut self,
734 value: impl Into<Option<Vec<DisableRule<S>>>>,
735 ) -> Self {
736 self._fields.3 = value.into();
737 self
738 }
739 pub fn maybe_postgate_embedding_rules(mut self, value: Option<Vec<DisableRule<S>>>) -> Self {
741 self._fields.3 = value;
742 self
743 }
744}
745
746impl<St, S: BosStr> DraftBuilder<St, S>
747where
748 St: draft_state::State,
749 St::Posts: draft_state::IsUnset,
750{
751 pub fn posts(
753 mut self,
754 value: impl Into<Vec<draft::DraftPost<S>>>,
755 ) -> DraftBuilder<draft_state::SetPosts<St>, S> {
756 self._fields.4 = Option::Some(value.into());
757 DraftBuilder {
758 _state: PhantomData,
759 _fields: self._fields,
760 _type: PhantomData,
761 }
762 }
763}
764
765impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
766 pub fn threadgate_allow(
768 mut self,
769 value: impl Into<Option<Vec<DraftThreadgateAllowItem<S>>>>,
770 ) -> Self {
771 self._fields.5 = value.into();
772 self
773 }
774 pub fn maybe_threadgate_allow(
776 mut self,
777 value: Option<Vec<DraftThreadgateAllowItem<S>>>,
778 ) -> Self {
779 self._fields.5 = value;
780 self
781 }
782}
783
784impl<St, S: BosStr> DraftBuilder<St, S>
785where
786 St: draft_state::State,
787 St::Posts: draft_state::IsSet,
788{
789 pub fn build(self) -> Draft<S> {
791 Draft {
792 device_id: self._fields.0,
793 device_name: self._fields.1,
794 langs: self._fields.2,
795 postgate_embedding_rules: self._fields.3,
796 posts: self._fields.4.unwrap(),
797 threadgate_allow: self._fields.5,
798 extra_data: Default::default(),
799 }
800 }
801 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Draft<S> {
803 Draft {
804 device_id: self._fields.0,
805 device_name: self._fields.1,
806 langs: self._fields.2,
807 postgate_embedding_rules: self._fields.3,
808 posts: self._fields.4.unwrap(),
809 threadgate_allow: self._fields.5,
810 extra_data: Some(extra_data),
811 }
812 }
813}
814
815fn lexicon_doc_app_bsky_draft_defs() -> LexiconDoc<'static> {
816 use alloc::collections::BTreeMap;
817 #[allow(unused_imports)]
818 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
819 use jacquard_lexicon::lexicon::*;
820 LexiconDoc {
821 lexicon: Lexicon::Lexicon1,
822 id: CowStr::new_static("app.bsky.draft.defs"),
823 defs: {
824 let mut map = BTreeMap::new();
825 map.insert(
826 SmolStr::new_static("draft"),
827 LexUserType::Object(LexObject {
828 description: Some(
829 CowStr::new_static("A draft containing an array of draft posts."),
830 ),
831 required: Some(vec![SmolStr::new_static("posts")]),
832 properties: {
833 #[allow(unused_mut)]
834 let mut map = BTreeMap::new();
835 map.insert(
836 SmolStr::new_static("deviceId"),
837 LexObjectProperty::String(LexString {
838 description: Some(
839 CowStr::new_static(
840 "UUIDv4 identifier of the device that created this draft.",
841 ),
842 ),
843 max_length: Some(100usize),
844 ..Default::default()
845 }),
846 );
847 map.insert(
848 SmolStr::new_static("deviceName"),
849 LexObjectProperty::String(LexString {
850 description: Some(
851 CowStr::new_static(
852 "The device and/or platform on which the draft was created.",
853 ),
854 ),
855 max_length: Some(100usize),
856 ..Default::default()
857 }),
858 );
859 map.insert(
860 SmolStr::new_static("langs"),
861 LexObjectProperty::Array(LexArray {
862 description: Some(
863 CowStr::new_static(
864 "Indicates human language of posts primary text content.",
865 ),
866 ),
867 items: LexArrayItem::String(LexString {
868 format: Some(LexStringFormat::Language),
869 ..Default::default()
870 }),
871 max_length: Some(3usize),
872 ..Default::default()
873 }),
874 );
875 map.insert(
876 SmolStr::new_static("postgateEmbeddingRules"),
877 LexObjectProperty::Array(LexArray {
878 description: Some(
879 CowStr::new_static(
880 "Embedding rules for the postgates to be created when this draft is published.",
881 ),
882 ),
883 items: LexArrayItem::Union(LexRefUnion {
884 refs: vec![
885 CowStr::new_static("app.bsky.feed.postgate#disableRule")
886 ],
887 ..Default::default()
888 }),
889 max_length: Some(5usize),
890 ..Default::default()
891 }),
892 );
893 map.insert(
894 SmolStr::new_static("posts"),
895 LexObjectProperty::Array(LexArray {
896 description: Some(
897 CowStr::new_static(
898 "Array of draft posts that compose this draft.",
899 ),
900 ),
901 items: LexArrayItem::Ref(LexRef {
902 r#ref: CowStr::new_static("#draftPost"),
903 ..Default::default()
904 }),
905 min_length: Some(1usize),
906 max_length: Some(100usize),
907 ..Default::default()
908 }),
909 );
910 map.insert(
911 SmolStr::new_static("threadgateAllow"),
912 LexObjectProperty::Array(LexArray {
913 description: Some(
914 CowStr::new_static(
915 "Allow-rules for the threadgate to be created when this draft is published.",
916 ),
917 ),
918 items: LexArrayItem::Union(LexRefUnion {
919 refs: vec![
920 CowStr::new_static("app.bsky.feed.threadgate#mentionRule"),
921 CowStr::new_static("app.bsky.feed.threadgate#followerRule"),
922 CowStr::new_static("app.bsky.feed.threadgate#followingRule"),
923 CowStr::new_static("app.bsky.feed.threadgate#listRule")
924 ],
925 ..Default::default()
926 }),
927 max_length: Some(5usize),
928 ..Default::default()
929 }),
930 );
931 map
932 },
933 ..Default::default()
934 }),
935 );
936 map.insert(
937 SmolStr::new_static("draftEmbedCaption"),
938 LexUserType::Object(LexObject {
939 required: Some(vec![
940 SmolStr::new_static("lang"),
941 SmolStr::new_static("content"),
942 ]),
943 properties: {
944 #[allow(unused_mut)]
945 let mut map = BTreeMap::new();
946 map.insert(
947 SmolStr::new_static("content"),
948 LexObjectProperty::String(LexString {
949 max_length: Some(10000usize),
950 ..Default::default()
951 }),
952 );
953 map.insert(
954 SmolStr::new_static("lang"),
955 LexObjectProperty::String(LexString {
956 format: Some(LexStringFormat::Language),
957 ..Default::default()
958 }),
959 );
960 map
961 },
962 ..Default::default()
963 }),
964 );
965 map.insert(
966 SmolStr::new_static("draftEmbedExternal"),
967 LexUserType::Object(LexObject {
968 required: Some(vec![SmolStr::new_static("uri")]),
969 properties: {
970 #[allow(unused_mut)]
971 let mut map = BTreeMap::new();
972 map.insert(
973 SmolStr::new_static("uri"),
974 LexObjectProperty::String(LexString {
975 format: Some(LexStringFormat::Uri),
976 ..Default::default()
977 }),
978 );
979 map
980 },
981 ..Default::default()
982 }),
983 );
984 map.insert(
985 SmolStr::new_static("draftEmbedGallery"),
986 LexUserType::Object(LexObject {
987 required: Some(vec![SmolStr::new_static("items")]),
988 properties: {
989 #[allow(unused_mut)]
990 let mut map = BTreeMap::new();
991 map.insert(
992 SmolStr::new_static("items"),
993 LexObjectProperty::Ref(LexRef {
994 r#ref: CowStr::new_static("#draftEmbedGalleryItems"),
995 ..Default::default()
996 }),
997 );
998 map
999 },
1000 ..Default::default()
1001 }),
1002 );
1003 map.insert(
1004 SmolStr::new_static("draftEmbedGalleryItems"),
1005 LexUserType::Array(LexArray {
1006 items: LexArrayItem::Union(LexRefUnion {
1007 refs: vec![CowStr::new_static("#draftEmbedImage")],
1008 ..Default::default()
1009 }),
1010 max_length: Some(20usize),
1011 ..Default::default()
1012 }),
1013 );
1014 map.insert(
1015 SmolStr::new_static("draftEmbedImage"),
1016 LexUserType::Object(LexObject {
1017 required: Some(vec![SmolStr::new_static("localRef")]),
1018 properties: {
1019 #[allow(unused_mut)]
1020 let mut map = BTreeMap::new();
1021 map.insert(
1022 SmolStr::new_static("alt"),
1023 LexObjectProperty::String(LexString {
1024 max_graphemes: Some(2000usize),
1025 ..Default::default()
1026 }),
1027 );
1028 map.insert(
1029 SmolStr::new_static("localRef"),
1030 LexObjectProperty::Ref(LexRef {
1031 r#ref: CowStr::new_static("#draftEmbedLocalRef"),
1032 ..Default::default()
1033 }),
1034 );
1035 map
1036 },
1037 ..Default::default()
1038 }),
1039 );
1040 map.insert(
1041 SmolStr::new_static("draftEmbedLocalRef"),
1042 LexUserType::Object(LexObject {
1043 required: Some(vec![SmolStr::new_static("path")]),
1044 properties: {
1045 #[allow(unused_mut)]
1046 let mut map = BTreeMap::new();
1047 map.insert(
1048 SmolStr::new_static("path"),
1049 LexObjectProperty::String(LexString {
1050 description: Some(
1051 CowStr::new_static(
1052 "Local, on-device ref to file to be embedded. Embeds are currently device-bound for drafts.",
1053 ),
1054 ),
1055 min_length: Some(1usize),
1056 max_length: Some(1024usize),
1057 ..Default::default()
1058 }),
1059 );
1060 map
1061 },
1062 ..Default::default()
1063 }),
1064 );
1065 map.insert(
1066 SmolStr::new_static("draftEmbedRecord"),
1067 LexUserType::Object(LexObject {
1068 required: Some(vec![SmolStr::new_static("record")]),
1069 properties: {
1070 #[allow(unused_mut)]
1071 let mut map = BTreeMap::new();
1072 map.insert(
1073 SmolStr::new_static("record"),
1074 LexObjectProperty::Ref(LexRef {
1075 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
1076 ..Default::default()
1077 }),
1078 );
1079 map
1080 },
1081 ..Default::default()
1082 }),
1083 );
1084 map.insert(
1085 SmolStr::new_static("draftEmbedVideo"),
1086 LexUserType::Object(LexObject {
1087 required: Some(vec![SmolStr::new_static("localRef")]),
1088 properties: {
1089 #[allow(unused_mut)]
1090 let mut map = BTreeMap::new();
1091 map.insert(
1092 SmolStr::new_static("alt"),
1093 LexObjectProperty::String(LexString {
1094 max_graphemes: Some(2000usize),
1095 ..Default::default()
1096 }),
1097 );
1098 map.insert(
1099 SmolStr::new_static("captions"),
1100 LexObjectProperty::Array(LexArray {
1101 items: LexArrayItem::Ref(LexRef {
1102 r#ref: CowStr::new_static("#draftEmbedCaption"),
1103 ..Default::default()
1104 }),
1105 max_length: Some(20usize),
1106 ..Default::default()
1107 }),
1108 );
1109 map.insert(
1110 SmolStr::new_static("localRef"),
1111 LexObjectProperty::Ref(LexRef {
1112 r#ref: CowStr::new_static("#draftEmbedLocalRef"),
1113 ..Default::default()
1114 }),
1115 );
1116 map
1117 },
1118 ..Default::default()
1119 }),
1120 );
1121 map.insert(
1122 SmolStr::new_static("draftPost"),
1123 LexUserType::Object(LexObject {
1124 description: Some(
1125 CowStr::new_static("One of the posts that compose a draft."),
1126 ),
1127 required: Some(vec![SmolStr::new_static("text")]),
1128 properties: {
1129 #[allow(unused_mut)]
1130 let mut map = BTreeMap::new();
1131 map.insert(
1132 SmolStr::new_static("embedExternals"),
1133 LexObjectProperty::Array(LexArray {
1134 items: LexArrayItem::Ref(LexRef {
1135 r#ref: CowStr::new_static("#draftEmbedExternal"),
1136 ..Default::default()
1137 }),
1138 max_length: Some(1usize),
1139 ..Default::default()
1140 }),
1141 );
1142 map.insert(
1143 SmolStr::new_static("embedGallery"),
1144 LexObjectProperty::Ref(LexRef {
1145 r#ref: CowStr::new_static("#draftEmbedGallery"),
1146 ..Default::default()
1147 }),
1148 );
1149 map.insert(
1150 SmolStr::new_static("embedImages"),
1151 LexObjectProperty::Array(LexArray {
1152 items: LexArrayItem::Ref(LexRef {
1153 r#ref: CowStr::new_static("#draftEmbedImage"),
1154 ..Default::default()
1155 }),
1156 max_length: Some(4usize),
1157 ..Default::default()
1158 }),
1159 );
1160 map.insert(
1161 SmolStr::new_static("embedRecords"),
1162 LexObjectProperty::Array(LexArray {
1163 items: LexArrayItem::Ref(LexRef {
1164 r#ref: CowStr::new_static("#draftEmbedRecord"),
1165 ..Default::default()
1166 }),
1167 max_length: Some(1usize),
1168 ..Default::default()
1169 }),
1170 );
1171 map.insert(
1172 SmolStr::new_static("embedVideos"),
1173 LexObjectProperty::Array(LexArray {
1174 items: LexArrayItem::Ref(LexRef {
1175 r#ref: CowStr::new_static("#draftEmbedVideo"),
1176 ..Default::default()
1177 }),
1178 max_length: Some(1usize),
1179 ..Default::default()
1180 }),
1181 );
1182 map.insert(
1183 SmolStr::new_static("labels"),
1184 LexObjectProperty::Union(LexRefUnion {
1185 description: Some(
1186 CowStr::new_static(
1187 "Self-label values for this post. Effectively content warnings.",
1188 ),
1189 ),
1190 refs: vec![
1191 CowStr::new_static("com.atproto.label.defs#selfLabels")
1192 ],
1193 ..Default::default()
1194 }),
1195 );
1196 map.insert(
1197 SmolStr::new_static("text"),
1198 LexObjectProperty::String(LexString {
1199 description: Some(
1200 CowStr::new_static(
1201 "The primary post content. It has a higher limit than post contents to allow storing a larger text that can later be refined into smaller posts.",
1202 ),
1203 ),
1204 max_length: Some(10000usize),
1205 max_graphemes: Some(1000usize),
1206 ..Default::default()
1207 }),
1208 );
1209 map
1210 },
1211 ..Default::default()
1212 }),
1213 );
1214 map.insert(
1215 SmolStr::new_static("draftView"),
1216 LexUserType::Object(LexObject {
1217 description: Some(CowStr::new_static("View to present drafts data to users.")),
1218 required: Some(vec![
1219 SmolStr::new_static("id"),
1220 SmolStr::new_static("draft"),
1221 SmolStr::new_static("createdAt"),
1222 SmolStr::new_static("updatedAt"),
1223 ]),
1224 properties: {
1225 #[allow(unused_mut)]
1226 let mut map = BTreeMap::new();
1227 map.insert(
1228 SmolStr::new_static("createdAt"),
1229 LexObjectProperty::String(LexString {
1230 description: Some(CowStr::new_static(
1231 "The time the draft was created.",
1232 )),
1233 format: Some(LexStringFormat::Datetime),
1234 ..Default::default()
1235 }),
1236 );
1237 map.insert(
1238 SmolStr::new_static("draft"),
1239 LexObjectProperty::Ref(LexRef {
1240 r#ref: CowStr::new_static("#draft"),
1241 ..Default::default()
1242 }),
1243 );
1244 map.insert(
1245 SmolStr::new_static("id"),
1246 LexObjectProperty::String(LexString {
1247 description: Some(CowStr::new_static(
1248 "A TID to be used as a draft identifier.",
1249 )),
1250 format: Some(LexStringFormat::Tid),
1251 ..Default::default()
1252 }),
1253 );
1254 map.insert(
1255 SmolStr::new_static("updatedAt"),
1256 LexObjectProperty::String(LexString {
1257 description: Some(CowStr::new_static(
1258 "The time the draft was last updated.",
1259 )),
1260 format: Some(LexStringFormat::Datetime),
1261 ..Default::default()
1262 }),
1263 );
1264 map
1265 },
1266 ..Default::default()
1267 }),
1268 );
1269 map.insert(
1270 SmolStr::new_static("draftWithId"),
1271 LexUserType::Object(LexObject {
1272 description: Some(
1273 CowStr::new_static(
1274 "A draft with an identifier, used to store drafts in private storage (stash).",
1275 ),
1276 ),
1277 required: Some(
1278 vec![SmolStr::new_static("id"), SmolStr::new_static("draft")],
1279 ),
1280 properties: {
1281 #[allow(unused_mut)]
1282 let mut map = BTreeMap::new();
1283 map.insert(
1284 SmolStr::new_static("draft"),
1285 LexObjectProperty::Ref(LexRef {
1286 r#ref: CowStr::new_static("#draft"),
1287 ..Default::default()
1288 }),
1289 );
1290 map.insert(
1291 SmolStr::new_static("id"),
1292 LexObjectProperty::String(LexString {
1293 description: Some(
1294 CowStr::new_static(
1295 "A TID to be used as a draft identifier.",
1296 ),
1297 ),
1298 format: Some(LexStringFormat::Tid),
1299 ..Default::default()
1300 }),
1301 );
1302 map
1303 },
1304 ..Default::default()
1305 }),
1306 );
1307 map
1308 },
1309 ..Default::default()
1310 }
1311}
1312
1313pub mod draft_embed_caption_state {
1314
1315 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
1316 #[allow(unused)]
1317 use ::core::marker::PhantomData;
1318 mod sealed {
1319 pub trait Sealed {}
1320 }
1321 pub trait State: sealed::Sealed {
1323 type Content;
1324 type Lang;
1325 }
1326 pub struct Empty(());
1328 impl sealed::Sealed for Empty {}
1329 impl State for Empty {
1330 type Content = Unset;
1331 type Lang = Unset;
1332 }
1333 pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
1335 impl<St: State> sealed::Sealed for SetContent<St> {}
1336 impl<St: State> State for SetContent<St> {
1337 type Content = Set<members::content>;
1338 type Lang = St::Lang;
1339 }
1340 pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
1342 impl<St: State> sealed::Sealed for SetLang<St> {}
1343 impl<St: State> State for SetLang<St> {
1344 type Content = St::Content;
1345 type Lang = Set<members::lang>;
1346 }
1347 #[allow(non_camel_case_types)]
1349 pub mod members {
1350 pub struct content(());
1352 pub struct lang(());
1354 }
1355}
1356
1357pub struct DraftEmbedCaptionBuilder<St: draft_embed_caption_state::State, S: BosStr = DefaultStr> {
1359 _state: PhantomData<fn() -> St>,
1360 _fields: (Option<S>, Option<Language>),
1361 _type: PhantomData<fn() -> S>,
1362}
1363
1364impl DraftEmbedCaption<DefaultStr> {
1365 pub fn new() -> DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, DefaultStr> {
1367 DraftEmbedCaptionBuilder::new()
1368 }
1369}
1370
1371impl<S: BosStr> DraftEmbedCaption<S> {
1372 pub fn builder() -> DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, S> {
1374 DraftEmbedCaptionBuilder::builder()
1375 }
1376}
1377
1378impl DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, DefaultStr> {
1379 pub fn new() -> Self {
1381 DraftEmbedCaptionBuilder {
1382 _state: PhantomData,
1383 _fields: (None, None),
1384 _type: PhantomData,
1385 }
1386 }
1387}
1388
1389impl<S: BosStr> DraftEmbedCaptionBuilder<draft_embed_caption_state::Empty, S> {
1390 pub fn builder() -> Self {
1392 DraftEmbedCaptionBuilder {
1393 _state: PhantomData,
1394 _fields: (None, None),
1395 _type: PhantomData,
1396 }
1397 }
1398}
1399
1400impl<St, S: BosStr> DraftEmbedCaptionBuilder<St, S>
1401where
1402 St: draft_embed_caption_state::State,
1403 St::Content: draft_embed_caption_state::IsUnset,
1404{
1405 pub fn content(
1407 mut self,
1408 value: impl Into<S>,
1409 ) -> DraftEmbedCaptionBuilder<draft_embed_caption_state::SetContent<St>, S> {
1410 self._fields.0 = Option::Some(value.into());
1411 DraftEmbedCaptionBuilder {
1412 _state: PhantomData,
1413 _fields: self._fields,
1414 _type: PhantomData,
1415 }
1416 }
1417}
1418
1419impl<St, S: BosStr> DraftEmbedCaptionBuilder<St, S>
1420where
1421 St: draft_embed_caption_state::State,
1422 St::Lang: draft_embed_caption_state::IsUnset,
1423{
1424 pub fn lang(
1426 mut self,
1427 value: impl Into<Language>,
1428 ) -> DraftEmbedCaptionBuilder<draft_embed_caption_state::SetLang<St>, S> {
1429 self._fields.1 = Option::Some(value.into());
1430 DraftEmbedCaptionBuilder {
1431 _state: PhantomData,
1432 _fields: self._fields,
1433 _type: PhantomData,
1434 }
1435 }
1436}
1437
1438impl<St, S: BosStr> DraftEmbedCaptionBuilder<St, S>
1439where
1440 St: draft_embed_caption_state::State,
1441 St::Content: draft_embed_caption_state::IsSet,
1442 St::Lang: draft_embed_caption_state::IsSet,
1443{
1444 pub fn build(self) -> DraftEmbedCaption<S> {
1446 DraftEmbedCaption {
1447 content: self._fields.0.unwrap(),
1448 lang: self._fields.1.unwrap(),
1449 extra_data: Default::default(),
1450 }
1451 }
1452 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedCaption<S> {
1454 DraftEmbedCaption {
1455 content: self._fields.0.unwrap(),
1456 lang: self._fields.1.unwrap(),
1457 extra_data: Some(extra_data),
1458 }
1459 }
1460}
1461
1462pub mod draft_embed_external_state {
1463
1464 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
1465 #[allow(unused)]
1466 use ::core::marker::PhantomData;
1467 mod sealed {
1468 pub trait Sealed {}
1469 }
1470 pub trait State: sealed::Sealed {
1472 type Uri;
1473 }
1474 pub struct Empty(());
1476 impl sealed::Sealed for Empty {}
1477 impl State for Empty {
1478 type Uri = Unset;
1479 }
1480 pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
1482 impl<St: State> sealed::Sealed for SetUri<St> {}
1483 impl<St: State> State for SetUri<St> {
1484 type Uri = Set<members::uri>;
1485 }
1486 #[allow(non_camel_case_types)]
1488 pub mod members {
1489 pub struct uri(());
1491 }
1492}
1493
1494pub struct DraftEmbedExternalBuilder<St: draft_embed_external_state::State, S: BosStr = DefaultStr>
1496{
1497 _state: PhantomData<fn() -> St>,
1498 _fields: (Option<UriValue<S>>,),
1499 _type: PhantomData<fn() -> S>,
1500}
1501
1502impl DraftEmbedExternal<DefaultStr> {
1503 pub fn new() -> DraftEmbedExternalBuilder<draft_embed_external_state::Empty, DefaultStr> {
1505 DraftEmbedExternalBuilder::new()
1506 }
1507}
1508
1509impl<S: BosStr> DraftEmbedExternal<S> {
1510 pub fn builder() -> DraftEmbedExternalBuilder<draft_embed_external_state::Empty, S> {
1512 DraftEmbedExternalBuilder::builder()
1513 }
1514}
1515
1516impl DraftEmbedExternalBuilder<draft_embed_external_state::Empty, DefaultStr> {
1517 pub fn new() -> Self {
1519 DraftEmbedExternalBuilder {
1520 _state: PhantomData,
1521 _fields: (None,),
1522 _type: PhantomData,
1523 }
1524 }
1525}
1526
1527impl<S: BosStr> DraftEmbedExternalBuilder<draft_embed_external_state::Empty, S> {
1528 pub fn builder() -> Self {
1530 DraftEmbedExternalBuilder {
1531 _state: PhantomData,
1532 _fields: (None,),
1533 _type: PhantomData,
1534 }
1535 }
1536}
1537
1538impl<St, S: BosStr> DraftEmbedExternalBuilder<St, S>
1539where
1540 St: draft_embed_external_state::State,
1541 St::Uri: draft_embed_external_state::IsUnset,
1542{
1543 pub fn uri(
1545 mut self,
1546 value: impl Into<UriValue<S>>,
1547 ) -> DraftEmbedExternalBuilder<draft_embed_external_state::SetUri<St>, S> {
1548 self._fields.0 = Option::Some(value.into());
1549 DraftEmbedExternalBuilder {
1550 _state: PhantomData,
1551 _fields: self._fields,
1552 _type: PhantomData,
1553 }
1554 }
1555}
1556
1557impl<St, S: BosStr> DraftEmbedExternalBuilder<St, S>
1558where
1559 St: draft_embed_external_state::State,
1560 St::Uri: draft_embed_external_state::IsSet,
1561{
1562 pub fn build(self) -> DraftEmbedExternal<S> {
1564 DraftEmbedExternal {
1565 uri: self._fields.0.unwrap(),
1566 extra_data: Default::default(),
1567 }
1568 }
1569 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedExternal<S> {
1571 DraftEmbedExternal {
1572 uri: self._fields.0.unwrap(),
1573 extra_data: Some(extra_data),
1574 }
1575 }
1576}
1577
1578pub mod draft_embed_gallery_state {
1579
1580 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
1581 #[allow(unused)]
1582 use ::core::marker::PhantomData;
1583 mod sealed {
1584 pub trait Sealed {}
1585 }
1586 pub trait State: sealed::Sealed {
1588 type Items;
1589 }
1590 pub struct Empty(());
1592 impl sealed::Sealed for Empty {}
1593 impl State for Empty {
1594 type Items = Unset;
1595 }
1596 pub struct SetItems<St: State = Empty>(PhantomData<fn() -> St>);
1598 impl<St: State> sealed::Sealed for SetItems<St> {}
1599 impl<St: State> State for SetItems<St> {
1600 type Items = Set<members::items>;
1601 }
1602 #[allow(non_camel_case_types)]
1604 pub mod members {
1605 pub struct items(());
1607 }
1608}
1609
1610pub struct DraftEmbedGalleryBuilder<St: draft_embed_gallery_state::State, S: BosStr = DefaultStr> {
1612 _state: PhantomData<fn() -> St>,
1613 _fields: (Option<draft::DraftEmbedGalleryItems<S>>,),
1614 _type: PhantomData<fn() -> S>,
1615}
1616
1617impl DraftEmbedGallery<DefaultStr> {
1618 pub fn new() -> DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, DefaultStr> {
1620 DraftEmbedGalleryBuilder::new()
1621 }
1622}
1623
1624impl<S: BosStr> DraftEmbedGallery<S> {
1625 pub fn builder() -> DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, S> {
1627 DraftEmbedGalleryBuilder::builder()
1628 }
1629}
1630
1631impl DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, DefaultStr> {
1632 pub fn new() -> Self {
1634 DraftEmbedGalleryBuilder {
1635 _state: PhantomData,
1636 _fields: (None,),
1637 _type: PhantomData,
1638 }
1639 }
1640}
1641
1642impl<S: BosStr> DraftEmbedGalleryBuilder<draft_embed_gallery_state::Empty, S> {
1643 pub fn builder() -> Self {
1645 DraftEmbedGalleryBuilder {
1646 _state: PhantomData,
1647 _fields: (None,),
1648 _type: PhantomData,
1649 }
1650 }
1651}
1652
1653impl<St, S: BosStr> DraftEmbedGalleryBuilder<St, S>
1654where
1655 St: draft_embed_gallery_state::State,
1656 St::Items: draft_embed_gallery_state::IsUnset,
1657{
1658 pub fn items(
1660 mut self,
1661 value: impl Into<draft::DraftEmbedGalleryItems<S>>,
1662 ) -> DraftEmbedGalleryBuilder<draft_embed_gallery_state::SetItems<St>, S> {
1663 self._fields.0 = Option::Some(value.into());
1664 DraftEmbedGalleryBuilder {
1665 _state: PhantomData,
1666 _fields: self._fields,
1667 _type: PhantomData,
1668 }
1669 }
1670}
1671
1672impl<St, S: BosStr> DraftEmbedGalleryBuilder<St, S>
1673where
1674 St: draft_embed_gallery_state::State,
1675 St::Items: draft_embed_gallery_state::IsSet,
1676{
1677 pub fn build(self) -> DraftEmbedGallery<S> {
1679 DraftEmbedGallery {
1680 items: self._fields.0.unwrap(),
1681 extra_data: Default::default(),
1682 }
1683 }
1684 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedGallery<S> {
1686 DraftEmbedGallery {
1687 items: self._fields.0.unwrap(),
1688 extra_data: Some(extra_data),
1689 }
1690 }
1691}
1692
1693pub mod draft_embed_image_state {
1694
1695 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
1696 #[allow(unused)]
1697 use ::core::marker::PhantomData;
1698 mod sealed {
1699 pub trait Sealed {}
1700 }
1701 pub trait State: sealed::Sealed {
1703 type LocalRef;
1704 }
1705 pub struct Empty(());
1707 impl sealed::Sealed for Empty {}
1708 impl State for Empty {
1709 type LocalRef = Unset;
1710 }
1711 pub struct SetLocalRef<St: State = Empty>(PhantomData<fn() -> St>);
1713 impl<St: State> sealed::Sealed for SetLocalRef<St> {}
1714 impl<St: State> State for SetLocalRef<St> {
1715 type LocalRef = Set<members::local_ref>;
1716 }
1717 #[allow(non_camel_case_types)]
1719 pub mod members {
1720 pub struct local_ref(());
1722 }
1723}
1724
1725pub struct DraftEmbedImageBuilder<St: draft_embed_image_state::State, S: BosStr = DefaultStr> {
1727 _state: PhantomData<fn() -> St>,
1728 _fields: (Option<S>, Option<draft::DraftEmbedLocalRef<S>>),
1729 _type: PhantomData<fn() -> S>,
1730}
1731
1732impl DraftEmbedImage<DefaultStr> {
1733 pub fn new() -> DraftEmbedImageBuilder<draft_embed_image_state::Empty, DefaultStr> {
1735 DraftEmbedImageBuilder::new()
1736 }
1737}
1738
1739impl<S: BosStr> DraftEmbedImage<S> {
1740 pub fn builder() -> DraftEmbedImageBuilder<draft_embed_image_state::Empty, S> {
1742 DraftEmbedImageBuilder::builder()
1743 }
1744}
1745
1746impl DraftEmbedImageBuilder<draft_embed_image_state::Empty, DefaultStr> {
1747 pub fn new() -> Self {
1749 DraftEmbedImageBuilder {
1750 _state: PhantomData,
1751 _fields: (None, None),
1752 _type: PhantomData,
1753 }
1754 }
1755}
1756
1757impl<S: BosStr> DraftEmbedImageBuilder<draft_embed_image_state::Empty, S> {
1758 pub fn builder() -> Self {
1760 DraftEmbedImageBuilder {
1761 _state: PhantomData,
1762 _fields: (None, None),
1763 _type: PhantomData,
1764 }
1765 }
1766}
1767
1768impl<St: draft_embed_image_state::State, S: BosStr> DraftEmbedImageBuilder<St, S> {
1769 pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
1771 self._fields.0 = value.into();
1772 self
1773 }
1774 pub fn maybe_alt(mut self, value: Option<S>) -> Self {
1776 self._fields.0 = value;
1777 self
1778 }
1779}
1780
1781impl<St, S: BosStr> DraftEmbedImageBuilder<St, S>
1782where
1783 St: draft_embed_image_state::State,
1784 St::LocalRef: draft_embed_image_state::IsUnset,
1785{
1786 pub fn local_ref(
1788 mut self,
1789 value: impl Into<draft::DraftEmbedLocalRef<S>>,
1790 ) -> DraftEmbedImageBuilder<draft_embed_image_state::SetLocalRef<St>, S> {
1791 self._fields.1 = Option::Some(value.into());
1792 DraftEmbedImageBuilder {
1793 _state: PhantomData,
1794 _fields: self._fields,
1795 _type: PhantomData,
1796 }
1797 }
1798}
1799
1800impl<St, S: BosStr> DraftEmbedImageBuilder<St, S>
1801where
1802 St: draft_embed_image_state::State,
1803 St::LocalRef: draft_embed_image_state::IsSet,
1804{
1805 pub fn build(self) -> DraftEmbedImage<S> {
1807 DraftEmbedImage {
1808 alt: self._fields.0,
1809 local_ref: self._fields.1.unwrap(),
1810 extra_data: Default::default(),
1811 }
1812 }
1813 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedImage<S> {
1815 DraftEmbedImage {
1816 alt: self._fields.0,
1817 local_ref: self._fields.1.unwrap(),
1818 extra_data: Some(extra_data),
1819 }
1820 }
1821}
1822
1823pub mod draft_embed_record_state {
1824
1825 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
1826 #[allow(unused)]
1827 use ::core::marker::PhantomData;
1828 mod sealed {
1829 pub trait Sealed {}
1830 }
1831 pub trait State: sealed::Sealed {
1833 type Record;
1834 }
1835 pub struct Empty(());
1837 impl sealed::Sealed for Empty {}
1838 impl State for Empty {
1839 type Record = Unset;
1840 }
1841 pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
1843 impl<St: State> sealed::Sealed for SetRecord<St> {}
1844 impl<St: State> State for SetRecord<St> {
1845 type Record = Set<members::record>;
1846 }
1847 #[allow(non_camel_case_types)]
1849 pub mod members {
1850 pub struct record(());
1852 }
1853}
1854
1855pub struct DraftEmbedRecordBuilder<St: draft_embed_record_state::State, S: BosStr = DefaultStr> {
1857 _state: PhantomData<fn() -> St>,
1858 _fields: (Option<StrongRef<S>>,),
1859 _type: PhantomData<fn() -> S>,
1860}
1861
1862impl DraftEmbedRecord<DefaultStr> {
1863 pub fn new() -> DraftEmbedRecordBuilder<draft_embed_record_state::Empty, DefaultStr> {
1865 DraftEmbedRecordBuilder::new()
1866 }
1867}
1868
1869impl<S: BosStr> DraftEmbedRecord<S> {
1870 pub fn builder() -> DraftEmbedRecordBuilder<draft_embed_record_state::Empty, S> {
1872 DraftEmbedRecordBuilder::builder()
1873 }
1874}
1875
1876impl DraftEmbedRecordBuilder<draft_embed_record_state::Empty, DefaultStr> {
1877 pub fn new() -> Self {
1879 DraftEmbedRecordBuilder {
1880 _state: PhantomData,
1881 _fields: (None,),
1882 _type: PhantomData,
1883 }
1884 }
1885}
1886
1887impl<S: BosStr> DraftEmbedRecordBuilder<draft_embed_record_state::Empty, S> {
1888 pub fn builder() -> Self {
1890 DraftEmbedRecordBuilder {
1891 _state: PhantomData,
1892 _fields: (None,),
1893 _type: PhantomData,
1894 }
1895 }
1896}
1897
1898impl<St, S: BosStr> DraftEmbedRecordBuilder<St, S>
1899where
1900 St: draft_embed_record_state::State,
1901 St::Record: draft_embed_record_state::IsUnset,
1902{
1903 pub fn record(
1905 mut self,
1906 value: impl Into<StrongRef<S>>,
1907 ) -> DraftEmbedRecordBuilder<draft_embed_record_state::SetRecord<St>, S> {
1908 self._fields.0 = Option::Some(value.into());
1909 DraftEmbedRecordBuilder {
1910 _state: PhantomData,
1911 _fields: self._fields,
1912 _type: PhantomData,
1913 }
1914 }
1915}
1916
1917impl<St, S: BosStr> DraftEmbedRecordBuilder<St, S>
1918where
1919 St: draft_embed_record_state::State,
1920 St::Record: draft_embed_record_state::IsSet,
1921{
1922 pub fn build(self) -> DraftEmbedRecord<S> {
1924 DraftEmbedRecord {
1925 record: self._fields.0.unwrap(),
1926 extra_data: Default::default(),
1927 }
1928 }
1929 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedRecord<S> {
1931 DraftEmbedRecord {
1932 record: self._fields.0.unwrap(),
1933 extra_data: Some(extra_data),
1934 }
1935 }
1936}
1937
1938pub mod draft_embed_video_state {
1939
1940 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
1941 #[allow(unused)]
1942 use ::core::marker::PhantomData;
1943 mod sealed {
1944 pub trait Sealed {}
1945 }
1946 pub trait State: sealed::Sealed {
1948 type LocalRef;
1949 }
1950 pub struct Empty(());
1952 impl sealed::Sealed for Empty {}
1953 impl State for Empty {
1954 type LocalRef = Unset;
1955 }
1956 pub struct SetLocalRef<St: State = Empty>(PhantomData<fn() -> St>);
1958 impl<St: State> sealed::Sealed for SetLocalRef<St> {}
1959 impl<St: State> State for SetLocalRef<St> {
1960 type LocalRef = Set<members::local_ref>;
1961 }
1962 #[allow(non_camel_case_types)]
1964 pub mod members {
1965 pub struct local_ref(());
1967 }
1968}
1969
1970pub struct DraftEmbedVideoBuilder<St: draft_embed_video_state::State, S: BosStr = DefaultStr> {
1972 _state: PhantomData<fn() -> St>,
1973 _fields: (
1974 Option<S>,
1975 Option<Vec<draft::DraftEmbedCaption<S>>>,
1976 Option<draft::DraftEmbedLocalRef<S>>,
1977 ),
1978 _type: PhantomData<fn() -> S>,
1979}
1980
1981impl DraftEmbedVideo<DefaultStr> {
1982 pub fn new() -> DraftEmbedVideoBuilder<draft_embed_video_state::Empty, DefaultStr> {
1984 DraftEmbedVideoBuilder::new()
1985 }
1986}
1987
1988impl<S: BosStr> DraftEmbedVideo<S> {
1989 pub fn builder() -> DraftEmbedVideoBuilder<draft_embed_video_state::Empty, S> {
1991 DraftEmbedVideoBuilder::builder()
1992 }
1993}
1994
1995impl DraftEmbedVideoBuilder<draft_embed_video_state::Empty, DefaultStr> {
1996 pub fn new() -> Self {
1998 DraftEmbedVideoBuilder {
1999 _state: PhantomData,
2000 _fields: (None, None, None),
2001 _type: PhantomData,
2002 }
2003 }
2004}
2005
2006impl<S: BosStr> DraftEmbedVideoBuilder<draft_embed_video_state::Empty, S> {
2007 pub fn builder() -> Self {
2009 DraftEmbedVideoBuilder {
2010 _state: PhantomData,
2011 _fields: (None, None, None),
2012 _type: PhantomData,
2013 }
2014 }
2015}
2016
2017impl<St: draft_embed_video_state::State, S: BosStr> DraftEmbedVideoBuilder<St, S> {
2018 pub fn alt(mut self, value: impl Into<Option<S>>) -> Self {
2020 self._fields.0 = value.into();
2021 self
2022 }
2023 pub fn maybe_alt(mut self, value: Option<S>) -> Self {
2025 self._fields.0 = value;
2026 self
2027 }
2028}
2029
2030impl<St: draft_embed_video_state::State, S: BosStr> DraftEmbedVideoBuilder<St, S> {
2031 pub fn captions(mut self, value: impl Into<Option<Vec<draft::DraftEmbedCaption<S>>>>) -> Self {
2033 self._fields.1 = value.into();
2034 self
2035 }
2036 pub fn maybe_captions(mut self, value: Option<Vec<draft::DraftEmbedCaption<S>>>) -> Self {
2038 self._fields.1 = value;
2039 self
2040 }
2041}
2042
2043impl<St, S: BosStr> DraftEmbedVideoBuilder<St, S>
2044where
2045 St: draft_embed_video_state::State,
2046 St::LocalRef: draft_embed_video_state::IsUnset,
2047{
2048 pub fn local_ref(
2050 mut self,
2051 value: impl Into<draft::DraftEmbedLocalRef<S>>,
2052 ) -> DraftEmbedVideoBuilder<draft_embed_video_state::SetLocalRef<St>, S> {
2053 self._fields.2 = Option::Some(value.into());
2054 DraftEmbedVideoBuilder {
2055 _state: PhantomData,
2056 _fields: self._fields,
2057 _type: PhantomData,
2058 }
2059 }
2060}
2061
2062impl<St, S: BosStr> DraftEmbedVideoBuilder<St, S>
2063where
2064 St: draft_embed_video_state::State,
2065 St::LocalRef: draft_embed_video_state::IsSet,
2066{
2067 pub fn build(self) -> DraftEmbedVideo<S> {
2069 DraftEmbedVideo {
2070 alt: self._fields.0,
2071 captions: self._fields.1,
2072 local_ref: self._fields.2.unwrap(),
2073 extra_data: Default::default(),
2074 }
2075 }
2076 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftEmbedVideo<S> {
2078 DraftEmbedVideo {
2079 alt: self._fields.0,
2080 captions: self._fields.1,
2081 local_ref: self._fields.2.unwrap(),
2082 extra_data: Some(extra_data),
2083 }
2084 }
2085}
2086
2087pub mod draft_view_state {
2088
2089 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
2090 #[allow(unused)]
2091 use ::core::marker::PhantomData;
2092 mod sealed {
2093 pub trait Sealed {}
2094 }
2095 pub trait State: sealed::Sealed {
2097 type CreatedAt;
2098 type Draft;
2099 type Id;
2100 type UpdatedAt;
2101 }
2102 pub struct Empty(());
2104 impl sealed::Sealed for Empty {}
2105 impl State for Empty {
2106 type CreatedAt = Unset;
2107 type Draft = Unset;
2108 type Id = Unset;
2109 type UpdatedAt = Unset;
2110 }
2111 pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
2113 impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
2114 impl<St: State> State for SetCreatedAt<St> {
2115 type CreatedAt = Set<members::created_at>;
2116 type Draft = St::Draft;
2117 type Id = St::Id;
2118 type UpdatedAt = St::UpdatedAt;
2119 }
2120 pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
2122 impl<St: State> sealed::Sealed for SetDraft<St> {}
2123 impl<St: State> State for SetDraft<St> {
2124 type CreatedAt = St::CreatedAt;
2125 type Draft = Set<members::draft>;
2126 type Id = St::Id;
2127 type UpdatedAt = St::UpdatedAt;
2128 }
2129 pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
2131 impl<St: State> sealed::Sealed for SetId<St> {}
2132 impl<St: State> State for SetId<St> {
2133 type CreatedAt = St::CreatedAt;
2134 type Draft = St::Draft;
2135 type Id = Set<members::id>;
2136 type UpdatedAt = St::UpdatedAt;
2137 }
2138 pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
2140 impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
2141 impl<St: State> State for SetUpdatedAt<St> {
2142 type CreatedAt = St::CreatedAt;
2143 type Draft = St::Draft;
2144 type Id = St::Id;
2145 type UpdatedAt = Set<members::updated_at>;
2146 }
2147 #[allow(non_camel_case_types)]
2149 pub mod members {
2150 pub struct created_at(());
2152 pub struct draft(());
2154 pub struct id(());
2156 pub struct updated_at(());
2158 }
2159}
2160
2161pub struct DraftViewBuilder<St: draft_view_state::State, S: BosStr = DefaultStr> {
2163 _state: PhantomData<fn() -> St>,
2164 _fields: (
2165 Option<Datetime>,
2166 Option<draft::Draft<S>>,
2167 Option<Tid>,
2168 Option<Datetime>,
2169 ),
2170 _type: PhantomData<fn() -> S>,
2171}
2172
2173impl DraftView<DefaultStr> {
2174 pub fn new() -> DraftViewBuilder<draft_view_state::Empty, DefaultStr> {
2176 DraftViewBuilder::new()
2177 }
2178}
2179
2180impl<S: BosStr> DraftView<S> {
2181 pub fn builder() -> DraftViewBuilder<draft_view_state::Empty, S> {
2183 DraftViewBuilder::builder()
2184 }
2185}
2186
2187impl DraftViewBuilder<draft_view_state::Empty, DefaultStr> {
2188 pub fn new() -> Self {
2190 DraftViewBuilder {
2191 _state: PhantomData,
2192 _fields: (None, None, None, None),
2193 _type: PhantomData,
2194 }
2195 }
2196}
2197
2198impl<S: BosStr> DraftViewBuilder<draft_view_state::Empty, S> {
2199 pub fn builder() -> Self {
2201 DraftViewBuilder {
2202 _state: PhantomData,
2203 _fields: (None, None, None, None),
2204 _type: PhantomData,
2205 }
2206 }
2207}
2208
2209impl<St, S: BosStr> DraftViewBuilder<St, S>
2210where
2211 St: draft_view_state::State,
2212 St::CreatedAt: draft_view_state::IsUnset,
2213{
2214 pub fn created_at(
2216 mut self,
2217 value: impl Into<Datetime>,
2218 ) -> DraftViewBuilder<draft_view_state::SetCreatedAt<St>, S> {
2219 self._fields.0 = Option::Some(value.into());
2220 DraftViewBuilder {
2221 _state: PhantomData,
2222 _fields: self._fields,
2223 _type: PhantomData,
2224 }
2225 }
2226}
2227
2228impl<St, S: BosStr> DraftViewBuilder<St, S>
2229where
2230 St: draft_view_state::State,
2231 St::Draft: draft_view_state::IsUnset,
2232{
2233 pub fn draft(
2235 mut self,
2236 value: impl Into<draft::Draft<S>>,
2237 ) -> DraftViewBuilder<draft_view_state::SetDraft<St>, S> {
2238 self._fields.1 = Option::Some(value.into());
2239 DraftViewBuilder {
2240 _state: PhantomData,
2241 _fields: self._fields,
2242 _type: PhantomData,
2243 }
2244 }
2245}
2246
2247impl<St, S: BosStr> DraftViewBuilder<St, S>
2248where
2249 St: draft_view_state::State,
2250 St::Id: draft_view_state::IsUnset,
2251{
2252 pub fn id(mut self, value: impl Into<Tid>) -> DraftViewBuilder<draft_view_state::SetId<St>, S> {
2254 self._fields.2 = Option::Some(value.into());
2255 DraftViewBuilder {
2256 _state: PhantomData,
2257 _fields: self._fields,
2258 _type: PhantomData,
2259 }
2260 }
2261}
2262
2263impl<St, S: BosStr> DraftViewBuilder<St, S>
2264where
2265 St: draft_view_state::State,
2266 St::UpdatedAt: draft_view_state::IsUnset,
2267{
2268 pub fn updated_at(
2270 mut self,
2271 value: impl Into<Datetime>,
2272 ) -> DraftViewBuilder<draft_view_state::SetUpdatedAt<St>, S> {
2273 self._fields.3 = Option::Some(value.into());
2274 DraftViewBuilder {
2275 _state: PhantomData,
2276 _fields: self._fields,
2277 _type: PhantomData,
2278 }
2279 }
2280}
2281
2282impl<St, S: BosStr> DraftViewBuilder<St, S>
2283where
2284 St: draft_view_state::State,
2285 St::CreatedAt: draft_view_state::IsSet,
2286 St::Draft: draft_view_state::IsSet,
2287 St::Id: draft_view_state::IsSet,
2288 St::UpdatedAt: draft_view_state::IsSet,
2289{
2290 pub fn build(self) -> DraftView<S> {
2292 DraftView {
2293 created_at: self._fields.0.unwrap(),
2294 draft: self._fields.1.unwrap(),
2295 id: self._fields.2.unwrap(),
2296 updated_at: self._fields.3.unwrap(),
2297 extra_data: Default::default(),
2298 }
2299 }
2300 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftView<S> {
2302 DraftView {
2303 created_at: self._fields.0.unwrap(),
2304 draft: self._fields.1.unwrap(),
2305 id: self._fields.2.unwrap(),
2306 updated_at: self._fields.3.unwrap(),
2307 extra_data: Some(extra_data),
2308 }
2309 }
2310}
2311
2312pub mod draft_with_id_state {
2313
2314 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
2315 #[allow(unused)]
2316 use ::core::marker::PhantomData;
2317 mod sealed {
2318 pub trait Sealed {}
2319 }
2320 pub trait State: sealed::Sealed {
2322 type Draft;
2323 type Id;
2324 }
2325 pub struct Empty(());
2327 impl sealed::Sealed for Empty {}
2328 impl State for Empty {
2329 type Draft = Unset;
2330 type Id = Unset;
2331 }
2332 pub struct SetDraft<St: State = Empty>(PhantomData<fn() -> St>);
2334 impl<St: State> sealed::Sealed for SetDraft<St> {}
2335 impl<St: State> State for SetDraft<St> {
2336 type Draft = Set<members::draft>;
2337 type Id = St::Id;
2338 }
2339 pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
2341 impl<St: State> sealed::Sealed for SetId<St> {}
2342 impl<St: State> State for SetId<St> {
2343 type Draft = St::Draft;
2344 type Id = Set<members::id>;
2345 }
2346 #[allow(non_camel_case_types)]
2348 pub mod members {
2349 pub struct draft(());
2351 pub struct id(());
2353 }
2354}
2355
2356pub struct DraftWithIdBuilder<St: draft_with_id_state::State, S: BosStr = DefaultStr> {
2358 _state: PhantomData<fn() -> St>,
2359 _fields: (Option<draft::Draft<S>>, Option<Tid>),
2360 _type: PhantomData<fn() -> S>,
2361}
2362
2363impl DraftWithId<DefaultStr> {
2364 pub fn new() -> DraftWithIdBuilder<draft_with_id_state::Empty, DefaultStr> {
2366 DraftWithIdBuilder::new()
2367 }
2368}
2369
2370impl<S: BosStr> DraftWithId<S> {
2371 pub fn builder() -> DraftWithIdBuilder<draft_with_id_state::Empty, S> {
2373 DraftWithIdBuilder::builder()
2374 }
2375}
2376
2377impl DraftWithIdBuilder<draft_with_id_state::Empty, DefaultStr> {
2378 pub fn new() -> Self {
2380 DraftWithIdBuilder {
2381 _state: PhantomData,
2382 _fields: (None, None),
2383 _type: PhantomData,
2384 }
2385 }
2386}
2387
2388impl<S: BosStr> DraftWithIdBuilder<draft_with_id_state::Empty, S> {
2389 pub fn builder() -> Self {
2391 DraftWithIdBuilder {
2392 _state: PhantomData,
2393 _fields: (None, None),
2394 _type: PhantomData,
2395 }
2396 }
2397}
2398
2399impl<St, S: BosStr> DraftWithIdBuilder<St, S>
2400where
2401 St: draft_with_id_state::State,
2402 St::Draft: draft_with_id_state::IsUnset,
2403{
2404 pub fn draft(
2406 mut self,
2407 value: impl Into<draft::Draft<S>>,
2408 ) -> DraftWithIdBuilder<draft_with_id_state::SetDraft<St>, S> {
2409 self._fields.0 = Option::Some(value.into());
2410 DraftWithIdBuilder {
2411 _state: PhantomData,
2412 _fields: self._fields,
2413 _type: PhantomData,
2414 }
2415 }
2416}
2417
2418impl<St, S: BosStr> DraftWithIdBuilder<St, S>
2419where
2420 St: draft_with_id_state::State,
2421 St::Id: draft_with_id_state::IsUnset,
2422{
2423 pub fn id(
2425 mut self,
2426 value: impl Into<Tid>,
2427 ) -> DraftWithIdBuilder<draft_with_id_state::SetId<St>, S> {
2428 self._fields.1 = Option::Some(value.into());
2429 DraftWithIdBuilder {
2430 _state: PhantomData,
2431 _fields: self._fields,
2432 _type: PhantomData,
2433 }
2434 }
2435}
2436
2437impl<St, S: BosStr> DraftWithIdBuilder<St, S>
2438where
2439 St: draft_with_id_state::State,
2440 St::Draft: draft_with_id_state::IsSet,
2441 St::Id: draft_with_id_state::IsSet,
2442{
2443 pub fn build(self) -> DraftWithId<S> {
2445 DraftWithId {
2446 draft: self._fields.0.unwrap(),
2447 id: self._fields.1.unwrap(),
2448 extra_data: Default::default(),
2449 }
2450 }
2451 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> DraftWithId<S> {
2453 DraftWithId {
2454 draft: self._fields.0.unwrap(),
2455 id: self._fields.1.unwrap(),
2456 extra_data: Some(extra_data),
2457 }
2458 }
2459}