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