1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_common::deps::smol_str::SmolStr;
18use jacquard_common::types::collection::{Collection, RecordError};
19use jacquard_common::types::string::{AtUri, Cid, Datetime, Language};
20use jacquard_common::types::uri::{RecordUri, UriError};
21use jacquard_common::types::value::Data;
22use jacquard_common::xrpc::XrpcResp;
23use jacquard_derive::{IntoStatic, lexicon, open_union};
24use jacquard_lexicon::lexicon::LexiconDoc;
25use jacquard_lexicon::schema::LexiconSchema;
26
27use crate::app_bsky::embed::external::ExternalRecord;
28use crate::app_bsky::embed::gallery::Gallery;
29use crate::app_bsky::embed::images::Images;
30use crate::app_bsky::embed::record::Record;
31use crate::app_bsky::embed::record_with_media::RecordWithMedia;
32use crate::app_bsky::embed::video::Video;
33use crate::app_bsky::richtext::facet::Facet;
34use crate::com_atproto::label::SelfLabels;
35use crate::com_atproto::repo::strong_ref::StrongRef;
36use crate::net_anisota::feed::draft;
37#[allow(unused_imports)]
38use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
39use serde::{Deserialize, Serialize};
40#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
43#[serde(
44 rename_all = "camelCase",
45 rename = "net.anisota.feed.draft",
46 tag = "$type",
47 bound(deserialize = "S: Deserialize<'de> + BosStr")
48)]
49pub struct Draft<S: BosStr = DefaultStr> {
50 pub created_at: Datetime,
52 #[serde(skip_serializing_if = "Option::is_none")]
53 pub embed: Option<DraftEmbed<S>>,
54 #[serde(skip_serializing_if = "Option::is_none")]
56 pub facets: Option<Vec<Facet<S>>>,
57 #[serde(skip_serializing_if = "Option::is_none")]
59 pub labels: Option<SelfLabels<S>>,
60 #[serde(skip_serializing_if = "Option::is_none")]
62 pub langs: Option<Vec<Language>>,
63 #[serde(skip_serializing_if = "Option::is_none")]
64 pub reply: Option<draft::ReplyRef<S>>,
65 #[serde(skip_serializing_if = "Option::is_none")]
67 pub tags: Option<Vec<S>>,
68 pub text: S,
70 #[serde(skip_serializing_if = "Option::is_none")]
72 pub updated_at: Option<Datetime>,
73 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
74 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
75}
76
77#[open_union]
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
79#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
80pub enum DraftEmbed<S: BosStr = DefaultStr> {
81 #[serde(rename = "app.bsky.embed.images")]
82 Images(Box<Images<S>>),
83 #[serde(rename = "app.bsky.embed.gallery")]
84 Gallery(Box<Gallery<S>>),
85 #[serde(rename = "app.bsky.embed.video")]
86 Video(Box<Video<S>>),
87 #[serde(rename = "app.bsky.embed.external")]
88 External(Box<ExternalRecord<S>>),
89 #[serde(rename = "app.bsky.embed.record")]
90 Record(Box<Record<S>>),
91 #[serde(rename = "app.bsky.embed.recordWithMedia")]
92 RecordWithMedia(Box<RecordWithMedia<S>>),
93}
94
95#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
98#[serde(rename_all = "camelCase")]
99pub struct DraftGetRecordOutput<S: BosStr = DefaultStr> {
100 #[serde(skip_serializing_if = "Option::is_none")]
101 pub cid: Option<Cid<S>>,
102 pub uri: AtUri<S>,
103 pub value: Draft<S>,
104}
105
106#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
107#[serde(
108 rename_all = "camelCase",
109 bound(deserialize = "S: Deserialize<'de> + BosStr")
110)]
111pub struct ReplyRef<S: BosStr = DefaultStr> {
112 pub parent: StrongRef<S>,
113 pub root: StrongRef<S>,
114 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
115 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
116}
117
118impl<S: BosStr> Draft<S> {
119 pub fn uri(uri: S) -> Result<RecordUri<S, DraftRecord>, UriError> {
120 RecordUri::try_from_uri(AtUri::new(uri)?)
121 }
122}
123
124#[derive(Debug, Serialize, Deserialize)]
127pub struct DraftRecord;
128impl XrpcResp for DraftRecord {
129 const NSID: &'static str = "net.anisota.feed.draft";
130 const ENCODING: &'static str = "application/json";
131 type Output<S: BosStr> = DraftGetRecordOutput<S>;
132 type Err = RecordError;
133}
134
135impl<S: BosStr> From<DraftGetRecordOutput<S>> for Draft<S> {
136 fn from(output: DraftGetRecordOutput<S>) -> Self {
137 output.value
138 }
139}
140
141impl<S: BosStr> Collection for Draft<S> {
142 const NSID: &'static str = "net.anisota.feed.draft";
143 type Record = DraftRecord;
144}
145
146impl Collection for DraftRecord {
147 const NSID: &'static str = "net.anisota.feed.draft";
148 type Record = DraftRecord;
149}
150
151impl<S: BosStr> LexiconSchema for Draft<S> {
152 fn nsid() -> &'static str {
153 "net.anisota.feed.draft"
154 }
155 fn def_name() -> &'static str {
156 "main"
157 }
158 fn lexicon_doc() -> LexiconDoc<'static> {
159 lexicon_doc_net_anisota_feed_draft()
160 }
161 fn validate(&self) -> Result<(), ConstraintError> {
162 if let Some(ref value) = self.langs {
163 #[allow(unused_comparisons)]
164 if value.len() > 3usize {
165 return Err(ConstraintError::MaxLength {
166 path: ValidationPath::from_field("langs"),
167 max: 3usize,
168 actual: value.len(),
169 });
170 }
171 }
172 if let Some(ref value) = self.tags {
173 #[allow(unused_comparisons)]
174 if value.len() > 8usize {
175 return Err(ConstraintError::MaxLength {
176 path: ValidationPath::from_field("tags"),
177 max: 8usize,
178 actual: value.len(),
179 });
180 }
181 }
182 {
183 let value = &self.text;
184 #[allow(unused_comparisons)]
185 if <str>::len(value.as_ref()) > 3000usize {
186 return Err(ConstraintError::MaxLength {
187 path: ValidationPath::from_field("text"),
188 max: 3000usize,
189 actual: <str>::len(value.as_ref()),
190 });
191 }
192 }
193 {
194 let value = &self.text;
195 {
196 let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
197 if count > 300usize {
198 return Err(ConstraintError::MaxGraphemes {
199 path: ValidationPath::from_field("text"),
200 max: 300usize,
201 actual: count,
202 });
203 }
204 }
205 }
206 Ok(())
207 }
208}
209
210impl<S: BosStr> LexiconSchema for ReplyRef<S> {
211 fn nsid() -> &'static str {
212 "net.anisota.feed.draft"
213 }
214 fn def_name() -> &'static str {
215 "replyRef"
216 }
217 fn lexicon_doc() -> LexiconDoc<'static> {
218 lexicon_doc_net_anisota_feed_draft()
219 }
220 fn validate(&self) -> Result<(), ConstraintError> {
221 Ok(())
222 }
223}
224
225pub mod draft_state {
226
227 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
228 #[allow(unused)]
229 use ::core::marker::PhantomData;
230 mod sealed {
231 pub trait Sealed {}
232 }
233 pub trait State: sealed::Sealed {
235 type CreatedAt;
236 type Text;
237 }
238 pub struct Empty(());
240 impl sealed::Sealed for Empty {}
241 impl State for Empty {
242 type CreatedAt = Unset;
243 type Text = Unset;
244 }
245 pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
247 impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
248 impl<St: State> State for SetCreatedAt<St> {
249 type CreatedAt = Set<members::created_at>;
250 type Text = St::Text;
251 }
252 pub struct SetText<St: State = Empty>(PhantomData<fn() -> St>);
254 impl<St: State> sealed::Sealed for SetText<St> {}
255 impl<St: State> State for SetText<St> {
256 type CreatedAt = St::CreatedAt;
257 type Text = Set<members::text>;
258 }
259 #[allow(non_camel_case_types)]
261 pub mod members {
262 pub struct created_at(());
264 pub struct text(());
266 }
267}
268
269pub struct DraftBuilder<St: draft_state::State, S: BosStr = DefaultStr> {
271 _state: PhantomData<fn() -> St>,
272 _fields: (
273 Option<Datetime>,
274 Option<DraftEmbed<S>>,
275 Option<Vec<Facet<S>>>,
276 Option<SelfLabels<S>>,
277 Option<Vec<Language>>,
278 Option<draft::ReplyRef<S>>,
279 Option<Vec<S>>,
280 Option<S>,
281 Option<Datetime>,
282 ),
283 _type: PhantomData<fn() -> S>,
284}
285
286impl Draft<DefaultStr> {
287 pub fn new() -> DraftBuilder<draft_state::Empty, DefaultStr> {
289 DraftBuilder::new()
290 }
291}
292
293impl<S: BosStr> Draft<S> {
294 pub fn builder() -> DraftBuilder<draft_state::Empty, S> {
296 DraftBuilder::builder()
297 }
298}
299
300impl DraftBuilder<draft_state::Empty, DefaultStr> {
301 pub fn new() -> Self {
303 DraftBuilder {
304 _state: PhantomData,
305 _fields: (None, None, None, None, None, None, None, None, None),
306 _type: PhantomData,
307 }
308 }
309}
310
311impl<S: BosStr> DraftBuilder<draft_state::Empty, S> {
312 pub fn builder() -> Self {
314 DraftBuilder {
315 _state: PhantomData,
316 _fields: (None, None, None, None, None, None, None, None, None),
317 _type: PhantomData,
318 }
319 }
320}
321
322impl<St, S: BosStr> DraftBuilder<St, S>
323where
324 St: draft_state::State,
325 St::CreatedAt: draft_state::IsUnset,
326{
327 pub fn created_at(
329 mut self,
330 value: impl Into<Datetime>,
331 ) -> DraftBuilder<draft_state::SetCreatedAt<St>, S> {
332 self._fields.0 = Option::Some(value.into());
333 DraftBuilder {
334 _state: PhantomData,
335 _fields: self._fields,
336 _type: PhantomData,
337 }
338 }
339}
340
341impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
342 pub fn embed(mut self, value: impl Into<Option<DraftEmbed<S>>>) -> Self {
344 self._fields.1 = value.into();
345 self
346 }
347 pub fn maybe_embed(mut self, value: Option<DraftEmbed<S>>) -> Self {
349 self._fields.1 = value;
350 self
351 }
352}
353
354impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
355 pub fn facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
357 self._fields.2 = value.into();
358 self
359 }
360 pub fn maybe_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
362 self._fields.2 = value;
363 self
364 }
365}
366
367impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
368 pub fn labels(mut self, value: impl Into<Option<SelfLabels<S>>>) -> Self {
370 self._fields.3 = value.into();
371 self
372 }
373 pub fn maybe_labels(mut self, value: Option<SelfLabels<S>>) -> Self {
375 self._fields.3 = value;
376 self
377 }
378}
379
380impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
381 pub fn langs(mut self, value: impl Into<Option<Vec<Language>>>) -> Self {
383 self._fields.4 = value.into();
384 self
385 }
386 pub fn maybe_langs(mut self, value: Option<Vec<Language>>) -> Self {
388 self._fields.4 = value;
389 self
390 }
391}
392
393impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
394 pub fn reply(mut self, value: impl Into<Option<draft::ReplyRef<S>>>) -> Self {
396 self._fields.5 = value.into();
397 self
398 }
399 pub fn maybe_reply(mut self, value: Option<draft::ReplyRef<S>>) -> Self {
401 self._fields.5 = value;
402 self
403 }
404}
405
406impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
407 pub fn tags(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
409 self._fields.6 = value.into();
410 self
411 }
412 pub fn maybe_tags(mut self, value: Option<Vec<S>>) -> Self {
414 self._fields.6 = value;
415 self
416 }
417}
418
419impl<St, S: BosStr> DraftBuilder<St, S>
420where
421 St: draft_state::State,
422 St::Text: draft_state::IsUnset,
423{
424 pub fn text(mut self, value: impl Into<S>) -> DraftBuilder<draft_state::SetText<St>, S> {
426 self._fields.7 = Option::Some(value.into());
427 DraftBuilder {
428 _state: PhantomData,
429 _fields: self._fields,
430 _type: PhantomData,
431 }
432 }
433}
434
435impl<St: draft_state::State, S: BosStr> DraftBuilder<St, S> {
436 pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
438 self._fields.8 = value.into();
439 self
440 }
441 pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
443 self._fields.8 = value;
444 self
445 }
446}
447
448impl<St, S: BosStr> DraftBuilder<St, S>
449where
450 St: draft_state::State,
451 St::CreatedAt: draft_state::IsSet,
452 St::Text: draft_state::IsSet,
453{
454 pub fn build(self) -> Draft<S> {
456 Draft {
457 created_at: self._fields.0.unwrap(),
458 embed: self._fields.1,
459 facets: self._fields.2,
460 labels: self._fields.3,
461 langs: self._fields.4,
462 reply: self._fields.5,
463 tags: self._fields.6,
464 text: self._fields.7.unwrap(),
465 updated_at: self._fields.8,
466 extra_data: Default::default(),
467 }
468 }
469 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Draft<S> {
471 Draft {
472 created_at: self._fields.0.unwrap(),
473 embed: self._fields.1,
474 facets: self._fields.2,
475 labels: self._fields.3,
476 langs: self._fields.4,
477 reply: self._fields.5,
478 tags: self._fields.6,
479 text: self._fields.7.unwrap(),
480 updated_at: self._fields.8,
481 extra_data: Some(extra_data),
482 }
483 }
484}
485
486fn lexicon_doc_net_anisota_feed_draft() -> LexiconDoc<'static> {
487 use alloc::collections::BTreeMap;
488 #[allow(unused_imports)]
489 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
490 use jacquard_lexicon::lexicon::*;
491 LexiconDoc {
492 lexicon: Lexicon::Lexicon1,
493 id: CowStr::new_static("net.anisota.feed.draft"),
494 defs: {
495 let mut map = BTreeMap::new();
496 map.insert(
497 SmolStr::new_static("main"),
498 LexUserType::Record(LexRecord {
499 description: Some(
500 CowStr::new_static(
501 "Record containing a draft post that can be edited and later published as app.bsky.feed.post",
502 ),
503 ),
504 key: Some(CowStr::new_static("tid")),
505 record: LexRecordRecord::Object(LexObject {
506 required: Some(
507 vec![
508 SmolStr::new_static("text"),
509 SmolStr::new_static("createdAt")
510 ],
511 ),
512 properties: {
513 #[allow(unused_mut)]
514 let mut map = BTreeMap::new();
515 map.insert(
516 SmolStr::new_static("createdAt"),
517 LexObjectProperty::String(LexString {
518 description: Some(
519 CowStr::new_static(
520 "Client-declared timestamp when this draft was originally created.",
521 ),
522 ),
523 format: Some(LexStringFormat::Datetime),
524 ..Default::default()
525 }),
526 );
527 map.insert(
528 SmolStr::new_static("embed"),
529 LexObjectProperty::Union(LexRefUnion {
530 refs: vec![
531 CowStr::new_static("app.bsky.embed.images"),
532 CowStr::new_static("app.bsky.embed.gallery"),
533 CowStr::new_static("app.bsky.embed.video"),
534 CowStr::new_static("app.bsky.embed.external"),
535 CowStr::new_static("app.bsky.embed.record"),
536 CowStr::new_static("app.bsky.embed.recordWithMedia")
537 ],
538 ..Default::default()
539 }),
540 );
541 map.insert(
542 SmolStr::new_static("facets"),
543 LexObjectProperty::Array(LexArray {
544 description: Some(
545 CowStr::new_static(
546 "Annotations of text (mentions, URLs, hashtags, etc)",
547 ),
548 ),
549 items: LexArrayItem::Ref(LexRef {
550 r#ref: CowStr::new_static("app.bsky.richtext.facet"),
551 ..Default::default()
552 }),
553 ..Default::default()
554 }),
555 );
556 map.insert(
557 SmolStr::new_static("labels"),
558 LexObjectProperty::Union(LexRefUnion {
559 description: Some(
560 CowStr::new_static(
561 "Self-label values for this post. Effectively content warnings.",
562 ),
563 ),
564 refs: vec![
565 CowStr::new_static("com.atproto.label.defs#selfLabels")
566 ],
567 ..Default::default()
568 }),
569 );
570 map.insert(
571 SmolStr::new_static("langs"),
572 LexObjectProperty::Array(LexArray {
573 description: Some(
574 CowStr::new_static(
575 "Indicates human language of post primary text content.",
576 ),
577 ),
578 items: LexArrayItem::String(LexString {
579 format: Some(LexStringFormat::Language),
580 ..Default::default()
581 }),
582 max_length: Some(3usize),
583 ..Default::default()
584 }),
585 );
586 map.insert(
587 SmolStr::new_static("reply"),
588 LexObjectProperty::Ref(LexRef {
589 r#ref: CowStr::new_static("#replyRef"),
590 ..Default::default()
591 }),
592 );
593 map.insert(
594 SmolStr::new_static("tags"),
595 LexObjectProperty::Array(LexArray {
596 description: Some(
597 CowStr::new_static(
598 "Additional hashtags, in addition to any included in post text and facets.",
599 ),
600 ),
601 items: LexArrayItem::String(LexString {
602 max_length: Some(640usize),
603 max_graphemes: Some(64usize),
604 ..Default::default()
605 }),
606 max_length: Some(8usize),
607 ..Default::default()
608 }),
609 );
610 map.insert(
611 SmolStr::new_static("text"),
612 LexObjectProperty::String(LexString {
613 description: Some(
614 CowStr::new_static(
615 "The primary post content. May be an empty string, if there are embeds.",
616 ),
617 ),
618 max_length: Some(3000usize),
619 max_graphemes: Some(300usize),
620 ..Default::default()
621 }),
622 );
623 map.insert(
624 SmolStr::new_static("updatedAt"),
625 LexObjectProperty::String(LexString {
626 description: Some(
627 CowStr::new_static(
628 "Client-declared timestamp when this draft was last updated.",
629 ),
630 ),
631 format: Some(LexStringFormat::Datetime),
632 ..Default::default()
633 }),
634 );
635 map
636 },
637 ..Default::default()
638 }),
639 ..Default::default()
640 }),
641 );
642 map.insert(
643 SmolStr::new_static("replyRef"),
644 LexUserType::Object(LexObject {
645 required: Some(vec![
646 SmolStr::new_static("root"),
647 SmolStr::new_static("parent"),
648 ]),
649 properties: {
650 #[allow(unused_mut)]
651 let mut map = BTreeMap::new();
652 map.insert(
653 SmolStr::new_static("parent"),
654 LexObjectProperty::Ref(LexRef {
655 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
656 ..Default::default()
657 }),
658 );
659 map.insert(
660 SmolStr::new_static("root"),
661 LexObjectProperty::Ref(LexRef {
662 r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
663 ..Default::default()
664 }),
665 );
666 map
667 },
668 ..Default::default()
669 }),
670 );
671 map
672 },
673 ..Default::default()
674 }
675}
676
677pub mod reply_ref_state {
678
679 pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
680 #[allow(unused)]
681 use ::core::marker::PhantomData;
682 mod sealed {
683 pub trait Sealed {}
684 }
685 pub trait State: sealed::Sealed {
687 type Parent;
688 type Root;
689 }
690 pub struct Empty(());
692 impl sealed::Sealed for Empty {}
693 impl State for Empty {
694 type Parent = Unset;
695 type Root = Unset;
696 }
697 pub struct SetParent<St: State = Empty>(PhantomData<fn() -> St>);
699 impl<St: State> sealed::Sealed for SetParent<St> {}
700 impl<St: State> State for SetParent<St> {
701 type Parent = Set<members::parent>;
702 type Root = St::Root;
703 }
704 pub struct SetRoot<St: State = Empty>(PhantomData<fn() -> St>);
706 impl<St: State> sealed::Sealed for SetRoot<St> {}
707 impl<St: State> State for SetRoot<St> {
708 type Parent = St::Parent;
709 type Root = Set<members::root>;
710 }
711 #[allow(non_camel_case_types)]
713 pub mod members {
714 pub struct parent(());
716 pub struct root(());
718 }
719}
720
721pub struct ReplyRefBuilder<St: reply_ref_state::State, S: BosStr = DefaultStr> {
723 _state: PhantomData<fn() -> St>,
724 _fields: (Option<StrongRef<S>>, Option<StrongRef<S>>),
725 _type: PhantomData<fn() -> S>,
726}
727
728impl ReplyRef<DefaultStr> {
729 pub fn new() -> ReplyRefBuilder<reply_ref_state::Empty, DefaultStr> {
731 ReplyRefBuilder::new()
732 }
733}
734
735impl<S: BosStr> ReplyRef<S> {
736 pub fn builder() -> ReplyRefBuilder<reply_ref_state::Empty, S> {
738 ReplyRefBuilder::builder()
739 }
740}
741
742impl ReplyRefBuilder<reply_ref_state::Empty, DefaultStr> {
743 pub fn new() -> Self {
745 ReplyRefBuilder {
746 _state: PhantomData,
747 _fields: (None, None),
748 _type: PhantomData,
749 }
750 }
751}
752
753impl<S: BosStr> ReplyRefBuilder<reply_ref_state::Empty, S> {
754 pub fn builder() -> Self {
756 ReplyRefBuilder {
757 _state: PhantomData,
758 _fields: (None, None),
759 _type: PhantomData,
760 }
761 }
762}
763
764impl<St, S: BosStr> ReplyRefBuilder<St, S>
765where
766 St: reply_ref_state::State,
767 St::Parent: reply_ref_state::IsUnset,
768{
769 pub fn parent(
771 mut self,
772 value: impl Into<StrongRef<S>>,
773 ) -> ReplyRefBuilder<reply_ref_state::SetParent<St>, S> {
774 self._fields.0 = Option::Some(value.into());
775 ReplyRefBuilder {
776 _state: PhantomData,
777 _fields: self._fields,
778 _type: PhantomData,
779 }
780 }
781}
782
783impl<St, S: BosStr> ReplyRefBuilder<St, S>
784where
785 St: reply_ref_state::State,
786 St::Root: reply_ref_state::IsUnset,
787{
788 pub fn root(
790 mut self,
791 value: impl Into<StrongRef<S>>,
792 ) -> ReplyRefBuilder<reply_ref_state::SetRoot<St>, S> {
793 self._fields.1 = Option::Some(value.into());
794 ReplyRefBuilder {
795 _state: PhantomData,
796 _fields: self._fields,
797 _type: PhantomData,
798 }
799 }
800}
801
802impl<St, S: BosStr> ReplyRefBuilder<St, S>
803where
804 St: reply_ref_state::State,
805 St::Parent: reply_ref_state::IsSet,
806 St::Root: reply_ref_state::IsSet,
807{
808 pub fn build(self) -> ReplyRef<S> {
810 ReplyRef {
811 parent: self._fields.0.unwrap(),
812 root: self._fields.1.unwrap(),
813 extra_data: Default::default(),
814 }
815 }
816 pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ReplyRef<S> {
818 ReplyRef {
819 parent: self._fields.0.unwrap(),
820 root: self._fields.1.unwrap(),
821 extra_data: Some(extra_data),
822 }
823 }
824}