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