1pub mod gate;
10pub mod message;
11pub mod pinned_record;
12pub mod profile;
13
14
15#[allow(unused_imports)]
16use alloc::collections::BTreeMap;
17
18#[allow(unused_imports)]
19use core::marker::PhantomData;
20use jacquard_common::{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::{AtUri, Cid, Datetime};
26use jacquard_common::types::value::Data;
27use jacquard_derive::IntoStatic;
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::actor::ProfileViewBasic;
35use crate::place_stream::badge::BadgeView;
36use crate::place_stream::chat::pinned_record::PinnedRecord;
37use crate::place_stream::chat::profile::Profile;
38use crate::place_stream::chat;
39
40#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
41#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
42pub struct MessageView<S: BosStr = DefaultStr> {
43 pub author: ProfileViewBasic<S>,
44 #[serde(skip_serializing_if = "Option::is_none")]
46 pub badges: Option<Vec<BadgeView<S>>>,
47 #[serde(skip_serializing_if = "Option::is_none")]
48 pub chat_profile: Option<Profile<S>>,
49 pub cid: Cid<S>,
50 #[serde(skip_serializing_if = "Option::is_none")]
52 pub deleted: Option<bool>,
53 pub indexed_at: Datetime,
54 pub record: Data<S>,
55 #[serde(skip_serializing_if = "Option::is_none")]
56 pub reply_to: Option<MessageViewReplyTo<S>>,
57 pub uri: AtUri<S>,
58 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
59 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
60}
61
62
63#[jacquard_derive::open_union]
64#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
65#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
66pub enum MessageViewReplyTo<S: BosStr = DefaultStr> {
67 #[serde(rename = "place.stream.chat.defs#messageView")]
68 MessageView(Box<chat::MessageView<S>>),
69}
70
71#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
74#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
75pub struct PinnedRecordView<S: BosStr = DefaultStr> {
76 pub cid: Cid<S>,
77 pub indexed_at: Datetime,
78 #[serde(skip_serializing_if = "Option::is_none")]
79 pub message: Option<chat::MessageView<S>>,
80 #[serde(skip_serializing_if = "Option::is_none")]
81 pub pinned_by: Option<Profile<S>>,
82 pub record: PinnedRecord<S>,
83 pub uri: AtUri<S>,
84 #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
85 pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
86}
87
88impl<S: BosStr> LexiconSchema for MessageView<S> {
89 fn nsid() -> &'static str {
90 "place.stream.chat.defs"
91 }
92 fn def_name() -> &'static str {
93 "messageView"
94 }
95 fn lexicon_doc() -> LexiconDoc<'static> {
96 lexicon_doc_place_stream_chat_defs()
97 }
98 fn validate(&self) -> Result<(), ConstraintError> {
99 if let Some(ref value) = self.badges {
100 #[allow(unused_comparisons)]
101 if value.len() > 3usize {
102 return Err(ConstraintError::MaxLength {
103 path: ValidationPath::from_field("badges"),
104 max: 3usize,
105 actual: value.len(),
106 });
107 }
108 }
109 Ok(())
110 }
111}
112
113impl<S: BosStr> LexiconSchema for PinnedRecordView<S> {
114 fn nsid() -> &'static str {
115 "place.stream.chat.defs"
116 }
117 fn def_name() -> &'static str {
118 "pinnedRecordView"
119 }
120 fn lexicon_doc() -> LexiconDoc<'static> {
121 lexicon_doc_place_stream_chat_defs()
122 }
123 fn validate(&self) -> Result<(), ConstraintError> {
124 Ok(())
125 }
126}
127
128pub mod message_view_state {
129
130 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
131 #[allow(unused)]
132 use ::core::marker::PhantomData;
133 mod sealed {
134 pub trait Sealed {}
135 }
136 pub trait State: sealed::Sealed {
138 type Author;
139 type Cid;
140 type IndexedAt;
141 type Record;
142 type Uri;
143 }
144 pub struct Empty(());
146 impl sealed::Sealed for Empty {}
147 impl State for Empty {
148 type Author = Unset;
149 type Cid = Unset;
150 type IndexedAt = Unset;
151 type Record = Unset;
152 type Uri = Unset;
153 }
154 pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
156 impl<St: State> sealed::Sealed for SetAuthor<St> {}
157 impl<St: State> State for SetAuthor<St> {
158 type Author = Set<members::author>;
159 type Cid = St::Cid;
160 type IndexedAt = St::IndexedAt;
161 type Record = St::Record;
162 type Uri = St::Uri;
163 }
164 pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
166 impl<St: State> sealed::Sealed for SetCid<St> {}
167 impl<St: State> State for SetCid<St> {
168 type Author = St::Author;
169 type Cid = Set<members::cid>;
170 type IndexedAt = St::IndexedAt;
171 type Record = St::Record;
172 type Uri = St::Uri;
173 }
174 pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
176 impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
177 impl<St: State> State for SetIndexedAt<St> {
178 type Author = St::Author;
179 type Cid = St::Cid;
180 type IndexedAt = Set<members::indexed_at>;
181 type Record = St::Record;
182 type Uri = St::Uri;
183 }
184 pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
186 impl<St: State> sealed::Sealed for SetRecord<St> {}
187 impl<St: State> State for SetRecord<St> {
188 type Author = St::Author;
189 type Cid = St::Cid;
190 type IndexedAt = St::IndexedAt;
191 type Record = Set<members::record>;
192 type Uri = St::Uri;
193 }
194 pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
196 impl<St: State> sealed::Sealed for SetUri<St> {}
197 impl<St: State> State for SetUri<St> {
198 type Author = St::Author;
199 type Cid = St::Cid;
200 type IndexedAt = St::IndexedAt;
201 type Record = St::Record;
202 type Uri = Set<members::uri>;
203 }
204 #[allow(non_camel_case_types)]
206 pub mod members {
207 pub struct author(());
209 pub struct cid(());
211 pub struct indexed_at(());
213 pub struct record(());
215 pub struct uri(());
217 }
218}
219
220pub struct MessageViewBuilder<St: message_view_state::State, S: BosStr = DefaultStr> {
222 _state: PhantomData<fn() -> St>,
223 _fields: (
224 Option<ProfileViewBasic<S>>,
225 Option<Vec<BadgeView<S>>>,
226 Option<Profile<S>>,
227 Option<Cid<S>>,
228 Option<bool>,
229 Option<Datetime>,
230 Option<Data<S>>,
231 Option<MessageViewReplyTo<S>>,
232 Option<AtUri<S>>,
233 ),
234 _type: PhantomData<fn() -> S>,
235}
236
237impl MessageView<DefaultStr> {
238 pub fn new() -> MessageViewBuilder<message_view_state::Empty, DefaultStr> {
240 MessageViewBuilder::new()
241 }
242}
243
244impl<S: BosStr> MessageView<S> {
245 pub fn builder() -> MessageViewBuilder<message_view_state::Empty, S> {
247 MessageViewBuilder::builder()
248 }
249}
250
251impl MessageViewBuilder<message_view_state::Empty, DefaultStr> {
252 pub fn new() -> Self {
254 MessageViewBuilder {
255 _state: PhantomData,
256 _fields: (None, None, None, None, None, None, None, None, None),
257 _type: PhantomData,
258 }
259 }
260}
261
262impl<S: BosStr> MessageViewBuilder<message_view_state::Empty, S> {
263 pub fn builder() -> Self {
265 MessageViewBuilder {
266 _state: PhantomData,
267 _fields: (None, None, None, None, None, None, None, None, None),
268 _type: PhantomData,
269 }
270 }
271}
272
273impl<St, S: BosStr> MessageViewBuilder<St, S>
274where
275 St: message_view_state::State,
276 St::Author: message_view_state::IsUnset,
277{
278 pub fn author(
280 mut self,
281 value: impl Into<ProfileViewBasic<S>>,
282 ) -> MessageViewBuilder<message_view_state::SetAuthor<St>, S> {
283 self._fields.0 = Option::Some(value.into());
284 MessageViewBuilder {
285 _state: PhantomData,
286 _fields: self._fields,
287 _type: PhantomData,
288 }
289 }
290}
291
292impl<St: message_view_state::State, S: BosStr> MessageViewBuilder<St, S> {
293 pub fn badges(mut self, value: impl Into<Option<Vec<BadgeView<S>>>>) -> Self {
295 self._fields.1 = value.into();
296 self
297 }
298 pub fn maybe_badges(mut self, value: Option<Vec<BadgeView<S>>>) -> Self {
300 self._fields.1 = value;
301 self
302 }
303}
304
305impl<St: message_view_state::State, S: BosStr> MessageViewBuilder<St, S> {
306 pub fn chat_profile(mut self, value: impl Into<Option<Profile<S>>>) -> Self {
308 self._fields.2 = value.into();
309 self
310 }
311 pub fn maybe_chat_profile(mut self, value: Option<Profile<S>>) -> Self {
313 self._fields.2 = value;
314 self
315 }
316}
317
318impl<St, S: BosStr> MessageViewBuilder<St, S>
319where
320 St: message_view_state::State,
321 St::Cid: message_view_state::IsUnset,
322{
323 pub fn cid(
325 mut self,
326 value: impl Into<Cid<S>>,
327 ) -> MessageViewBuilder<message_view_state::SetCid<St>, S> {
328 self._fields.3 = Option::Some(value.into());
329 MessageViewBuilder {
330 _state: PhantomData,
331 _fields: self._fields,
332 _type: PhantomData,
333 }
334 }
335}
336
337impl<St: message_view_state::State, S: BosStr> MessageViewBuilder<St, S> {
338 pub fn deleted(mut self, value: impl Into<Option<bool>>) -> Self {
340 self._fields.4 = value.into();
341 self
342 }
343 pub fn maybe_deleted(mut self, value: Option<bool>) -> Self {
345 self._fields.4 = value;
346 self
347 }
348}
349
350impl<St, S: BosStr> MessageViewBuilder<St, S>
351where
352 St: message_view_state::State,
353 St::IndexedAt: message_view_state::IsUnset,
354{
355 pub fn indexed_at(
357 mut self,
358 value: impl Into<Datetime>,
359 ) -> MessageViewBuilder<message_view_state::SetIndexedAt<St>, S> {
360 self._fields.5 = Option::Some(value.into());
361 MessageViewBuilder {
362 _state: PhantomData,
363 _fields: self._fields,
364 _type: PhantomData,
365 }
366 }
367}
368
369impl<St, S: BosStr> MessageViewBuilder<St, S>
370where
371 St: message_view_state::State,
372 St::Record: message_view_state::IsUnset,
373{
374 pub fn record(
376 mut self,
377 value: impl Into<Data<S>>,
378 ) -> MessageViewBuilder<message_view_state::SetRecord<St>, S> {
379 self._fields.6 = Option::Some(value.into());
380 MessageViewBuilder {
381 _state: PhantomData,
382 _fields: self._fields,
383 _type: PhantomData,
384 }
385 }
386}
387
388impl<St: message_view_state::State, S: BosStr> MessageViewBuilder<St, S> {
389 pub fn reply_to(mut self, value: impl Into<Option<MessageViewReplyTo<S>>>) -> Self {
391 self._fields.7 = value.into();
392 self
393 }
394 pub fn maybe_reply_to(mut self, value: Option<MessageViewReplyTo<S>>) -> Self {
396 self._fields.7 = value;
397 self
398 }
399}
400
401impl<St, S: BosStr> MessageViewBuilder<St, S>
402where
403 St: message_view_state::State,
404 St::Uri: message_view_state::IsUnset,
405{
406 pub fn uri(
408 mut self,
409 value: impl Into<AtUri<S>>,
410 ) -> MessageViewBuilder<message_view_state::SetUri<St>, S> {
411 self._fields.8 = Option::Some(value.into());
412 MessageViewBuilder {
413 _state: PhantomData,
414 _fields: self._fields,
415 _type: PhantomData,
416 }
417 }
418}
419
420impl<St, S: BosStr> MessageViewBuilder<St, S>
421where
422 St: message_view_state::State,
423 St::Author: message_view_state::IsSet,
424 St::Cid: message_view_state::IsSet,
425 St::IndexedAt: message_view_state::IsSet,
426 St::Record: message_view_state::IsSet,
427 St::Uri: message_view_state::IsSet,
428{
429 pub fn build(self) -> MessageView<S> {
431 MessageView {
432 author: self._fields.0.unwrap(),
433 badges: self._fields.1,
434 chat_profile: self._fields.2,
435 cid: self._fields.3.unwrap(),
436 deleted: self._fields.4,
437 indexed_at: self._fields.5.unwrap(),
438 record: self._fields.6.unwrap(),
439 reply_to: self._fields.7,
440 uri: self._fields.8.unwrap(),
441 extra_data: Default::default(),
442 }
443 }
444 pub fn build_with_data(
446 self,
447 extra_data: BTreeMap<SmolStr, Data<S>>,
448 ) -> MessageView<S> {
449 MessageView {
450 author: self._fields.0.unwrap(),
451 badges: self._fields.1,
452 chat_profile: self._fields.2,
453 cid: self._fields.3.unwrap(),
454 deleted: self._fields.4,
455 indexed_at: self._fields.5.unwrap(),
456 record: self._fields.6.unwrap(),
457 reply_to: self._fields.7,
458 uri: self._fields.8.unwrap(),
459 extra_data: Some(extra_data),
460 }
461 }
462}
463
464fn lexicon_doc_place_stream_chat_defs() -> LexiconDoc<'static> {
465 #[allow(unused_imports)]
466 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
467 use jacquard_lexicon::lexicon::*;
468 use alloc::collections::BTreeMap;
469 LexiconDoc {
470 lexicon: Lexicon::Lexicon1,
471 id: CowStr::new_static("place.stream.chat.defs"),
472 defs: {
473 let mut map = BTreeMap::new();
474 map.insert(
475 SmolStr::new_static("messageView"),
476 LexUserType::Object(LexObject {
477 required: Some(
478 vec![
479 SmolStr::new_static("uri"), SmolStr::new_static("cid"),
480 SmolStr::new_static("author"), SmolStr::new_static("record"),
481 SmolStr::new_static("indexedAt")
482 ],
483 ),
484 properties: {
485 #[allow(unused_mut)]
486 let mut map = BTreeMap::new();
487 map.insert(
488 SmolStr::new_static("author"),
489 LexObjectProperty::Ref(LexRef {
490 r#ref: CowStr::new_static(
491 "app.bsky.actor.defs#profileViewBasic",
492 ),
493 ..Default::default()
494 }),
495 );
496 map.insert(
497 SmolStr::new_static("badges"),
498 LexObjectProperty::Array(LexArray {
499 description: Some(
500 CowStr::new_static(
501 "Up to 3 badge tokens to display with the message. First badge is server-controlled, remaining badges are user-settable. Tokens are looked up in badges.json for display info.",
502 ),
503 ),
504 items: LexArrayItem::Ref(LexRef {
505 r#ref: CowStr::new_static(
506 "place.stream.badge.defs#badgeView",
507 ),
508 ..Default::default()
509 }),
510 max_length: Some(3usize),
511 ..Default::default()
512 }),
513 );
514 map.insert(
515 SmolStr::new_static("chatProfile"),
516 LexObjectProperty::Ref(LexRef {
517 r#ref: CowStr::new_static("place.stream.chat.profile"),
518 ..Default::default()
519 }),
520 );
521 map.insert(
522 SmolStr::new_static("cid"),
523 LexObjectProperty::String(LexString {
524 format: Some(LexStringFormat::Cid),
525 ..Default::default()
526 }),
527 );
528 map.insert(
529 SmolStr::new_static("deleted"),
530 LexObjectProperty::Boolean(LexBoolean {
531 ..Default::default()
532 }),
533 );
534 map.insert(
535 SmolStr::new_static("indexedAt"),
536 LexObjectProperty::String(LexString {
537 format: Some(LexStringFormat::Datetime),
538 ..Default::default()
539 }),
540 );
541 map.insert(
542 SmolStr::new_static("record"),
543 LexObjectProperty::Unknown(LexUnknown {
544 ..Default::default()
545 }),
546 );
547 map.insert(
548 SmolStr::new_static("replyTo"),
549 LexObjectProperty::Union(LexRefUnion {
550 refs: vec![CowStr::new_static("#messageView")],
551 ..Default::default()
552 }),
553 );
554 map.insert(
555 SmolStr::new_static("uri"),
556 LexObjectProperty::String(LexString {
557 format: Some(LexStringFormat::AtUri),
558 ..Default::default()
559 }),
560 );
561 map
562 },
563 ..Default::default()
564 }),
565 );
566 map.insert(
567 SmolStr::new_static("pinnedRecordView"),
568 LexUserType::Object(LexObject {
569 description: Some(
570 CowStr::new_static(
571 "View of a pinned chat record with hydrated message data.",
572 ),
573 ),
574 required: Some(
575 vec![
576 SmolStr::new_static("uri"), SmolStr::new_static("cid"),
577 SmolStr::new_static("record"),
578 SmolStr::new_static("indexedAt")
579 ],
580 ),
581 properties: {
582 #[allow(unused_mut)]
583 let mut map = BTreeMap::new();
584 map.insert(
585 SmolStr::new_static("cid"),
586 LexObjectProperty::String(LexString {
587 format: Some(LexStringFormat::Cid),
588 ..Default::default()
589 }),
590 );
591 map.insert(
592 SmolStr::new_static("indexedAt"),
593 LexObjectProperty::String(LexString {
594 format: Some(LexStringFormat::Datetime),
595 ..Default::default()
596 }),
597 );
598 map.insert(
599 SmolStr::new_static("message"),
600 LexObjectProperty::Ref(LexRef {
601 r#ref: CowStr::new_static("#messageView"),
602 ..Default::default()
603 }),
604 );
605 map.insert(
606 SmolStr::new_static("pinnedBy"),
607 LexObjectProperty::Ref(LexRef {
608 r#ref: CowStr::new_static("place.stream.chat.profile"),
609 ..Default::default()
610 }),
611 );
612 map.insert(
613 SmolStr::new_static("record"),
614 LexObjectProperty::Ref(LexRef {
615 r#ref: CowStr::new_static("place.stream.chat.pinnedRecord"),
616 ..Default::default()
617 }),
618 );
619 map.insert(
620 SmolStr::new_static("uri"),
621 LexObjectProperty::String(LexString {
622 format: Some(LexStringFormat::AtUri),
623 ..Default::default()
624 }),
625 );
626 map
627 },
628 ..Default::default()
629 }),
630 );
631 map
632 },
633 ..Default::default()
634 }
635}
636
637pub mod pinned_record_view_state {
638
639 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
640 #[allow(unused)]
641 use ::core::marker::PhantomData;
642 mod sealed {
643 pub trait Sealed {}
644 }
645 pub trait State: sealed::Sealed {
647 type Cid;
648 type IndexedAt;
649 type Record;
650 type Uri;
651 }
652 pub struct Empty(());
654 impl sealed::Sealed for Empty {}
655 impl State for Empty {
656 type Cid = Unset;
657 type IndexedAt = Unset;
658 type Record = Unset;
659 type Uri = Unset;
660 }
661 pub struct SetCid<St: State = Empty>(PhantomData<fn() -> St>);
663 impl<St: State> sealed::Sealed for SetCid<St> {}
664 impl<St: State> State for SetCid<St> {
665 type Cid = Set<members::cid>;
666 type IndexedAt = St::IndexedAt;
667 type Record = St::Record;
668 type Uri = St::Uri;
669 }
670 pub struct SetIndexedAt<St: State = Empty>(PhantomData<fn() -> St>);
672 impl<St: State> sealed::Sealed for SetIndexedAt<St> {}
673 impl<St: State> State for SetIndexedAt<St> {
674 type Cid = St::Cid;
675 type IndexedAt = Set<members::indexed_at>;
676 type Record = St::Record;
677 type Uri = St::Uri;
678 }
679 pub struct SetRecord<St: State = Empty>(PhantomData<fn() -> St>);
681 impl<St: State> sealed::Sealed for SetRecord<St> {}
682 impl<St: State> State for SetRecord<St> {
683 type Cid = St::Cid;
684 type IndexedAt = St::IndexedAt;
685 type Record = Set<members::record>;
686 type Uri = St::Uri;
687 }
688 pub struct SetUri<St: State = Empty>(PhantomData<fn() -> St>);
690 impl<St: State> sealed::Sealed for SetUri<St> {}
691 impl<St: State> State for SetUri<St> {
692 type Cid = St::Cid;
693 type IndexedAt = St::IndexedAt;
694 type Record = St::Record;
695 type Uri = Set<members::uri>;
696 }
697 #[allow(non_camel_case_types)]
699 pub mod members {
700 pub struct cid(());
702 pub struct indexed_at(());
704 pub struct record(());
706 pub struct uri(());
708 }
709}
710
711pub struct PinnedRecordViewBuilder<
713 St: pinned_record_view_state::State,
714 S: BosStr = DefaultStr,
715> {
716 _state: PhantomData<fn() -> St>,
717 _fields: (
718 Option<Cid<S>>,
719 Option<Datetime>,
720 Option<chat::MessageView<S>>,
721 Option<Profile<S>>,
722 Option<PinnedRecord<S>>,
723 Option<AtUri<S>>,
724 ),
725 _type: PhantomData<fn() -> S>,
726}
727
728impl PinnedRecordView<DefaultStr> {
729 pub fn new() -> PinnedRecordViewBuilder<
731 pinned_record_view_state::Empty,
732 DefaultStr,
733 > {
734 PinnedRecordViewBuilder::new()
735 }
736}
737
738impl<S: BosStr> PinnedRecordView<S> {
739 pub fn builder() -> PinnedRecordViewBuilder<pinned_record_view_state::Empty, S> {
741 PinnedRecordViewBuilder::builder()
742 }
743}
744
745impl PinnedRecordViewBuilder<pinned_record_view_state::Empty, DefaultStr> {
746 pub fn new() -> Self {
748 PinnedRecordViewBuilder {
749 _state: PhantomData,
750 _fields: (None, None, None, None, None, None),
751 _type: PhantomData,
752 }
753 }
754}
755
756impl<S: BosStr> PinnedRecordViewBuilder<pinned_record_view_state::Empty, S> {
757 pub fn builder() -> Self {
759 PinnedRecordViewBuilder {
760 _state: PhantomData,
761 _fields: (None, None, None, None, None, None),
762 _type: PhantomData,
763 }
764 }
765}
766
767impl<St, S: BosStr> PinnedRecordViewBuilder<St, S>
768where
769 St: pinned_record_view_state::State,
770 St::Cid: pinned_record_view_state::IsUnset,
771{
772 pub fn cid(
774 mut self,
775 value: impl Into<Cid<S>>,
776 ) -> PinnedRecordViewBuilder<pinned_record_view_state::SetCid<St>, S> {
777 self._fields.0 = Option::Some(value.into());
778 PinnedRecordViewBuilder {
779 _state: PhantomData,
780 _fields: self._fields,
781 _type: PhantomData,
782 }
783 }
784}
785
786impl<St, S: BosStr> PinnedRecordViewBuilder<St, S>
787where
788 St: pinned_record_view_state::State,
789 St::IndexedAt: pinned_record_view_state::IsUnset,
790{
791 pub fn indexed_at(
793 mut self,
794 value: impl Into<Datetime>,
795 ) -> PinnedRecordViewBuilder<pinned_record_view_state::SetIndexedAt<St>, S> {
796 self._fields.1 = Option::Some(value.into());
797 PinnedRecordViewBuilder {
798 _state: PhantomData,
799 _fields: self._fields,
800 _type: PhantomData,
801 }
802 }
803}
804
805impl<St: pinned_record_view_state::State, S: BosStr> PinnedRecordViewBuilder<St, S> {
806 pub fn message(mut self, value: impl Into<Option<chat::MessageView<S>>>) -> Self {
808 self._fields.2 = value.into();
809 self
810 }
811 pub fn maybe_message(mut self, value: Option<chat::MessageView<S>>) -> Self {
813 self._fields.2 = value;
814 self
815 }
816}
817
818impl<St: pinned_record_view_state::State, S: BosStr> PinnedRecordViewBuilder<St, S> {
819 pub fn pinned_by(mut self, value: impl Into<Option<Profile<S>>>) -> Self {
821 self._fields.3 = value.into();
822 self
823 }
824 pub fn maybe_pinned_by(mut self, value: Option<Profile<S>>) -> Self {
826 self._fields.3 = value;
827 self
828 }
829}
830
831impl<St, S: BosStr> PinnedRecordViewBuilder<St, S>
832where
833 St: pinned_record_view_state::State,
834 St::Record: pinned_record_view_state::IsUnset,
835{
836 pub fn record(
838 mut self,
839 value: impl Into<PinnedRecord<S>>,
840 ) -> PinnedRecordViewBuilder<pinned_record_view_state::SetRecord<St>, S> {
841 self._fields.4 = Option::Some(value.into());
842 PinnedRecordViewBuilder {
843 _state: PhantomData,
844 _fields: self._fields,
845 _type: PhantomData,
846 }
847 }
848}
849
850impl<St, S: BosStr> PinnedRecordViewBuilder<St, S>
851where
852 St: pinned_record_view_state::State,
853 St::Uri: pinned_record_view_state::IsUnset,
854{
855 pub fn uri(
857 mut self,
858 value: impl Into<AtUri<S>>,
859 ) -> PinnedRecordViewBuilder<pinned_record_view_state::SetUri<St>, S> {
860 self._fields.5 = Option::Some(value.into());
861 PinnedRecordViewBuilder {
862 _state: PhantomData,
863 _fields: self._fields,
864 _type: PhantomData,
865 }
866 }
867}
868
869impl<St, S: BosStr> PinnedRecordViewBuilder<St, S>
870where
871 St: pinned_record_view_state::State,
872 St::Cid: pinned_record_view_state::IsSet,
873 St::IndexedAt: pinned_record_view_state::IsSet,
874 St::Record: pinned_record_view_state::IsSet,
875 St::Uri: pinned_record_view_state::IsSet,
876{
877 pub fn build(self) -> PinnedRecordView<S> {
879 PinnedRecordView {
880 cid: self._fields.0.unwrap(),
881 indexed_at: self._fields.1.unwrap(),
882 message: self._fields.2,
883 pinned_by: self._fields.3,
884 record: self._fields.4.unwrap(),
885 uri: self._fields.5.unwrap(),
886 extra_data: Default::default(),
887 }
888 }
889 pub fn build_with_data(
891 self,
892 extra_data: BTreeMap<SmolStr, Data<S>>,
893 ) -> PinnedRecordView<S> {
894 PinnedRecordView {
895 cid: self._fields.0.unwrap(),
896 indexed_at: self._fields.1.unwrap(),
897 message: self._fields.2,
898 pinned_by: self._fields.3,
899 record: self._fields.4.unwrap(),
900 uri: self._fields.5.unwrap(),
901 extra_data: Some(extra_data),
902 }
903 }
904}