1#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14use jacquard_common::deps::bytes::Bytes;
15
16#[allow(unused_imports)]
17use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
18use jacquard_common::types::cid::CidLink;
19use jacquard_common::types::string::{Did, Handle, Tid, Datetime};
20use jacquard_derive::{IntoStatic, lexicon, open_union};
21use jacquard_lexicon::lexicon::LexiconDoc;
22use jacquard_lexicon::schema::LexiconSchema;
23
24#[allow(unused_imports)]
25use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
26use serde::{Serialize, Deserialize};
27use crate::com_atproto::sync::subscribe_repos;
28#[lexicon]
31#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
32#[serde(rename_all = "camelCase")]
33pub struct Account<'a> {
34 pub active: bool,
36 #[serde(borrow)]
37 pub did: Did<'a>,
38 pub seq: i64,
39 #[serde(skip_serializing_if = "Option::is_none")]
41 #[serde(borrow)]
42 pub status: Option<AccountStatus<'a>>,
43 pub time: Datetime,
44}
45
46#[derive(Debug, Clone, PartialEq, Eq, Hash)]
49pub enum AccountStatus<'a> {
50 Takendown,
51 Suspended,
52 Deleted,
53 Deactivated,
54 Desynchronized,
55 Throttled,
56 Other(CowStr<'a>),
57}
58
59impl<'a> AccountStatus<'a> {
60 pub fn as_str(&self) -> &str {
61 match self {
62 Self::Takendown => "takendown",
63 Self::Suspended => "suspended",
64 Self::Deleted => "deleted",
65 Self::Deactivated => "deactivated",
66 Self::Desynchronized => "desynchronized",
67 Self::Throttled => "throttled",
68 Self::Other(s) => s.as_ref(),
69 }
70 }
71}
72
73impl<'a> From<&'a str> for AccountStatus<'a> {
74 fn from(s: &'a str) -> Self {
75 match s {
76 "takendown" => Self::Takendown,
77 "suspended" => Self::Suspended,
78 "deleted" => Self::Deleted,
79 "deactivated" => Self::Deactivated,
80 "desynchronized" => Self::Desynchronized,
81 "throttled" => Self::Throttled,
82 _ => Self::Other(CowStr::from(s)),
83 }
84 }
85}
86
87impl<'a> From<String> for AccountStatus<'a> {
88 fn from(s: String) -> Self {
89 match s.as_str() {
90 "takendown" => Self::Takendown,
91 "suspended" => Self::Suspended,
92 "deleted" => Self::Deleted,
93 "deactivated" => Self::Deactivated,
94 "desynchronized" => Self::Desynchronized,
95 "throttled" => Self::Throttled,
96 _ => Self::Other(CowStr::from(s)),
97 }
98 }
99}
100
101impl<'a> core::fmt::Display for AccountStatus<'a> {
102 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
103 write!(f, "{}", self.as_str())
104 }
105}
106
107impl<'a> AsRef<str> for AccountStatus<'a> {
108 fn as_ref(&self) -> &str {
109 self.as_str()
110 }
111}
112
113impl<'a> serde::Serialize for AccountStatus<'a> {
114 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
115 where
116 S: serde::Serializer,
117 {
118 serializer.serialize_str(self.as_str())
119 }
120}
121
122impl<'de, 'a> serde::Deserialize<'de> for AccountStatus<'a>
123where
124 'de: 'a,
125{
126 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
127 where
128 D: serde::Deserializer<'de>,
129 {
130 let s = <&'de str>::deserialize(deserializer)?;
131 Ok(Self::from(s))
132 }
133}
134
135impl<'a> Default for AccountStatus<'a> {
136 fn default() -> Self {
137 Self::Other(Default::default())
138 }
139}
140
141impl jacquard_common::IntoStatic for AccountStatus<'_> {
142 type Output = AccountStatus<'static>;
143 fn into_static(self) -> Self::Output {
144 match self {
145 AccountStatus::Takendown => AccountStatus::Takendown,
146 AccountStatus::Suspended => AccountStatus::Suspended,
147 AccountStatus::Deleted => AccountStatus::Deleted,
148 AccountStatus::Deactivated => AccountStatus::Deactivated,
149 AccountStatus::Desynchronized => AccountStatus::Desynchronized,
150 AccountStatus::Throttled => AccountStatus::Throttled,
151 AccountStatus::Other(v) => AccountStatus::Other(v.into_static()),
152 }
153 }
154}
155
156#[lexicon]
159#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
160#[serde(rename_all = "camelCase")]
161pub struct Commit<'a> {
162 #[serde(borrow)]
163 pub blobs: Vec<CidLink<'a>>,
164 #[serde(with = "jacquard_common::serde_bytes_helper")]
166 pub blocks: Bytes,
167 #[serde(borrow)]
169 pub commit: CidLink<'a>,
170 #[serde(borrow)]
171 pub ops: Vec<subscribe_repos::RepoOp<'a>>,
172 #[serde(skip_serializing_if = "Option::is_none")]
174 #[serde(borrow)]
175 pub prev_data: Option<CidLink<'a>>,
176 pub rebase: bool,
178 #[serde(borrow)]
180 pub repo: Did<'a>,
181 pub rev: Tid,
183 pub seq: i64,
185 #[serde(skip_serializing_if = "Option::is_none")]
187 pub since: Option<Tid>,
188 pub time: Datetime,
190 pub too_big: bool,
192}
193
194#[lexicon]
197#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
198#[serde(rename_all = "camelCase")]
199pub struct Identity<'a> {
200 #[serde(borrow)]
201 pub did: Did<'a>,
202 #[serde(skip_serializing_if = "Option::is_none")]
204 #[serde(borrow)]
205 pub handle: Option<Handle<'a>>,
206 pub seq: i64,
207 pub time: Datetime,
208}
209
210
211#[lexicon]
212#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
213#[serde(rename_all = "camelCase")]
214pub struct Info<'a> {
215 #[serde(skip_serializing_if = "Option::is_none")]
216 #[serde(borrow)]
217 pub message: Option<CowStr<'a>>,
218 #[serde(borrow)]
219 pub name: InfoName<'a>,
220}
221
222
223#[derive(Debug, Clone, PartialEq, Eq, Hash)]
224pub enum InfoName<'a> {
225 OutdatedCursor,
226 Other(CowStr<'a>),
227}
228
229impl<'a> InfoName<'a> {
230 pub fn as_str(&self) -> &str {
231 match self {
232 Self::OutdatedCursor => "OutdatedCursor",
233 Self::Other(s) => s.as_ref(),
234 }
235 }
236}
237
238impl<'a> From<&'a str> for InfoName<'a> {
239 fn from(s: &'a str) -> Self {
240 match s {
241 "OutdatedCursor" => Self::OutdatedCursor,
242 _ => Self::Other(CowStr::from(s)),
243 }
244 }
245}
246
247impl<'a> From<String> for InfoName<'a> {
248 fn from(s: String) -> Self {
249 match s.as_str() {
250 "OutdatedCursor" => Self::OutdatedCursor,
251 _ => Self::Other(CowStr::from(s)),
252 }
253 }
254}
255
256impl<'a> core::fmt::Display for InfoName<'a> {
257 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
258 write!(f, "{}", self.as_str())
259 }
260}
261
262impl<'a> AsRef<str> for InfoName<'a> {
263 fn as_ref(&self) -> &str {
264 self.as_str()
265 }
266}
267
268impl<'a> serde::Serialize for InfoName<'a> {
269 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
270 where
271 S: serde::Serializer,
272 {
273 serializer.serialize_str(self.as_str())
274 }
275}
276
277impl<'de, 'a> serde::Deserialize<'de> for InfoName<'a>
278where
279 'de: 'a,
280{
281 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
282 where
283 D: serde::Deserializer<'de>,
284 {
285 let s = <&'de str>::deserialize(deserializer)?;
286 Ok(Self::from(s))
287 }
288}
289
290impl<'a> Default for InfoName<'a> {
291 fn default() -> Self {
292 Self::Other(Default::default())
293 }
294}
295
296impl jacquard_common::IntoStatic for InfoName<'_> {
297 type Output = InfoName<'static>;
298 fn into_static(self) -> Self::Output {
299 match self {
300 InfoName::OutdatedCursor => InfoName::OutdatedCursor,
301 InfoName::Other(v) => InfoName::Other(v.into_static()),
302 }
303 }
304}
305
306
307#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
308#[serde(rename_all = "camelCase")]
309pub struct SubscribeRepos {
310 #[serde(skip_serializing_if = "Option::is_none")]
311 pub cursor: Option<i64>,
312}
313
314
315#[open_union]
316#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
317#[serde(tag = "$type")]
318#[serde(bound(deserialize = "'de: 'a"))]
319pub enum SubscribeReposMessage<'a> {
320 #[serde(rename = "#commit")]
321 Commit(Box<subscribe_repos::Commit<'a>>),
322 #[serde(rename = "#sync")]
323 Sync(Box<subscribe_repos::Sync<'a>>),
324 #[serde(rename = "#identity")]
325 Identity(Box<subscribe_repos::Identity<'a>>),
326 #[serde(rename = "#account")]
327 Account(Box<subscribe_repos::Account<'a>>),
328 #[serde(rename = "#info")]
329 Info(Box<subscribe_repos::Info<'a>>),
330}
331
332impl<'a> SubscribeReposMessage<'a> {
333 pub fn decode_framed<'de: 'a>(
335 bytes: &'de [u8],
336 ) -> Result<SubscribeReposMessage<'a>, jacquard_common::error::DecodeError> {
337 let (header, body) = jacquard_common::xrpc::subscription::parse_event_header(
338 bytes,
339 )?;
340 match header.t.as_str() {
341 "#commit" => {
342 let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
343 body,
344 )?;
345 Ok(Self::Commit(Box::new(variant)))
346 }
347 "#sync" => {
348 let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
349 body,
350 )?;
351 Ok(Self::Sync(Box::new(variant)))
352 }
353 "#identity" => {
354 let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
355 body,
356 )?;
357 Ok(Self::Identity(Box::new(variant)))
358 }
359 "#account" => {
360 let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
361 body,
362 )?;
363 Ok(Self::Account(Box::new(variant)))
364 }
365 "#info" => {
366 let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
367 body,
368 )?;
369 Ok(Self::Info(Box::new(variant)))
370 }
371 unknown => {
372 Err(
373 jacquard_common::error::DecodeError::UnknownEventType(unknown.into()),
374 )
375 }
376 }
377 }
378}
379
380
381#[open_union]
382#[derive(
383 Serialize,
384 Deserialize,
385 Debug,
386 Clone,
387 PartialEq,
388 Eq,
389 thiserror::Error,
390 miette::Diagnostic,
391 IntoStatic
392)]
393
394#[serde(tag = "error", content = "message")]
395#[serde(bound(deserialize = "'de: 'a"))]
396pub enum SubscribeReposError<'a> {
397 #[serde(rename = "FutureCursor")]
398 FutureCursor(Option<CowStr<'a>>),
399 #[serde(rename = "ConsumerTooSlow")]
401 ConsumerTooSlow(Option<CowStr<'a>>),
402}
403
404impl core::fmt::Display for SubscribeReposError<'_> {
405 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
406 match self {
407 Self::FutureCursor(msg) => {
408 write!(f, "FutureCursor")?;
409 if let Some(msg) = msg {
410 write!(f, ": {}", msg)?;
411 }
412 Ok(())
413 }
414 Self::ConsumerTooSlow(msg) => {
415 write!(f, "ConsumerTooSlow")?;
416 if let Some(msg) = msg {
417 write!(f, ": {}", msg)?;
418 }
419 Ok(())
420 }
421 Self::Unknown(err) => write!(f, "Unknown error: {:?}", err),
422 }
423 }
424}
425
426#[lexicon]
429#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
430#[serde(rename_all = "camelCase")]
431pub struct RepoOp<'a> {
432 #[serde(borrow)]
433 pub action: RepoOpAction<'a>,
434 #[serde(skip_serializing_if = "Option::is_none")]
436 #[serde(borrow)]
437 pub cid: Option<CidLink<'a>>,
438 #[serde(borrow)]
439 pub path: CowStr<'a>,
440 #[serde(skip_serializing_if = "Option::is_none")]
442 #[serde(borrow)]
443 pub prev: Option<CidLink<'a>>,
444}
445
446
447#[derive(Debug, Clone, PartialEq, Eq, Hash)]
448pub enum RepoOpAction<'a> {
449 Create,
450 Update,
451 Delete,
452 Other(CowStr<'a>),
453}
454
455impl<'a> RepoOpAction<'a> {
456 pub fn as_str(&self) -> &str {
457 match self {
458 Self::Create => "create",
459 Self::Update => "update",
460 Self::Delete => "delete",
461 Self::Other(s) => s.as_ref(),
462 }
463 }
464}
465
466impl<'a> From<&'a str> for RepoOpAction<'a> {
467 fn from(s: &'a str) -> Self {
468 match s {
469 "create" => Self::Create,
470 "update" => Self::Update,
471 "delete" => Self::Delete,
472 _ => Self::Other(CowStr::from(s)),
473 }
474 }
475}
476
477impl<'a> From<String> for RepoOpAction<'a> {
478 fn from(s: String) -> Self {
479 match s.as_str() {
480 "create" => Self::Create,
481 "update" => Self::Update,
482 "delete" => Self::Delete,
483 _ => Self::Other(CowStr::from(s)),
484 }
485 }
486}
487
488impl<'a> core::fmt::Display for RepoOpAction<'a> {
489 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
490 write!(f, "{}", self.as_str())
491 }
492}
493
494impl<'a> AsRef<str> for RepoOpAction<'a> {
495 fn as_ref(&self) -> &str {
496 self.as_str()
497 }
498}
499
500impl<'a> serde::Serialize for RepoOpAction<'a> {
501 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
502 where
503 S: serde::Serializer,
504 {
505 serializer.serialize_str(self.as_str())
506 }
507}
508
509impl<'de, 'a> serde::Deserialize<'de> for RepoOpAction<'a>
510where
511 'de: 'a,
512{
513 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
514 where
515 D: serde::Deserializer<'de>,
516 {
517 let s = <&'de str>::deserialize(deserializer)?;
518 Ok(Self::from(s))
519 }
520}
521
522impl<'a> Default for RepoOpAction<'a> {
523 fn default() -> Self {
524 Self::Other(Default::default())
525 }
526}
527
528impl jacquard_common::IntoStatic for RepoOpAction<'_> {
529 type Output = RepoOpAction<'static>;
530 fn into_static(self) -> Self::Output {
531 match self {
532 RepoOpAction::Create => RepoOpAction::Create,
533 RepoOpAction::Update => RepoOpAction::Update,
534 RepoOpAction::Delete => RepoOpAction::Delete,
535 RepoOpAction::Other(v) => RepoOpAction::Other(v.into_static()),
536 }
537 }
538}
539
540#[lexicon]
543#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
544#[serde(rename_all = "camelCase")]
545pub struct Sync<'a> {
546 #[serde(with = "jacquard_common::serde_bytes_helper")]
548 pub blocks: Bytes,
549 #[serde(borrow)]
551 pub did: Did<'a>,
552 #[serde(borrow)]
554 pub rev: CowStr<'a>,
555 pub seq: i64,
557 pub time: Datetime,
559}
560
561impl<'a> LexiconSchema for Account<'a> {
562 fn nsid() -> &'static str {
563 "com.atproto.sync.subscribeRepos"
564 }
565 fn def_name() -> &'static str {
566 "account"
567 }
568 fn lexicon_doc() -> LexiconDoc<'static> {
569 lexicon_doc_com_atproto_sync_subscribeRepos()
570 }
571 fn validate(&self) -> Result<(), ConstraintError> {
572 Ok(())
573 }
574}
575
576impl<'a> LexiconSchema for Commit<'a> {
577 fn nsid() -> &'static str {
578 "com.atproto.sync.subscribeRepos"
579 }
580 fn def_name() -> &'static str {
581 "commit"
582 }
583 fn lexicon_doc() -> LexiconDoc<'static> {
584 lexicon_doc_com_atproto_sync_subscribeRepos()
585 }
586 fn validate(&self) -> Result<(), ConstraintError> {
587 {
588 let value = &self.ops;
589 #[allow(unused_comparisons)]
590 if value.len() > 200usize {
591 return Err(ConstraintError::MaxLength {
592 path: ValidationPath::from_field("ops"),
593 max: 200usize,
594 actual: value.len(),
595 });
596 }
597 }
598 Ok(())
599 }
600}
601
602impl<'a> LexiconSchema for Identity<'a> {
603 fn nsid() -> &'static str {
604 "com.atproto.sync.subscribeRepos"
605 }
606 fn def_name() -> &'static str {
607 "identity"
608 }
609 fn lexicon_doc() -> LexiconDoc<'static> {
610 lexicon_doc_com_atproto_sync_subscribeRepos()
611 }
612 fn validate(&self) -> Result<(), ConstraintError> {
613 Ok(())
614 }
615}
616
617impl<'a> LexiconSchema for Info<'a> {
618 fn nsid() -> &'static str {
619 "com.atproto.sync.subscribeRepos"
620 }
621 fn def_name() -> &'static str {
622 "info"
623 }
624 fn lexicon_doc() -> LexiconDoc<'static> {
625 lexicon_doc_com_atproto_sync_subscribeRepos()
626 }
627 fn validate(&self) -> Result<(), ConstraintError> {
628 Ok(())
629 }
630}
631
632pub struct SubscribeReposStream;
635impl jacquard_common::xrpc::SubscriptionResp for SubscribeReposStream {
636 const NSID: &'static str = "com.atproto.sync.subscribeRepos";
637 const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor;
638 type Message<'de> = SubscribeReposMessage<'de>;
639 type Error<'de> = SubscribeReposError<'de>;
640 fn decode_message<'de>(
641 bytes: &'de [u8],
642 ) -> Result<Self::Message<'de>, jacquard_common::error::DecodeError> {
643 SubscribeReposMessage::decode_framed(bytes)
644 }
645}
646
647impl jacquard_common::xrpc::XrpcSubscription for SubscribeRepos {
648 const NSID: &'static str = "com.atproto.sync.subscribeRepos";
649 const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor;
650 type Stream = SubscribeReposStream;
651}
652
653pub struct SubscribeReposEndpoint;
654impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeReposEndpoint {
655 const PATH: &'static str = "/xrpc/com.atproto.sync.subscribeRepos";
656 const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::DagCbor;
657 type Params<'de> = SubscribeRepos;
658 type Stream = SubscribeReposStream;
659}
660
661impl<'a> LexiconSchema for RepoOp<'a> {
662 fn nsid() -> &'static str {
663 "com.atproto.sync.subscribeRepos"
664 }
665 fn def_name() -> &'static str {
666 "repoOp"
667 }
668 fn lexicon_doc() -> LexiconDoc<'static> {
669 lexicon_doc_com_atproto_sync_subscribeRepos()
670 }
671 fn validate(&self) -> Result<(), ConstraintError> {
672 Ok(())
673 }
674}
675
676impl<'a> LexiconSchema for Sync<'a> {
677 fn nsid() -> &'static str {
678 "com.atproto.sync.subscribeRepos"
679 }
680 fn def_name() -> &'static str {
681 "sync"
682 }
683 fn lexicon_doc() -> LexiconDoc<'static> {
684 lexicon_doc_com_atproto_sync_subscribeRepos()
685 }
686 fn validate(&self) -> Result<(), ConstraintError> {
687 Ok(())
688 }
689}
690
691pub mod account_state {
692
693 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
694 #[allow(unused)]
695 use ::core::marker::PhantomData;
696 mod sealed {
697 pub trait Sealed {}
698 }
699 pub trait State: sealed::Sealed {
701 type Did;
702 type Active;
703 type Time;
704 type Seq;
705 }
706 pub struct Empty(());
708 impl sealed::Sealed for Empty {}
709 impl State for Empty {
710 type Did = Unset;
711 type Active = Unset;
712 type Time = Unset;
713 type Seq = Unset;
714 }
715 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
717 impl<S: State> sealed::Sealed for SetDid<S> {}
718 impl<S: State> State for SetDid<S> {
719 type Did = Set<members::did>;
720 type Active = S::Active;
721 type Time = S::Time;
722 type Seq = S::Seq;
723 }
724 pub struct SetActive<S: State = Empty>(PhantomData<fn() -> S>);
726 impl<S: State> sealed::Sealed for SetActive<S> {}
727 impl<S: State> State for SetActive<S> {
728 type Did = S::Did;
729 type Active = Set<members::active>;
730 type Time = S::Time;
731 type Seq = S::Seq;
732 }
733 pub struct SetTime<S: State = Empty>(PhantomData<fn() -> S>);
735 impl<S: State> sealed::Sealed for SetTime<S> {}
736 impl<S: State> State for SetTime<S> {
737 type Did = S::Did;
738 type Active = S::Active;
739 type Time = Set<members::time>;
740 type Seq = S::Seq;
741 }
742 pub struct SetSeq<S: State = Empty>(PhantomData<fn() -> S>);
744 impl<S: State> sealed::Sealed for SetSeq<S> {}
745 impl<S: State> State for SetSeq<S> {
746 type Did = S::Did;
747 type Active = S::Active;
748 type Time = S::Time;
749 type Seq = Set<members::seq>;
750 }
751 #[allow(non_camel_case_types)]
753 pub mod members {
754 pub struct did(());
756 pub struct active(());
758 pub struct time(());
760 pub struct seq(());
762 }
763}
764
765pub struct AccountBuilder<'a, S: account_state::State> {
767 _state: PhantomData<fn() -> S>,
768 _fields: (
769 Option<bool>,
770 Option<Did<'a>>,
771 Option<i64>,
772 Option<AccountStatus<'a>>,
773 Option<Datetime>,
774 ),
775 _lifetime: PhantomData<&'a ()>,
776}
777
778impl<'a> Account<'a> {
779 pub fn new() -> AccountBuilder<'a, account_state::Empty> {
781 AccountBuilder::new()
782 }
783}
784
785impl<'a> AccountBuilder<'a, account_state::Empty> {
786 pub fn new() -> Self {
788 AccountBuilder {
789 _state: PhantomData,
790 _fields: (None, None, None, None, None),
791 _lifetime: PhantomData,
792 }
793 }
794}
795
796impl<'a, S> AccountBuilder<'a, S>
797where
798 S: account_state::State,
799 S::Active: account_state::IsUnset,
800{
801 pub fn active(
803 mut self,
804 value: impl Into<bool>,
805 ) -> AccountBuilder<'a, account_state::SetActive<S>> {
806 self._fields.0 = Option::Some(value.into());
807 AccountBuilder {
808 _state: PhantomData,
809 _fields: self._fields,
810 _lifetime: PhantomData,
811 }
812 }
813}
814
815impl<'a, S> AccountBuilder<'a, S>
816where
817 S: account_state::State,
818 S::Did: account_state::IsUnset,
819{
820 pub fn did(
822 mut self,
823 value: impl Into<Did<'a>>,
824 ) -> AccountBuilder<'a, account_state::SetDid<S>> {
825 self._fields.1 = Option::Some(value.into());
826 AccountBuilder {
827 _state: PhantomData,
828 _fields: self._fields,
829 _lifetime: PhantomData,
830 }
831 }
832}
833
834impl<'a, S> AccountBuilder<'a, S>
835where
836 S: account_state::State,
837 S::Seq: account_state::IsUnset,
838{
839 pub fn seq(
841 mut self,
842 value: impl Into<i64>,
843 ) -> AccountBuilder<'a, account_state::SetSeq<S>> {
844 self._fields.2 = Option::Some(value.into());
845 AccountBuilder {
846 _state: PhantomData,
847 _fields: self._fields,
848 _lifetime: PhantomData,
849 }
850 }
851}
852
853impl<'a, S: account_state::State> AccountBuilder<'a, S> {
854 pub fn status(mut self, value: impl Into<Option<AccountStatus<'a>>>) -> Self {
856 self._fields.3 = value.into();
857 self
858 }
859 pub fn maybe_status(mut self, value: Option<AccountStatus<'a>>) -> Self {
861 self._fields.3 = value;
862 self
863 }
864}
865
866impl<'a, S> AccountBuilder<'a, S>
867where
868 S: account_state::State,
869 S::Time: account_state::IsUnset,
870{
871 pub fn time(
873 mut self,
874 value: impl Into<Datetime>,
875 ) -> AccountBuilder<'a, account_state::SetTime<S>> {
876 self._fields.4 = Option::Some(value.into());
877 AccountBuilder {
878 _state: PhantomData,
879 _fields: self._fields,
880 _lifetime: PhantomData,
881 }
882 }
883}
884
885impl<'a, S> AccountBuilder<'a, S>
886where
887 S: account_state::State,
888 S::Did: account_state::IsSet,
889 S::Active: account_state::IsSet,
890 S::Time: account_state::IsSet,
891 S::Seq: account_state::IsSet,
892{
893 pub fn build(self) -> Account<'a> {
895 Account {
896 active: self._fields.0.unwrap(),
897 did: self._fields.1.unwrap(),
898 seq: self._fields.2.unwrap(),
899 status: self._fields.3,
900 time: self._fields.4.unwrap(),
901 extra_data: Default::default(),
902 }
903 }
904 pub fn build_with_data(
906 self,
907 extra_data: BTreeMap<
908 jacquard_common::deps::smol_str::SmolStr,
909 jacquard_common::types::value::Data<'a>,
910 >,
911 ) -> Account<'a> {
912 Account {
913 active: self._fields.0.unwrap(),
914 did: self._fields.1.unwrap(),
915 seq: self._fields.2.unwrap(),
916 status: self._fields.3,
917 time: self._fields.4.unwrap(),
918 extra_data: Some(extra_data),
919 }
920 }
921}
922
923fn lexicon_doc_com_atproto_sync_subscribeRepos() -> LexiconDoc<'static> {
924 #[allow(unused_imports)]
925 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
926 use jacquard_lexicon::lexicon::*;
927 use alloc::collections::BTreeMap;
928 LexiconDoc {
929 lexicon: Lexicon::Lexicon1,
930 id: CowStr::new_static("com.atproto.sync.subscribeRepos"),
931 defs: {
932 let mut map = BTreeMap::new();
933 map.insert(
934 SmolStr::new_static("account"),
935 LexUserType::Object(LexObject {
936 description: Some(
937 CowStr::new_static(
938 "Represents a change to an account's status on a host (eg, PDS or Relay). The semantics of this event are that the status is at the host which emitted the event, not necessarily that at the currently active PDS. Eg, a Relay takedown would emit a takedown with active=false, even if the PDS is still active.",
939 ),
940 ),
941 required: Some(
942 vec![
943 SmolStr::new_static("seq"), SmolStr::new_static("did"),
944 SmolStr::new_static("time"), SmolStr::new_static("active")
945 ],
946 ),
947 properties: {
948 #[allow(unused_mut)]
949 let mut map = BTreeMap::new();
950 map.insert(
951 SmolStr::new_static("active"),
952 LexObjectProperty::Boolean(LexBoolean {
953 ..Default::default()
954 }),
955 );
956 map.insert(
957 SmolStr::new_static("did"),
958 LexObjectProperty::String(LexString {
959 format: Some(LexStringFormat::Did),
960 ..Default::default()
961 }),
962 );
963 map.insert(
964 SmolStr::new_static("seq"),
965 LexObjectProperty::Integer(LexInteger {
966 ..Default::default()
967 }),
968 );
969 map.insert(
970 SmolStr::new_static("status"),
971 LexObjectProperty::String(LexString {
972 description: Some(
973 CowStr::new_static(
974 "If active=false, this optional field indicates a reason for why the account is not active.",
975 ),
976 ),
977 ..Default::default()
978 }),
979 );
980 map.insert(
981 SmolStr::new_static("time"),
982 LexObjectProperty::String(LexString {
983 format: Some(LexStringFormat::Datetime),
984 ..Default::default()
985 }),
986 );
987 map
988 },
989 ..Default::default()
990 }),
991 );
992 map.insert(
993 SmolStr::new_static("commit"),
994 LexUserType::Object(LexObject {
995 description: Some(
996 CowStr::new_static(
997 "Represents an update of repository state. Note that empty commits are allowed, which include no repo data changes, but an update to rev and signature.",
998 ),
999 ),
1000 required: Some(
1001 vec![
1002 SmolStr::new_static("seq"), SmolStr::new_static("rebase"),
1003 SmolStr::new_static("tooBig"), SmolStr::new_static("repo"),
1004 SmolStr::new_static("commit"), SmolStr::new_static("rev"),
1005 SmolStr::new_static("since"), SmolStr::new_static("blocks"),
1006 SmolStr::new_static("ops"), SmolStr::new_static("blobs"),
1007 SmolStr::new_static("time")
1008 ],
1009 ),
1010 properties: {
1011 #[allow(unused_mut)]
1012 let mut map = BTreeMap::new();
1013 map.insert(
1014 SmolStr::new_static("blobs"),
1015 LexObjectProperty::Array(LexArray {
1016 items: LexArrayItem::CidLink(LexCidLink {
1017 ..Default::default()
1018 }),
1019 ..Default::default()
1020 }),
1021 );
1022 map.insert(
1023 SmolStr::new_static("blocks"),
1024 LexObjectProperty::Bytes(LexBytes {
1025 max_length: Some(2000000usize),
1026 ..Default::default()
1027 }),
1028 );
1029 map.insert(
1030 SmolStr::new_static("commit"),
1031 LexObjectProperty::CidLink(LexCidLink {
1032 ..Default::default()
1033 }),
1034 );
1035 map.insert(
1036 SmolStr::new_static("ops"),
1037 LexObjectProperty::Array(LexArray {
1038 items: LexArrayItem::Ref(LexRef {
1039 r#ref: CowStr::new_static("#repoOp"),
1040 ..Default::default()
1041 }),
1042 max_length: Some(200usize),
1043 ..Default::default()
1044 }),
1045 );
1046 map.insert(
1047 SmolStr::new_static("prevData"),
1048 LexObjectProperty::CidLink(LexCidLink {
1049 ..Default::default()
1050 }),
1051 );
1052 map.insert(
1053 SmolStr::new_static("rebase"),
1054 LexObjectProperty::Boolean(LexBoolean {
1055 ..Default::default()
1056 }),
1057 );
1058 map.insert(
1059 SmolStr::new_static("repo"),
1060 LexObjectProperty::String(LexString {
1061 description: Some(
1062 CowStr::new_static(
1063 "The repo this event comes from. Note that all other message types name this field 'did'.",
1064 ),
1065 ),
1066 format: Some(LexStringFormat::Did),
1067 ..Default::default()
1068 }),
1069 );
1070 map.insert(
1071 SmolStr::new_static("rev"),
1072 LexObjectProperty::String(LexString {
1073 description: Some(
1074 CowStr::new_static(
1075 "The rev of the emitted commit. Note that this information is also in the commit object included in blocks, unless this is a tooBig event.",
1076 ),
1077 ),
1078 format: Some(LexStringFormat::Tid),
1079 ..Default::default()
1080 }),
1081 );
1082 map.insert(
1083 SmolStr::new_static("seq"),
1084 LexObjectProperty::Integer(LexInteger {
1085 ..Default::default()
1086 }),
1087 );
1088 map.insert(
1089 SmolStr::new_static("since"),
1090 LexObjectProperty::String(LexString {
1091 description: Some(
1092 CowStr::new_static(
1093 "The rev of the last emitted commit from this repo (if any).",
1094 ),
1095 ),
1096 format: Some(LexStringFormat::Tid),
1097 ..Default::default()
1098 }),
1099 );
1100 map.insert(
1101 SmolStr::new_static("time"),
1102 LexObjectProperty::String(LexString {
1103 description: Some(
1104 CowStr::new_static(
1105 "Timestamp of when this message was originally broadcast.",
1106 ),
1107 ),
1108 format: Some(LexStringFormat::Datetime),
1109 ..Default::default()
1110 }),
1111 );
1112 map.insert(
1113 SmolStr::new_static("tooBig"),
1114 LexObjectProperty::Boolean(LexBoolean {
1115 ..Default::default()
1116 }),
1117 );
1118 map
1119 },
1120 ..Default::default()
1121 }),
1122 );
1123 map.insert(
1124 SmolStr::new_static("identity"),
1125 LexUserType::Object(LexObject {
1126 description: Some(
1127 CowStr::new_static(
1128 "Represents a change to an account's identity. Could be an updated handle, signing key, or pds hosting endpoint. Serves as a prod to all downstream services to refresh their identity cache.",
1129 ),
1130 ),
1131 required: Some(
1132 vec![
1133 SmolStr::new_static("seq"), SmolStr::new_static("did"),
1134 SmolStr::new_static("time")
1135 ],
1136 ),
1137 properties: {
1138 #[allow(unused_mut)]
1139 let mut map = BTreeMap::new();
1140 map.insert(
1141 SmolStr::new_static("did"),
1142 LexObjectProperty::String(LexString {
1143 format: Some(LexStringFormat::Did),
1144 ..Default::default()
1145 }),
1146 );
1147 map.insert(
1148 SmolStr::new_static("handle"),
1149 LexObjectProperty::String(LexString {
1150 description: Some(
1151 CowStr::new_static(
1152 "The current handle for the account, or 'handle.invalid' if validation fails. This field is optional, might have been validated or passed-through from an upstream source. Semantics and behaviors for PDS vs Relay may evolve in the future; see atproto specs for more details.",
1153 ),
1154 ),
1155 format: Some(LexStringFormat::Handle),
1156 ..Default::default()
1157 }),
1158 );
1159 map.insert(
1160 SmolStr::new_static("seq"),
1161 LexObjectProperty::Integer(LexInteger {
1162 ..Default::default()
1163 }),
1164 );
1165 map.insert(
1166 SmolStr::new_static("time"),
1167 LexObjectProperty::String(LexString {
1168 format: Some(LexStringFormat::Datetime),
1169 ..Default::default()
1170 }),
1171 );
1172 map
1173 },
1174 ..Default::default()
1175 }),
1176 );
1177 map.insert(
1178 SmolStr::new_static("info"),
1179 LexUserType::Object(LexObject {
1180 required: Some(vec![SmolStr::new_static("name")]),
1181 properties: {
1182 #[allow(unused_mut)]
1183 let mut map = BTreeMap::new();
1184 map.insert(
1185 SmolStr::new_static("message"),
1186 LexObjectProperty::String(LexString { ..Default::default() }),
1187 );
1188 map.insert(
1189 SmolStr::new_static("name"),
1190 LexObjectProperty::String(LexString { ..Default::default() }),
1191 );
1192 map
1193 },
1194 ..Default::default()
1195 }),
1196 );
1197 map.insert(
1198 SmolStr::new_static("main"),
1199 LexUserType::XrpcSubscription(LexXrpcSubscription {
1200 parameters: Some(
1201 LexXrpcSubscriptionParameter::Params(LexXrpcParameters {
1202 properties: {
1203 #[allow(unused_mut)]
1204 let mut map = BTreeMap::new();
1205 map.insert(
1206 SmolStr::new_static("cursor"),
1207 LexXrpcParametersProperty::Integer(LexInteger {
1208 ..Default::default()
1209 }),
1210 );
1211 map
1212 },
1213 ..Default::default()
1214 }),
1215 ),
1216 ..Default::default()
1217 }),
1218 );
1219 map.insert(
1220 SmolStr::new_static("repoOp"),
1221 LexUserType::Object(LexObject {
1222 description: Some(
1223 CowStr::new_static(
1224 "A repo operation, ie a mutation of a single record.",
1225 ),
1226 ),
1227 required: Some(
1228 vec![
1229 SmolStr::new_static("action"), SmolStr::new_static("path"),
1230 SmolStr::new_static("cid")
1231 ],
1232 ),
1233 properties: {
1234 #[allow(unused_mut)]
1235 let mut map = BTreeMap::new();
1236 map.insert(
1237 SmolStr::new_static("action"),
1238 LexObjectProperty::String(LexString { ..Default::default() }),
1239 );
1240 map.insert(
1241 SmolStr::new_static("cid"),
1242 LexObjectProperty::CidLink(LexCidLink {
1243 ..Default::default()
1244 }),
1245 );
1246 map.insert(
1247 SmolStr::new_static("path"),
1248 LexObjectProperty::String(LexString { ..Default::default() }),
1249 );
1250 map.insert(
1251 SmolStr::new_static("prev"),
1252 LexObjectProperty::CidLink(LexCidLink {
1253 ..Default::default()
1254 }),
1255 );
1256 map
1257 },
1258 ..Default::default()
1259 }),
1260 );
1261 map.insert(
1262 SmolStr::new_static("sync"),
1263 LexUserType::Object(LexObject {
1264 description: Some(
1265 CowStr::new_static(
1266 "Updates the repo to a new state, without necessarily including that state on the firehose. Used to recover from broken commit streams, data loss incidents, or in situations where upstream host does not know recent state of the repository.",
1267 ),
1268 ),
1269 required: Some(
1270 vec![
1271 SmolStr::new_static("seq"), SmolStr::new_static("did"),
1272 SmolStr::new_static("blocks"), SmolStr::new_static("rev"),
1273 SmolStr::new_static("time")
1274 ],
1275 ),
1276 properties: {
1277 #[allow(unused_mut)]
1278 let mut map = BTreeMap::new();
1279 map.insert(
1280 SmolStr::new_static("blocks"),
1281 LexObjectProperty::Bytes(LexBytes {
1282 max_length: Some(10000usize),
1283 ..Default::default()
1284 }),
1285 );
1286 map.insert(
1287 SmolStr::new_static("did"),
1288 LexObjectProperty::String(LexString {
1289 description: Some(
1290 CowStr::new_static(
1291 "The account this repo event corresponds to. Must match that in the commit object.",
1292 ),
1293 ),
1294 format: Some(LexStringFormat::Did),
1295 ..Default::default()
1296 }),
1297 );
1298 map.insert(
1299 SmolStr::new_static("rev"),
1300 LexObjectProperty::String(LexString {
1301 description: Some(
1302 CowStr::new_static(
1303 "The rev of the commit. This value must match that in the commit object.",
1304 ),
1305 ),
1306 ..Default::default()
1307 }),
1308 );
1309 map.insert(
1310 SmolStr::new_static("seq"),
1311 LexObjectProperty::Integer(LexInteger {
1312 ..Default::default()
1313 }),
1314 );
1315 map.insert(
1316 SmolStr::new_static("time"),
1317 LexObjectProperty::String(LexString {
1318 description: Some(
1319 CowStr::new_static(
1320 "Timestamp of when this message was originally broadcast.",
1321 ),
1322 ),
1323 format: Some(LexStringFormat::Datetime),
1324 ..Default::default()
1325 }),
1326 );
1327 map
1328 },
1329 ..Default::default()
1330 }),
1331 );
1332 map
1333 },
1334 ..Default::default()
1335 }
1336}
1337
1338pub mod commit_state {
1339
1340 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1341 #[allow(unused)]
1342 use ::core::marker::PhantomData;
1343 mod sealed {
1344 pub trait Sealed {}
1345 }
1346 pub trait State: sealed::Sealed {
1348 type Seq;
1349 type TooBig;
1350 type Rev;
1351 type Repo;
1352 type Blocks;
1353 type Ops;
1354 type Blobs;
1355 type Commit;
1356 type Time;
1357 type Rebase;
1358 }
1359 pub struct Empty(());
1361 impl sealed::Sealed for Empty {}
1362 impl State for Empty {
1363 type Seq = Unset;
1364 type TooBig = Unset;
1365 type Rev = Unset;
1366 type Repo = Unset;
1367 type Blocks = Unset;
1368 type Ops = Unset;
1369 type Blobs = Unset;
1370 type Commit = Unset;
1371 type Time = Unset;
1372 type Rebase = Unset;
1373 }
1374 pub struct SetSeq<S: State = Empty>(PhantomData<fn() -> S>);
1376 impl<S: State> sealed::Sealed for SetSeq<S> {}
1377 impl<S: State> State for SetSeq<S> {
1378 type Seq = Set<members::seq>;
1379 type TooBig = S::TooBig;
1380 type Rev = S::Rev;
1381 type Repo = S::Repo;
1382 type Blocks = S::Blocks;
1383 type Ops = S::Ops;
1384 type Blobs = S::Blobs;
1385 type Commit = S::Commit;
1386 type Time = S::Time;
1387 type Rebase = S::Rebase;
1388 }
1389 pub struct SetTooBig<S: State = Empty>(PhantomData<fn() -> S>);
1391 impl<S: State> sealed::Sealed for SetTooBig<S> {}
1392 impl<S: State> State for SetTooBig<S> {
1393 type Seq = S::Seq;
1394 type TooBig = Set<members::too_big>;
1395 type Rev = S::Rev;
1396 type Repo = S::Repo;
1397 type Blocks = S::Blocks;
1398 type Ops = S::Ops;
1399 type Blobs = S::Blobs;
1400 type Commit = S::Commit;
1401 type Time = S::Time;
1402 type Rebase = S::Rebase;
1403 }
1404 pub struct SetRev<S: State = Empty>(PhantomData<fn() -> S>);
1406 impl<S: State> sealed::Sealed for SetRev<S> {}
1407 impl<S: State> State for SetRev<S> {
1408 type Seq = S::Seq;
1409 type TooBig = S::TooBig;
1410 type Rev = Set<members::rev>;
1411 type Repo = S::Repo;
1412 type Blocks = S::Blocks;
1413 type Ops = S::Ops;
1414 type Blobs = S::Blobs;
1415 type Commit = S::Commit;
1416 type Time = S::Time;
1417 type Rebase = S::Rebase;
1418 }
1419 pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
1421 impl<S: State> sealed::Sealed for SetRepo<S> {}
1422 impl<S: State> State for SetRepo<S> {
1423 type Seq = S::Seq;
1424 type TooBig = S::TooBig;
1425 type Rev = S::Rev;
1426 type Repo = Set<members::repo>;
1427 type Blocks = S::Blocks;
1428 type Ops = S::Ops;
1429 type Blobs = S::Blobs;
1430 type Commit = S::Commit;
1431 type Time = S::Time;
1432 type Rebase = S::Rebase;
1433 }
1434 pub struct SetBlocks<S: State = Empty>(PhantomData<fn() -> S>);
1436 impl<S: State> sealed::Sealed for SetBlocks<S> {}
1437 impl<S: State> State for SetBlocks<S> {
1438 type Seq = S::Seq;
1439 type TooBig = S::TooBig;
1440 type Rev = S::Rev;
1441 type Repo = S::Repo;
1442 type Blocks = Set<members::blocks>;
1443 type Ops = S::Ops;
1444 type Blobs = S::Blobs;
1445 type Commit = S::Commit;
1446 type Time = S::Time;
1447 type Rebase = S::Rebase;
1448 }
1449 pub struct SetOps<S: State = Empty>(PhantomData<fn() -> S>);
1451 impl<S: State> sealed::Sealed for SetOps<S> {}
1452 impl<S: State> State for SetOps<S> {
1453 type Seq = S::Seq;
1454 type TooBig = S::TooBig;
1455 type Rev = S::Rev;
1456 type Repo = S::Repo;
1457 type Blocks = S::Blocks;
1458 type Ops = Set<members::ops>;
1459 type Blobs = S::Blobs;
1460 type Commit = S::Commit;
1461 type Time = S::Time;
1462 type Rebase = S::Rebase;
1463 }
1464 pub struct SetBlobs<S: State = Empty>(PhantomData<fn() -> S>);
1466 impl<S: State> sealed::Sealed for SetBlobs<S> {}
1467 impl<S: State> State for SetBlobs<S> {
1468 type Seq = S::Seq;
1469 type TooBig = S::TooBig;
1470 type Rev = S::Rev;
1471 type Repo = S::Repo;
1472 type Blocks = S::Blocks;
1473 type Ops = S::Ops;
1474 type Blobs = Set<members::blobs>;
1475 type Commit = S::Commit;
1476 type Time = S::Time;
1477 type Rebase = S::Rebase;
1478 }
1479 pub struct SetCommit<S: State = Empty>(PhantomData<fn() -> S>);
1481 impl<S: State> sealed::Sealed for SetCommit<S> {}
1482 impl<S: State> State for SetCommit<S> {
1483 type Seq = S::Seq;
1484 type TooBig = S::TooBig;
1485 type Rev = S::Rev;
1486 type Repo = S::Repo;
1487 type Blocks = S::Blocks;
1488 type Ops = S::Ops;
1489 type Blobs = S::Blobs;
1490 type Commit = Set<members::commit>;
1491 type Time = S::Time;
1492 type Rebase = S::Rebase;
1493 }
1494 pub struct SetTime<S: State = Empty>(PhantomData<fn() -> S>);
1496 impl<S: State> sealed::Sealed for SetTime<S> {}
1497 impl<S: State> State for SetTime<S> {
1498 type Seq = S::Seq;
1499 type TooBig = S::TooBig;
1500 type Rev = S::Rev;
1501 type Repo = S::Repo;
1502 type Blocks = S::Blocks;
1503 type Ops = S::Ops;
1504 type Blobs = S::Blobs;
1505 type Commit = S::Commit;
1506 type Time = Set<members::time>;
1507 type Rebase = S::Rebase;
1508 }
1509 pub struct SetRebase<S: State = Empty>(PhantomData<fn() -> S>);
1511 impl<S: State> sealed::Sealed for SetRebase<S> {}
1512 impl<S: State> State for SetRebase<S> {
1513 type Seq = S::Seq;
1514 type TooBig = S::TooBig;
1515 type Rev = S::Rev;
1516 type Repo = S::Repo;
1517 type Blocks = S::Blocks;
1518 type Ops = S::Ops;
1519 type Blobs = S::Blobs;
1520 type Commit = S::Commit;
1521 type Time = S::Time;
1522 type Rebase = Set<members::rebase>;
1523 }
1524 #[allow(non_camel_case_types)]
1526 pub mod members {
1527 pub struct seq(());
1529 pub struct too_big(());
1531 pub struct rev(());
1533 pub struct repo(());
1535 pub struct blocks(());
1537 pub struct ops(());
1539 pub struct blobs(());
1541 pub struct commit(());
1543 pub struct time(());
1545 pub struct rebase(());
1547 }
1548}
1549
1550pub struct CommitBuilder<'a, S: commit_state::State> {
1552 _state: PhantomData<fn() -> S>,
1553 _fields: (
1554 Option<Vec<CidLink<'a>>>,
1555 Option<Bytes>,
1556 Option<CidLink<'a>>,
1557 Option<Vec<subscribe_repos::RepoOp<'a>>>,
1558 Option<CidLink<'a>>,
1559 Option<bool>,
1560 Option<Did<'a>>,
1561 Option<Tid>,
1562 Option<i64>,
1563 Option<Tid>,
1564 Option<Datetime>,
1565 Option<bool>,
1566 ),
1567 _lifetime: PhantomData<&'a ()>,
1568}
1569
1570impl<'a> Commit<'a> {
1571 pub fn new() -> CommitBuilder<'a, commit_state::Empty> {
1573 CommitBuilder::new()
1574 }
1575}
1576
1577impl<'a> CommitBuilder<'a, commit_state::Empty> {
1578 pub fn new() -> Self {
1580 CommitBuilder {
1581 _state: PhantomData,
1582 _fields: (
1583 None,
1584 None,
1585 None,
1586 None,
1587 None,
1588 None,
1589 None,
1590 None,
1591 None,
1592 None,
1593 None,
1594 None,
1595 ),
1596 _lifetime: PhantomData,
1597 }
1598 }
1599}
1600
1601impl<'a, S> CommitBuilder<'a, S>
1602where
1603 S: commit_state::State,
1604 S::Blobs: commit_state::IsUnset,
1605{
1606 pub fn blobs(
1608 mut self,
1609 value: impl Into<Vec<CidLink<'a>>>,
1610 ) -> CommitBuilder<'a, commit_state::SetBlobs<S>> {
1611 self._fields.0 = Option::Some(value.into());
1612 CommitBuilder {
1613 _state: PhantomData,
1614 _fields: self._fields,
1615 _lifetime: PhantomData,
1616 }
1617 }
1618}
1619
1620impl<'a, S> CommitBuilder<'a, S>
1621where
1622 S: commit_state::State,
1623 S::Blocks: commit_state::IsUnset,
1624{
1625 pub fn blocks(
1627 mut self,
1628 value: impl Into<Bytes>,
1629 ) -> CommitBuilder<'a, commit_state::SetBlocks<S>> {
1630 self._fields.1 = Option::Some(value.into());
1631 CommitBuilder {
1632 _state: PhantomData,
1633 _fields: self._fields,
1634 _lifetime: PhantomData,
1635 }
1636 }
1637}
1638
1639impl<'a, S> CommitBuilder<'a, S>
1640where
1641 S: commit_state::State,
1642 S::Commit: commit_state::IsUnset,
1643{
1644 pub fn commit(
1646 mut self,
1647 value: impl Into<CidLink<'a>>,
1648 ) -> CommitBuilder<'a, commit_state::SetCommit<S>> {
1649 self._fields.2 = Option::Some(value.into());
1650 CommitBuilder {
1651 _state: PhantomData,
1652 _fields: self._fields,
1653 _lifetime: PhantomData,
1654 }
1655 }
1656}
1657
1658impl<'a, S> CommitBuilder<'a, S>
1659where
1660 S: commit_state::State,
1661 S::Ops: commit_state::IsUnset,
1662{
1663 pub fn ops(
1665 mut self,
1666 value: impl Into<Vec<subscribe_repos::RepoOp<'a>>>,
1667 ) -> CommitBuilder<'a, commit_state::SetOps<S>> {
1668 self._fields.3 = Option::Some(value.into());
1669 CommitBuilder {
1670 _state: PhantomData,
1671 _fields: self._fields,
1672 _lifetime: PhantomData,
1673 }
1674 }
1675}
1676
1677impl<'a, S: commit_state::State> CommitBuilder<'a, S> {
1678 pub fn prev_data(mut self, value: impl Into<Option<CidLink<'a>>>) -> Self {
1680 self._fields.4 = value.into();
1681 self
1682 }
1683 pub fn maybe_prev_data(mut self, value: Option<CidLink<'a>>) -> Self {
1685 self._fields.4 = value;
1686 self
1687 }
1688}
1689
1690impl<'a, S> CommitBuilder<'a, S>
1691where
1692 S: commit_state::State,
1693 S::Rebase: commit_state::IsUnset,
1694{
1695 pub fn rebase(
1697 mut self,
1698 value: impl Into<bool>,
1699 ) -> CommitBuilder<'a, commit_state::SetRebase<S>> {
1700 self._fields.5 = Option::Some(value.into());
1701 CommitBuilder {
1702 _state: PhantomData,
1703 _fields: self._fields,
1704 _lifetime: PhantomData,
1705 }
1706 }
1707}
1708
1709impl<'a, S> CommitBuilder<'a, S>
1710where
1711 S: commit_state::State,
1712 S::Repo: commit_state::IsUnset,
1713{
1714 pub fn repo(
1716 mut self,
1717 value: impl Into<Did<'a>>,
1718 ) -> CommitBuilder<'a, commit_state::SetRepo<S>> {
1719 self._fields.6 = Option::Some(value.into());
1720 CommitBuilder {
1721 _state: PhantomData,
1722 _fields: self._fields,
1723 _lifetime: PhantomData,
1724 }
1725 }
1726}
1727
1728impl<'a, S> CommitBuilder<'a, S>
1729where
1730 S: commit_state::State,
1731 S::Rev: commit_state::IsUnset,
1732{
1733 pub fn rev(
1735 mut self,
1736 value: impl Into<Tid>,
1737 ) -> CommitBuilder<'a, commit_state::SetRev<S>> {
1738 self._fields.7 = Option::Some(value.into());
1739 CommitBuilder {
1740 _state: PhantomData,
1741 _fields: self._fields,
1742 _lifetime: PhantomData,
1743 }
1744 }
1745}
1746
1747impl<'a, S> CommitBuilder<'a, S>
1748where
1749 S: commit_state::State,
1750 S::Seq: commit_state::IsUnset,
1751{
1752 pub fn seq(
1754 mut self,
1755 value: impl Into<i64>,
1756 ) -> CommitBuilder<'a, commit_state::SetSeq<S>> {
1757 self._fields.8 = Option::Some(value.into());
1758 CommitBuilder {
1759 _state: PhantomData,
1760 _fields: self._fields,
1761 _lifetime: PhantomData,
1762 }
1763 }
1764}
1765
1766impl<'a, S: commit_state::State> CommitBuilder<'a, S> {
1767 pub fn since(mut self, value: impl Into<Option<Tid>>) -> Self {
1769 self._fields.9 = value.into();
1770 self
1771 }
1772 pub fn maybe_since(mut self, value: Option<Tid>) -> Self {
1774 self._fields.9 = value;
1775 self
1776 }
1777}
1778
1779impl<'a, S> CommitBuilder<'a, S>
1780where
1781 S: commit_state::State,
1782 S::Time: commit_state::IsUnset,
1783{
1784 pub fn time(
1786 mut self,
1787 value: impl Into<Datetime>,
1788 ) -> CommitBuilder<'a, commit_state::SetTime<S>> {
1789 self._fields.10 = Option::Some(value.into());
1790 CommitBuilder {
1791 _state: PhantomData,
1792 _fields: self._fields,
1793 _lifetime: PhantomData,
1794 }
1795 }
1796}
1797
1798impl<'a, S> CommitBuilder<'a, S>
1799where
1800 S: commit_state::State,
1801 S::TooBig: commit_state::IsUnset,
1802{
1803 pub fn too_big(
1805 mut self,
1806 value: impl Into<bool>,
1807 ) -> CommitBuilder<'a, commit_state::SetTooBig<S>> {
1808 self._fields.11 = Option::Some(value.into());
1809 CommitBuilder {
1810 _state: PhantomData,
1811 _fields: self._fields,
1812 _lifetime: PhantomData,
1813 }
1814 }
1815}
1816
1817impl<'a, S> CommitBuilder<'a, S>
1818where
1819 S: commit_state::State,
1820 S::Seq: commit_state::IsSet,
1821 S::TooBig: commit_state::IsSet,
1822 S::Rev: commit_state::IsSet,
1823 S::Repo: commit_state::IsSet,
1824 S::Blocks: commit_state::IsSet,
1825 S::Ops: commit_state::IsSet,
1826 S::Blobs: commit_state::IsSet,
1827 S::Commit: commit_state::IsSet,
1828 S::Time: commit_state::IsSet,
1829 S::Rebase: commit_state::IsSet,
1830{
1831 pub fn build(self) -> Commit<'a> {
1833 Commit {
1834 blobs: self._fields.0.unwrap(),
1835 blocks: self._fields.1.unwrap(),
1836 commit: self._fields.2.unwrap(),
1837 ops: self._fields.3.unwrap(),
1838 prev_data: self._fields.4,
1839 rebase: self._fields.5.unwrap(),
1840 repo: self._fields.6.unwrap(),
1841 rev: self._fields.7.unwrap(),
1842 seq: self._fields.8.unwrap(),
1843 since: self._fields.9,
1844 time: self._fields.10.unwrap(),
1845 too_big: self._fields.11.unwrap(),
1846 extra_data: Default::default(),
1847 }
1848 }
1849 pub fn build_with_data(
1851 self,
1852 extra_data: BTreeMap<
1853 jacquard_common::deps::smol_str::SmolStr,
1854 jacquard_common::types::value::Data<'a>,
1855 >,
1856 ) -> Commit<'a> {
1857 Commit {
1858 blobs: self._fields.0.unwrap(),
1859 blocks: self._fields.1.unwrap(),
1860 commit: self._fields.2.unwrap(),
1861 ops: self._fields.3.unwrap(),
1862 prev_data: self._fields.4,
1863 rebase: self._fields.5.unwrap(),
1864 repo: self._fields.6.unwrap(),
1865 rev: self._fields.7.unwrap(),
1866 seq: self._fields.8.unwrap(),
1867 since: self._fields.9,
1868 time: self._fields.10.unwrap(),
1869 too_big: self._fields.11.unwrap(),
1870 extra_data: Some(extra_data),
1871 }
1872 }
1873}
1874
1875pub mod identity_state {
1876
1877 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
1878 #[allow(unused)]
1879 use ::core::marker::PhantomData;
1880 mod sealed {
1881 pub trait Sealed {}
1882 }
1883 pub trait State: sealed::Sealed {
1885 type Seq;
1886 type Did;
1887 type Time;
1888 }
1889 pub struct Empty(());
1891 impl sealed::Sealed for Empty {}
1892 impl State for Empty {
1893 type Seq = Unset;
1894 type Did = Unset;
1895 type Time = Unset;
1896 }
1897 pub struct SetSeq<S: State = Empty>(PhantomData<fn() -> S>);
1899 impl<S: State> sealed::Sealed for SetSeq<S> {}
1900 impl<S: State> State for SetSeq<S> {
1901 type Seq = Set<members::seq>;
1902 type Did = S::Did;
1903 type Time = S::Time;
1904 }
1905 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
1907 impl<S: State> sealed::Sealed for SetDid<S> {}
1908 impl<S: State> State for SetDid<S> {
1909 type Seq = S::Seq;
1910 type Did = Set<members::did>;
1911 type Time = S::Time;
1912 }
1913 pub struct SetTime<S: State = Empty>(PhantomData<fn() -> S>);
1915 impl<S: State> sealed::Sealed for SetTime<S> {}
1916 impl<S: State> State for SetTime<S> {
1917 type Seq = S::Seq;
1918 type Did = S::Did;
1919 type Time = Set<members::time>;
1920 }
1921 #[allow(non_camel_case_types)]
1923 pub mod members {
1924 pub struct seq(());
1926 pub struct did(());
1928 pub struct time(());
1930 }
1931}
1932
1933pub struct IdentityBuilder<'a, S: identity_state::State> {
1935 _state: PhantomData<fn() -> S>,
1936 _fields: (Option<Did<'a>>, Option<Handle<'a>>, Option<i64>, Option<Datetime>),
1937 _lifetime: PhantomData<&'a ()>,
1938}
1939
1940impl<'a> Identity<'a> {
1941 pub fn new() -> IdentityBuilder<'a, identity_state::Empty> {
1943 IdentityBuilder::new()
1944 }
1945}
1946
1947impl<'a> IdentityBuilder<'a, identity_state::Empty> {
1948 pub fn new() -> Self {
1950 IdentityBuilder {
1951 _state: PhantomData,
1952 _fields: (None, None, None, None),
1953 _lifetime: PhantomData,
1954 }
1955 }
1956}
1957
1958impl<'a, S> IdentityBuilder<'a, S>
1959where
1960 S: identity_state::State,
1961 S::Did: identity_state::IsUnset,
1962{
1963 pub fn did(
1965 mut self,
1966 value: impl Into<Did<'a>>,
1967 ) -> IdentityBuilder<'a, identity_state::SetDid<S>> {
1968 self._fields.0 = Option::Some(value.into());
1969 IdentityBuilder {
1970 _state: PhantomData,
1971 _fields: self._fields,
1972 _lifetime: PhantomData,
1973 }
1974 }
1975}
1976
1977impl<'a, S: identity_state::State> IdentityBuilder<'a, S> {
1978 pub fn handle(mut self, value: impl Into<Option<Handle<'a>>>) -> Self {
1980 self._fields.1 = value.into();
1981 self
1982 }
1983 pub fn maybe_handle(mut self, value: Option<Handle<'a>>) -> Self {
1985 self._fields.1 = value;
1986 self
1987 }
1988}
1989
1990impl<'a, S> IdentityBuilder<'a, S>
1991where
1992 S: identity_state::State,
1993 S::Seq: identity_state::IsUnset,
1994{
1995 pub fn seq(
1997 mut self,
1998 value: impl Into<i64>,
1999 ) -> IdentityBuilder<'a, identity_state::SetSeq<S>> {
2000 self._fields.2 = Option::Some(value.into());
2001 IdentityBuilder {
2002 _state: PhantomData,
2003 _fields: self._fields,
2004 _lifetime: PhantomData,
2005 }
2006 }
2007}
2008
2009impl<'a, S> IdentityBuilder<'a, S>
2010where
2011 S: identity_state::State,
2012 S::Time: identity_state::IsUnset,
2013{
2014 pub fn time(
2016 mut self,
2017 value: impl Into<Datetime>,
2018 ) -> IdentityBuilder<'a, identity_state::SetTime<S>> {
2019 self._fields.3 = Option::Some(value.into());
2020 IdentityBuilder {
2021 _state: PhantomData,
2022 _fields: self._fields,
2023 _lifetime: PhantomData,
2024 }
2025 }
2026}
2027
2028impl<'a, S> IdentityBuilder<'a, S>
2029where
2030 S: identity_state::State,
2031 S::Seq: identity_state::IsSet,
2032 S::Did: identity_state::IsSet,
2033 S::Time: identity_state::IsSet,
2034{
2035 pub fn build(self) -> Identity<'a> {
2037 Identity {
2038 did: self._fields.0.unwrap(),
2039 handle: self._fields.1,
2040 seq: self._fields.2.unwrap(),
2041 time: self._fields.3.unwrap(),
2042 extra_data: Default::default(),
2043 }
2044 }
2045 pub fn build_with_data(
2047 self,
2048 extra_data: BTreeMap<
2049 jacquard_common::deps::smol_str::SmolStr,
2050 jacquard_common::types::value::Data<'a>,
2051 >,
2052 ) -> Identity<'a> {
2053 Identity {
2054 did: self._fields.0.unwrap(),
2055 handle: self._fields.1,
2056 seq: self._fields.2.unwrap(),
2057 time: self._fields.3.unwrap(),
2058 extra_data: Some(extra_data),
2059 }
2060 }
2061}
2062
2063pub mod subscribe_repos_state {
2064
2065 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
2066 #[allow(unused)]
2067 use ::core::marker::PhantomData;
2068 mod sealed {
2069 pub trait Sealed {}
2070 }
2071 pub trait State: sealed::Sealed {}
2073 pub struct Empty(());
2075 impl sealed::Sealed for Empty {}
2076 impl State for Empty {}
2077 #[allow(non_camel_case_types)]
2079 pub mod members {}
2080}
2081
2082pub struct SubscribeReposBuilder<S: subscribe_repos_state::State> {
2084 _state: PhantomData<fn() -> S>,
2085 _fields: (Option<i64>,),
2086}
2087
2088impl SubscribeRepos {
2089 pub fn new() -> SubscribeReposBuilder<subscribe_repos_state::Empty> {
2091 SubscribeReposBuilder::new()
2092 }
2093}
2094
2095impl SubscribeReposBuilder<subscribe_repos_state::Empty> {
2096 pub fn new() -> Self {
2098 SubscribeReposBuilder {
2099 _state: PhantomData,
2100 _fields: (None,),
2101 }
2102 }
2103}
2104
2105impl<S: subscribe_repos_state::State> SubscribeReposBuilder<S> {
2106 pub fn cursor(mut self, value: impl Into<Option<i64>>) -> Self {
2108 self._fields.0 = value.into();
2109 self
2110 }
2111 pub fn maybe_cursor(mut self, value: Option<i64>) -> Self {
2113 self._fields.0 = value;
2114 self
2115 }
2116}
2117
2118impl<S> SubscribeReposBuilder<S>
2119where
2120 S: subscribe_repos_state::State,
2121{
2122 pub fn build(self) -> SubscribeRepos {
2124 SubscribeRepos {
2125 cursor: self._fields.0,
2126 }
2127 }
2128}
2129
2130pub mod repo_op_state {
2131
2132 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
2133 #[allow(unused)]
2134 use ::core::marker::PhantomData;
2135 mod sealed {
2136 pub trait Sealed {}
2137 }
2138 pub trait State: sealed::Sealed {
2140 type Action;
2141 type Path;
2142 }
2143 pub struct Empty(());
2145 impl sealed::Sealed for Empty {}
2146 impl State for Empty {
2147 type Action = Unset;
2148 type Path = Unset;
2149 }
2150 pub struct SetAction<S: State = Empty>(PhantomData<fn() -> S>);
2152 impl<S: State> sealed::Sealed for SetAction<S> {}
2153 impl<S: State> State for SetAction<S> {
2154 type Action = Set<members::action>;
2155 type Path = S::Path;
2156 }
2157 pub struct SetPath<S: State = Empty>(PhantomData<fn() -> S>);
2159 impl<S: State> sealed::Sealed for SetPath<S> {}
2160 impl<S: State> State for SetPath<S> {
2161 type Action = S::Action;
2162 type Path = Set<members::path>;
2163 }
2164 #[allow(non_camel_case_types)]
2166 pub mod members {
2167 pub struct action(());
2169 pub struct path(());
2171 }
2172}
2173
2174pub struct RepoOpBuilder<'a, S: repo_op_state::State> {
2176 _state: PhantomData<fn() -> S>,
2177 _fields: (
2178 Option<RepoOpAction<'a>>,
2179 Option<CidLink<'a>>,
2180 Option<CowStr<'a>>,
2181 Option<CidLink<'a>>,
2182 ),
2183 _lifetime: PhantomData<&'a ()>,
2184}
2185
2186impl<'a> RepoOp<'a> {
2187 pub fn new() -> RepoOpBuilder<'a, repo_op_state::Empty> {
2189 RepoOpBuilder::new()
2190 }
2191}
2192
2193impl<'a> RepoOpBuilder<'a, repo_op_state::Empty> {
2194 pub fn new() -> Self {
2196 RepoOpBuilder {
2197 _state: PhantomData,
2198 _fields: (None, None, None, None),
2199 _lifetime: PhantomData,
2200 }
2201 }
2202}
2203
2204impl<'a, S> RepoOpBuilder<'a, S>
2205where
2206 S: repo_op_state::State,
2207 S::Action: repo_op_state::IsUnset,
2208{
2209 pub fn action(
2211 mut self,
2212 value: impl Into<RepoOpAction<'a>>,
2213 ) -> RepoOpBuilder<'a, repo_op_state::SetAction<S>> {
2214 self._fields.0 = Option::Some(value.into());
2215 RepoOpBuilder {
2216 _state: PhantomData,
2217 _fields: self._fields,
2218 _lifetime: PhantomData,
2219 }
2220 }
2221}
2222
2223impl<'a, S: repo_op_state::State> RepoOpBuilder<'a, S> {
2224 pub fn cid(mut self, value: impl Into<Option<CidLink<'a>>>) -> Self {
2226 self._fields.1 = value.into();
2227 self
2228 }
2229 pub fn maybe_cid(mut self, value: Option<CidLink<'a>>) -> Self {
2231 self._fields.1 = value;
2232 self
2233 }
2234}
2235
2236impl<'a, S> RepoOpBuilder<'a, S>
2237where
2238 S: repo_op_state::State,
2239 S::Path: repo_op_state::IsUnset,
2240{
2241 pub fn path(
2243 mut self,
2244 value: impl Into<CowStr<'a>>,
2245 ) -> RepoOpBuilder<'a, repo_op_state::SetPath<S>> {
2246 self._fields.2 = Option::Some(value.into());
2247 RepoOpBuilder {
2248 _state: PhantomData,
2249 _fields: self._fields,
2250 _lifetime: PhantomData,
2251 }
2252 }
2253}
2254
2255impl<'a, S: repo_op_state::State> RepoOpBuilder<'a, S> {
2256 pub fn prev(mut self, value: impl Into<Option<CidLink<'a>>>) -> Self {
2258 self._fields.3 = value.into();
2259 self
2260 }
2261 pub fn maybe_prev(mut self, value: Option<CidLink<'a>>) -> Self {
2263 self._fields.3 = value;
2264 self
2265 }
2266}
2267
2268impl<'a, S> RepoOpBuilder<'a, S>
2269where
2270 S: repo_op_state::State,
2271 S::Action: repo_op_state::IsSet,
2272 S::Path: repo_op_state::IsSet,
2273{
2274 pub fn build(self) -> RepoOp<'a> {
2276 RepoOp {
2277 action: self._fields.0.unwrap(),
2278 cid: self._fields.1,
2279 path: self._fields.2.unwrap(),
2280 prev: self._fields.3,
2281 extra_data: Default::default(),
2282 }
2283 }
2284 pub fn build_with_data(
2286 self,
2287 extra_data: BTreeMap<
2288 jacquard_common::deps::smol_str::SmolStr,
2289 jacquard_common::types::value::Data<'a>,
2290 >,
2291 ) -> RepoOp<'a> {
2292 RepoOp {
2293 action: self._fields.0.unwrap(),
2294 cid: self._fields.1,
2295 path: self._fields.2.unwrap(),
2296 prev: self._fields.3,
2297 extra_data: Some(extra_data),
2298 }
2299 }
2300}
2301
2302pub mod sync_state {
2303
2304 pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
2305 #[allow(unused)]
2306 use ::core::marker::PhantomData;
2307 mod sealed {
2308 pub trait Sealed {}
2309 }
2310 pub trait State: sealed::Sealed {
2312 type Blocks;
2313 type Rev;
2314 type Seq;
2315 type Did;
2316 type Time;
2317 }
2318 pub struct Empty(());
2320 impl sealed::Sealed for Empty {}
2321 impl State for Empty {
2322 type Blocks = Unset;
2323 type Rev = Unset;
2324 type Seq = Unset;
2325 type Did = Unset;
2326 type Time = Unset;
2327 }
2328 pub struct SetBlocks<S: State = Empty>(PhantomData<fn() -> S>);
2330 impl<S: State> sealed::Sealed for SetBlocks<S> {}
2331 impl<S: State> State for SetBlocks<S> {
2332 type Blocks = Set<members::blocks>;
2333 type Rev = S::Rev;
2334 type Seq = S::Seq;
2335 type Did = S::Did;
2336 type Time = S::Time;
2337 }
2338 pub struct SetRev<S: State = Empty>(PhantomData<fn() -> S>);
2340 impl<S: State> sealed::Sealed for SetRev<S> {}
2341 impl<S: State> State for SetRev<S> {
2342 type Blocks = S::Blocks;
2343 type Rev = Set<members::rev>;
2344 type Seq = S::Seq;
2345 type Did = S::Did;
2346 type Time = S::Time;
2347 }
2348 pub struct SetSeq<S: State = Empty>(PhantomData<fn() -> S>);
2350 impl<S: State> sealed::Sealed for SetSeq<S> {}
2351 impl<S: State> State for SetSeq<S> {
2352 type Blocks = S::Blocks;
2353 type Rev = S::Rev;
2354 type Seq = Set<members::seq>;
2355 type Did = S::Did;
2356 type Time = S::Time;
2357 }
2358 pub struct SetDid<S: State = Empty>(PhantomData<fn() -> S>);
2360 impl<S: State> sealed::Sealed for SetDid<S> {}
2361 impl<S: State> State for SetDid<S> {
2362 type Blocks = S::Blocks;
2363 type Rev = S::Rev;
2364 type Seq = S::Seq;
2365 type Did = Set<members::did>;
2366 type Time = S::Time;
2367 }
2368 pub struct SetTime<S: State = Empty>(PhantomData<fn() -> S>);
2370 impl<S: State> sealed::Sealed for SetTime<S> {}
2371 impl<S: State> State for SetTime<S> {
2372 type Blocks = S::Blocks;
2373 type Rev = S::Rev;
2374 type Seq = S::Seq;
2375 type Did = S::Did;
2376 type Time = Set<members::time>;
2377 }
2378 #[allow(non_camel_case_types)]
2380 pub mod members {
2381 pub struct blocks(());
2383 pub struct rev(());
2385 pub struct seq(());
2387 pub struct did(());
2389 pub struct time(());
2391 }
2392}
2393
2394pub struct SyncBuilder<'a, S: sync_state::State> {
2396 _state: PhantomData<fn() -> S>,
2397 _fields: (
2398 Option<Bytes>,
2399 Option<Did<'a>>,
2400 Option<CowStr<'a>>,
2401 Option<i64>,
2402 Option<Datetime>,
2403 ),
2404 _lifetime: PhantomData<&'a ()>,
2405}
2406
2407impl<'a> Sync<'a> {
2408 pub fn new() -> SyncBuilder<'a, sync_state::Empty> {
2410 SyncBuilder::new()
2411 }
2412}
2413
2414impl<'a> SyncBuilder<'a, sync_state::Empty> {
2415 pub fn new() -> Self {
2417 SyncBuilder {
2418 _state: PhantomData,
2419 _fields: (None, None, None, None, None),
2420 _lifetime: PhantomData,
2421 }
2422 }
2423}
2424
2425impl<'a, S> SyncBuilder<'a, S>
2426where
2427 S: sync_state::State,
2428 S::Blocks: sync_state::IsUnset,
2429{
2430 pub fn blocks(
2432 mut self,
2433 value: impl Into<Bytes>,
2434 ) -> SyncBuilder<'a, sync_state::SetBlocks<S>> {
2435 self._fields.0 = Option::Some(value.into());
2436 SyncBuilder {
2437 _state: PhantomData,
2438 _fields: self._fields,
2439 _lifetime: PhantomData,
2440 }
2441 }
2442}
2443
2444impl<'a, S> SyncBuilder<'a, S>
2445where
2446 S: sync_state::State,
2447 S::Did: sync_state::IsUnset,
2448{
2449 pub fn did(
2451 mut self,
2452 value: impl Into<Did<'a>>,
2453 ) -> SyncBuilder<'a, sync_state::SetDid<S>> {
2454 self._fields.1 = Option::Some(value.into());
2455 SyncBuilder {
2456 _state: PhantomData,
2457 _fields: self._fields,
2458 _lifetime: PhantomData,
2459 }
2460 }
2461}
2462
2463impl<'a, S> SyncBuilder<'a, S>
2464where
2465 S: sync_state::State,
2466 S::Rev: sync_state::IsUnset,
2467{
2468 pub fn rev(
2470 mut self,
2471 value: impl Into<CowStr<'a>>,
2472 ) -> SyncBuilder<'a, sync_state::SetRev<S>> {
2473 self._fields.2 = Option::Some(value.into());
2474 SyncBuilder {
2475 _state: PhantomData,
2476 _fields: self._fields,
2477 _lifetime: PhantomData,
2478 }
2479 }
2480}
2481
2482impl<'a, S> SyncBuilder<'a, S>
2483where
2484 S: sync_state::State,
2485 S::Seq: sync_state::IsUnset,
2486{
2487 pub fn seq(
2489 mut self,
2490 value: impl Into<i64>,
2491 ) -> SyncBuilder<'a, sync_state::SetSeq<S>> {
2492 self._fields.3 = Option::Some(value.into());
2493 SyncBuilder {
2494 _state: PhantomData,
2495 _fields: self._fields,
2496 _lifetime: PhantomData,
2497 }
2498 }
2499}
2500
2501impl<'a, S> SyncBuilder<'a, S>
2502where
2503 S: sync_state::State,
2504 S::Time: sync_state::IsUnset,
2505{
2506 pub fn time(
2508 mut self,
2509 value: impl Into<Datetime>,
2510 ) -> SyncBuilder<'a, sync_state::SetTime<S>> {
2511 self._fields.4 = Option::Some(value.into());
2512 SyncBuilder {
2513 _state: PhantomData,
2514 _fields: self._fields,
2515 _lifetime: PhantomData,
2516 }
2517 }
2518}
2519
2520impl<'a, S> SyncBuilder<'a, S>
2521where
2522 S: sync_state::State,
2523 S::Blocks: sync_state::IsSet,
2524 S::Rev: sync_state::IsSet,
2525 S::Seq: sync_state::IsSet,
2526 S::Did: sync_state::IsSet,
2527 S::Time: sync_state::IsSet,
2528{
2529 pub fn build(self) -> Sync<'a> {
2531 Sync {
2532 blocks: self._fields.0.unwrap(),
2533 did: self._fields.1.unwrap(),
2534 rev: self._fields.2.unwrap(),
2535 seq: self._fields.3.unwrap(),
2536 time: self._fields.4.unwrap(),
2537 extra_data: Default::default(),
2538 }
2539 }
2540 pub fn build_with_data(
2542 self,
2543 extra_data: BTreeMap<
2544 jacquard_common::deps::smol_str::SmolStr,
2545 jacquard_common::types::value::Data<'a>,
2546 >,
2547 ) -> Sync<'a> {
2548 Sync {
2549 blocks: self._fields.0.unwrap(),
2550 did: self._fields.1.unwrap(),
2551 rev: self._fields.2.unwrap(),
2552 seq: self._fields.3.unwrap(),
2553 time: self._fields.4.unwrap(),
2554 extra_data: Some(extra_data),
2555 }
2556 }
2557}