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