#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::deps::bytes::Bytes;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::cid::CidLink;
use jacquard_common::types::string::{Datetime, Did, Handle, Tid};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::com_atproto::sync::subscribe_repos;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Account<S: BosStr = DefaultStr> {
pub active: bool,
pub did: Did<S>,
pub seq: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<AccountStatus<S>>,
pub time: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum AccountStatus<S: BosStr = DefaultStr> {
Takendown,
Suspended,
Deleted,
Deactivated,
Desynchronized,
Throttled,
Other(S),
}
impl<S: BosStr> AccountStatus<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Takendown => "takendown",
Self::Suspended => "suspended",
Self::Deleted => "deleted",
Self::Deactivated => "deactivated",
Self::Desynchronized => "desynchronized",
Self::Throttled => "throttled",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"takendown" => Self::Takendown,
"suspended" => Self::Suspended,
"deleted" => Self::Deleted,
"deactivated" => Self::Deactivated,
"desynchronized" => Self::Desynchronized,
"throttled" => Self::Throttled,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for AccountStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for AccountStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for AccountStatus<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for AccountStatus<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for AccountStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for AccountStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = AccountStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
AccountStatus::Takendown => AccountStatus::Takendown,
AccountStatus::Suspended => AccountStatus::Suspended,
AccountStatus::Deleted => AccountStatus::Deleted,
AccountStatus::Deactivated => AccountStatus::Deactivated,
AccountStatus::Desynchronized => AccountStatus::Desynchronized,
AccountStatus::Throttled => AccountStatus::Throttled,
AccountStatus::Other(v) => AccountStatus::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Commit<S: BosStr = DefaultStr> {
pub blobs: Vec<CidLink<S>>,
#[serde(with = "jacquard_common::serde_bytes_helper")]
pub blocks: Bytes,
pub commit: CidLink<S>,
pub ops: Vec<subscribe_repos::RepoOp<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub prev_data: Option<CidLink<S>>,
pub rebase: bool,
pub repo: Did<S>,
pub rev: Tid,
pub seq: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub since: Option<Tid>,
pub time: Datetime,
pub too_big: bool,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Identity<S: BosStr = DefaultStr> {
pub did: Did<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub handle: Option<Handle<S>>,
pub seq: i64,
pub time: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Info<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<S>,
pub name: InfoName<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum InfoName<S: BosStr = DefaultStr> {
OutdatedCursor,
Other(S),
}
impl<S: BosStr> InfoName<S> {
pub fn as_str(&self) -> &str {
match self {
Self::OutdatedCursor => "OutdatedCursor",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"OutdatedCursor" => Self::OutdatedCursor,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for InfoName<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for InfoName<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for InfoName<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for InfoName<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for InfoName<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for InfoName<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = InfoName<S::Output>;
fn into_static(self) -> Self::Output {
match self {
InfoName::OutdatedCursor => InfoName::OutdatedCursor,
InfoName::Other(v) => InfoName::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SubscribeRepos {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<i64>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum SubscribeReposMessage<S: BosStr = DefaultStr> {
#[serde(rename = "#commit")]
Commit(Box<subscribe_repos::Commit<S>>),
#[serde(rename = "#sync")]
Sync(Box<subscribe_repos::Sync<S>>),
#[serde(rename = "#identity")]
Identity(Box<subscribe_repos::Identity<S>>),
#[serde(rename = "#account")]
Account(Box<subscribe_repos::Account<S>>),
#[serde(rename = "#info")]
Info(Box<subscribe_repos::Info<S>>),
}
impl<S: BosStr> SubscribeReposMessage<S> {
pub fn decode_framed<'de>(
bytes: &'de [u8],
) -> Result<SubscribeReposMessage<S>, jacquard_common::error::DecodeError>
where
S: serde::Deserialize<'de>,
{
let (header, body) = jacquard_common::xrpc::subscription::parse_event_header(bytes)?;
match header.t.as_str() {
"#commit" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Commit(Box::new(variant)))
}
"#sync" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Sync(Box::new(variant)))
}
"#identity" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Identity(Box::new(variant)))
}
"#account" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Account(Box::new(variant)))
}
"#info" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Info(Box::new(variant)))
}
unknown => Err(jacquard_common::error::DecodeError::UnknownEventType(
unknown.into(),
)),
}
}
}
#[derive(
Serialize, Deserialize, Debug, Clone, PartialEq, Eq, thiserror::Error, miette::Diagnostic,
)]
#[serde(tag = "error", content = "message")]
pub enum SubscribeReposError {
#[serde(rename = "FutureCursor")]
FutureCursor(Option<SmolStr>),
#[serde(rename = "ConsumerTooSlow")]
ConsumerTooSlow(Option<SmolStr>),
#[serde(untagged)]
Other {
error: SmolStr,
message: Option<SmolStr>,
},
}
impl core::fmt::Display for SubscribeReposError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::FutureCursor(msg) => {
write!(f, "FutureCursor")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::ConsumerTooSlow(msg) => {
write!(f, "ConsumerTooSlow")?;
if let Some(msg) = msg {
write!(f, ": {}", msg)?;
}
Ok(())
}
Self::Other { error, message } => {
write!(f, "{}", error)?;
if let Some(msg) = message {
write!(f, ": {}", msg)?;
}
Ok(())
}
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct RepoOp<S: BosStr = DefaultStr> {
pub action: RepoOpAction<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<CidLink<S>>,
pub path: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub prev: Option<CidLink<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RepoOpAction<S: BosStr = DefaultStr> {
Create,
Update,
Delete,
Other(S),
}
impl<S: BosStr> RepoOpAction<S> {
pub fn as_str(&self) -> &str {
match self {
Self::Create => "create",
Self::Update => "update",
Self::Delete => "delete",
Self::Other(s) => s.as_ref(),
}
}
pub fn from_value(s: S) -> Self {
match s.as_ref() {
"create" => Self::Create,
"update" => Self::Update,
"delete" => Self::Delete,
_ => Self::Other(s),
}
}
}
impl<S: BosStr> core::fmt::Display for RepoOpAction<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for RepoOpAction<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for RepoOpAction<S> {
fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
where
Ser: serde::Serializer,
{
serializer.serialize_str(self.as_str())
}
}
impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for RepoOpAction<S> {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: serde::Deserializer<'de>,
{
let s = S::deserialize(deserializer)?;
Ok(Self::from_value(s))
}
}
impl<S: BosStr + Default> Default for RepoOpAction<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for RepoOpAction<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = RepoOpAction<S::Output>;
fn into_static(self) -> Self::Output {
match self {
RepoOpAction::Create => RepoOpAction::Create,
RepoOpAction::Update => RepoOpAction::Update,
RepoOpAction::Delete => RepoOpAction::Delete,
RepoOpAction::Other(v) => RepoOpAction::Other(v.into_static()),
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Sync<S: BosStr = DefaultStr> {
#[serde(with = "jacquard_common::serde_bytes_helper")]
pub blocks: Bytes,
pub did: Did<S>,
pub rev: S,
pub seq: i64,
pub time: Datetime,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Account<S> {
fn nsid() -> &'static str {
"com.atproto.sync.subscribeRepos"
}
fn def_name() -> &'static str {
"account"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Commit<S> {
fn nsid() -> &'static str {
"com.atproto.sync.subscribeRepos"
}
fn def_name() -> &'static str {
"commit"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.ops;
#[allow(unused_comparisons)]
if value.len() > 200usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("ops"),
max: 200usize,
actual: value.len(),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Identity<S> {
fn nsid() -> &'static str {
"com.atproto.sync.subscribeRepos"
}
fn def_name() -> &'static str {
"identity"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Info<S> {
fn nsid() -> &'static str {
"com.atproto.sync.subscribeRepos"
}
fn def_name() -> &'static str {
"info"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct SubscribeReposStream;
impl jacquard_common::xrpc::SubscriptionResp for SubscribeReposStream {
const NSID: &'static str = "com.atproto.sync.subscribeRepos";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::DagCbor;
type Message<S: BosStr> = SubscribeReposMessage<S>;
type Error = SubscribeReposError;
fn decode_message<'de, S>(
bytes: &'de [u8],
) -> Result<Self::Message<S>, jacquard_common::error::DecodeError>
where
S: BosStr + serde::Deserialize<'de>,
Self::Message<S>: serde::Deserialize<'de>,
{
SubscribeReposMessage::decode_framed(bytes)
}
}
impl jacquard_common::xrpc::XrpcSubscription for SubscribeRepos {
const NSID: &'static str = "com.atproto.sync.subscribeRepos";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::DagCbor;
type Stream = SubscribeReposStream;
}
pub struct SubscribeReposEndpoint;
impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeReposEndpoint {
const PATH: &'static str = "/xrpc/com.atproto.sync.subscribeRepos";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::DagCbor;
type Params<S: BosStr> = SubscribeRepos;
type Stream = SubscribeReposStream;
}
impl<S: BosStr> LexiconSchema for RepoOp<S> {
fn nsid() -> &'static str {
"com.atproto.sync.subscribeRepos"
}
fn def_name() -> &'static str {
"repoOp"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Sync<S> {
fn nsid() -> &'static str {
"com.atproto.sync.subscribeRepos"
}
fn def_name() -> &'static str {
"sync"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod account_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Seq;
type Did;
type Active;
type Time;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Seq = Unset;
type Did = Unset;
type Active = Unset;
type Time = Unset;
}
pub struct SetSeq<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeq<St> {}
impl<St: State> State for SetSeq<St> {
type Seq = Set<members::seq>;
type Did = St::Did;
type Active = St::Active;
type Time = St::Time;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Seq = St::Seq;
type Did = Set<members::did>;
type Active = St::Active;
type Time = St::Time;
}
pub struct SetActive<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetActive<St> {}
impl<St: State> State for SetActive<St> {
type Seq = St::Seq;
type Did = St::Did;
type Active = Set<members::active>;
type Time = St::Time;
}
pub struct SetTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTime<St> {}
impl<St: State> State for SetTime<St> {
type Seq = St::Seq;
type Did = St::Did;
type Active = St::Active;
type Time = Set<members::time>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct seq(());
pub struct did(());
pub struct active(());
pub struct time(());
}
}
pub struct AccountBuilder<S: BosStr, St: account_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<bool>,
Option<Did<S>>,
Option<i64>,
Option<AccountStatus<S>>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Account<S> {
pub fn new() -> AccountBuilder<S, account_state::Empty> {
AccountBuilder::new()
}
}
impl<S: BosStr> AccountBuilder<S, account_state::Empty> {
pub fn new() -> Self {
AccountBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AccountBuilder<S, St>
where
St: account_state::State,
St::Active: account_state::IsUnset,
{
pub fn active(
mut self,
value: impl Into<bool>,
) -> AccountBuilder<S, account_state::SetActive<St>> {
self._fields.0 = Option::Some(value.into());
AccountBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AccountBuilder<S, St>
where
St: account_state::State,
St::Did: account_state::IsUnset,
{
pub fn did(mut self, value: impl Into<Did<S>>) -> AccountBuilder<S, account_state::SetDid<St>> {
self._fields.1 = Option::Some(value.into());
AccountBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AccountBuilder<S, St>
where
St: account_state::State,
St::Seq: account_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> AccountBuilder<S, account_state::SetSeq<St>> {
self._fields.2 = Option::Some(value.into());
AccountBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: account_state::State> AccountBuilder<S, St> {
pub fn status(mut self, value: impl Into<Option<AccountStatus<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<AccountStatus<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> AccountBuilder<S, St>
where
St: account_state::State,
St::Time: account_state::IsUnset,
{
pub fn time(
mut self,
value: impl Into<Datetime>,
) -> AccountBuilder<S, account_state::SetTime<St>> {
self._fields.4 = Option::Some(value.into());
AccountBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> AccountBuilder<S, St>
where
St: account_state::State,
St::Seq: account_state::IsSet,
St::Did: account_state::IsSet,
St::Active: account_state::IsSet,
St::Time: account_state::IsSet,
{
pub fn build(self) -> Account<S> {
Account {
active: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
seq: self._fields.2.unwrap(),
status: self._fields.3,
time: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Account<S> {
Account {
active: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
seq: self._fields.2.unwrap(),
status: self._fields.3,
time: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_atproto_sync_subscribeRepos() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("com.atproto.sync.subscribeRepos"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("account"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"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.",
),
),
required: Some(
vec![
SmolStr::new_static("seq"), SmolStr::new_static("did"),
SmolStr::new_static("time"), SmolStr::new_static("active")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("active"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"If active=false, this optional field indicates a reason for why the account is not active.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("time"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("commit"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"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.",
),
),
required: Some(
vec![
SmolStr::new_static("seq"), SmolStr::new_static("rebase"),
SmolStr::new_static("tooBig"), SmolStr::new_static("repo"),
SmolStr::new_static("commit"), SmolStr::new_static("rev"),
SmolStr::new_static("since"), SmolStr::new_static("blocks"),
SmolStr::new_static("ops"), SmolStr::new_static("blobs"),
SmolStr::new_static("time")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blobs"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::CidLink(LexCidLink {
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("blocks"),
LexObjectProperty::Bytes(LexBytes {
max_length: Some(2000000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("commit"),
LexObjectProperty::CidLink(LexCidLink {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ops"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#repoOp"),
..Default::default()
}),
max_length: Some(200usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("prevData"),
LexObjectProperty::CidLink(LexCidLink {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rebase"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repo"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The repo this event comes from. Note that all other message types name this field 'did'.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rev"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"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.",
),
),
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("since"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The rev of the last emitted commit from this repo (if any).",
),
),
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("time"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp of when this message was originally broadcast.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tooBig"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("identity"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"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.",
),
),
required: Some(
vec![
SmolStr::new_static("seq"), SmolStr::new_static("did"),
SmolStr::new_static("time")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("handle"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"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.",
),
),
format: Some(LexStringFormat::Handle),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("time"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("info"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("name")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcSubscription(LexXrpcSubscription {
parameters: Some(LexXrpcSubscriptionParameter::Params(LexXrpcParameters {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cursor"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
})),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repoOp"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A repo operation, ie a mutation of a single record.",
)),
required: Some(vec![
SmolStr::new_static("action"),
SmolStr::new_static("path"),
SmolStr::new_static("cid"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("action"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("cid"),
LexObjectProperty::CidLink(LexCidLink {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("path"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("prev"),
LexObjectProperty::CidLink(LexCidLink {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sync"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"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.",
),
),
required: Some(
vec![
SmolStr::new_static("seq"), SmolStr::new_static("did"),
SmolStr::new_static("blocks"), SmolStr::new_static("rev"),
SmolStr::new_static("time")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blocks"),
LexObjectProperty::Bytes(LexBytes {
max_length: Some(10000usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The account this repo event corresponds to. Must match that in the commit object.",
),
),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rev"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The rev of the commit. This value must match that in the commit object.",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("time"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Timestamp of when this message was originally broadcast.",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod commit_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Rev;
type Seq;
type TooBig;
type Commit;
type Ops;
type Blocks;
type Repo;
type Blobs;
type Time;
type Rebase;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Rev = Unset;
type Seq = Unset;
type TooBig = Unset;
type Commit = Unset;
type Ops = Unset;
type Blocks = Unset;
type Repo = Unset;
type Blobs = Unset;
type Time = Unset;
type Rebase = Unset;
}
pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRev<St> {}
impl<St: State> State for SetRev<St> {
type Rev = Set<members::rev>;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetSeq<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeq<St> {}
impl<St: State> State for SetSeq<St> {
type Rev = St::Rev;
type Seq = Set<members::seq>;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetTooBig<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTooBig<St> {}
impl<St: State> State for SetTooBig<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = Set<members::too_big>;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetCommit<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCommit<St> {}
impl<St: State> State for SetCommit<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = Set<members::commit>;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetOps<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetOps<St> {}
impl<St: State> State for SetOps<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = Set<members::ops>;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetBlocks<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlocks<St> {}
impl<St: State> State for SetBlocks<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = Set<members::blocks>;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetRepo<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepo<St> {}
impl<St: State> State for SetRepo<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = Set<members::repo>;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetBlobs<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlobs<St> {}
impl<St: State> State for SetBlobs<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = Set<members::blobs>;
type Time = St::Time;
type Rebase = St::Rebase;
}
pub struct SetTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTime<St> {}
impl<St: State> State for SetTime<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = Set<members::time>;
type Rebase = St::Rebase;
}
pub struct SetRebase<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRebase<St> {}
impl<St: State> State for SetRebase<St> {
type Rev = St::Rev;
type Seq = St::Seq;
type TooBig = St::TooBig;
type Commit = St::Commit;
type Ops = St::Ops;
type Blocks = St::Blocks;
type Repo = St::Repo;
type Blobs = St::Blobs;
type Time = St::Time;
type Rebase = Set<members::rebase>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct rev(());
pub struct seq(());
pub struct too_big(());
pub struct commit(());
pub struct ops(());
pub struct blocks(());
pub struct repo(());
pub struct blobs(());
pub struct time(());
pub struct rebase(());
}
}
pub struct CommitBuilder<S: BosStr, St: commit_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<CidLink<S>>>,
Option<Bytes>,
Option<CidLink<S>>,
Option<Vec<subscribe_repos::RepoOp<S>>>,
Option<CidLink<S>>,
Option<bool>,
Option<Did<S>>,
Option<Tid>,
Option<i64>,
Option<Tid>,
Option<Datetime>,
Option<bool>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Commit<S> {
pub fn new() -> CommitBuilder<S, commit_state::Empty> {
CommitBuilder::new()
}
}
impl<S: BosStr> CommitBuilder<S, commit_state::Empty> {
pub fn new() -> Self {
CommitBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Blobs: commit_state::IsUnset,
{
pub fn blobs(
mut self,
value: impl Into<Vec<CidLink<S>>>,
) -> CommitBuilder<S, commit_state::SetBlobs<St>> {
self._fields.0 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Blocks: commit_state::IsUnset,
{
pub fn blocks(
mut self,
value: impl Into<Bytes>,
) -> CommitBuilder<S, commit_state::SetBlocks<St>> {
self._fields.1 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Commit: commit_state::IsUnset,
{
pub fn commit(
mut self,
value: impl Into<CidLink<S>>,
) -> CommitBuilder<S, commit_state::SetCommit<St>> {
self._fields.2 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Ops: commit_state::IsUnset,
{
pub fn ops(
mut self,
value: impl Into<Vec<subscribe_repos::RepoOp<S>>>,
) -> CommitBuilder<S, commit_state::SetOps<St>> {
self._fields.3 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: commit_state::State> CommitBuilder<S, St> {
pub fn prev_data(mut self, value: impl Into<Option<CidLink<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_prev_data(mut self, value: Option<CidLink<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Rebase: commit_state::IsUnset,
{
pub fn rebase(
mut self,
value: impl Into<bool>,
) -> CommitBuilder<S, commit_state::SetRebase<St>> {
self._fields.5 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Repo: commit_state::IsUnset,
{
pub fn repo(mut self, value: impl Into<Did<S>>) -> CommitBuilder<S, commit_state::SetRepo<St>> {
self._fields.6 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Rev: commit_state::IsUnset,
{
pub fn rev(mut self, value: impl Into<Tid>) -> CommitBuilder<S, commit_state::SetRev<St>> {
self._fields.7 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Seq: commit_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> CommitBuilder<S, commit_state::SetSeq<St>> {
self._fields.8 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: commit_state::State> CommitBuilder<S, St> {
pub fn since(mut self, value: impl Into<Option<Tid>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_since(mut self, value: Option<Tid>) -> Self {
self._fields.9 = value;
self
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Time: commit_state::IsUnset,
{
pub fn time(
mut self,
value: impl Into<Datetime>,
) -> CommitBuilder<S, commit_state::SetTime<St>> {
self._fields.10 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::TooBig: commit_state::IsUnset,
{
pub fn too_big(
mut self,
value: impl Into<bool>,
) -> CommitBuilder<S, commit_state::SetTooBig<St>> {
self._fields.11 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Rev: commit_state::IsSet,
St::Seq: commit_state::IsSet,
St::TooBig: commit_state::IsSet,
St::Commit: commit_state::IsSet,
St::Ops: commit_state::IsSet,
St::Blocks: commit_state::IsSet,
St::Repo: commit_state::IsSet,
St::Blobs: commit_state::IsSet,
St::Time: commit_state::IsSet,
St::Rebase: commit_state::IsSet,
{
pub fn build(self) -> Commit<S> {
Commit {
blobs: self._fields.0.unwrap(),
blocks: self._fields.1.unwrap(),
commit: self._fields.2.unwrap(),
ops: self._fields.3.unwrap(),
prev_data: self._fields.4,
rebase: self._fields.5.unwrap(),
repo: self._fields.6.unwrap(),
rev: self._fields.7.unwrap(),
seq: self._fields.8.unwrap(),
since: self._fields.9,
time: self._fields.10.unwrap(),
too_big: self._fields.11.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Commit<S> {
Commit {
blobs: self._fields.0.unwrap(),
blocks: self._fields.1.unwrap(),
commit: self._fields.2.unwrap(),
ops: self._fields.3.unwrap(),
prev_data: self._fields.4,
rebase: self._fields.5.unwrap(),
repo: self._fields.6.unwrap(),
rev: self._fields.7.unwrap(),
seq: self._fields.8.unwrap(),
since: self._fields.9,
time: self._fields.10.unwrap(),
too_big: self._fields.11.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod identity_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Time;
type Seq;
type Did;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Time = Unset;
type Seq = Unset;
type Did = Unset;
}
pub struct SetTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTime<St> {}
impl<St: State> State for SetTime<St> {
type Time = Set<members::time>;
type Seq = St::Seq;
type Did = St::Did;
}
pub struct SetSeq<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeq<St> {}
impl<St: State> State for SetSeq<St> {
type Time = St::Time;
type Seq = Set<members::seq>;
type Did = St::Did;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Time = St::Time;
type Seq = St::Seq;
type Did = Set<members::did>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct time(());
pub struct seq(());
pub struct did(());
}
}
pub struct IdentityBuilder<S: BosStr, St: identity_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<Handle<S>>,
Option<i64>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Identity<S> {
pub fn new() -> IdentityBuilder<S, identity_state::Empty> {
IdentityBuilder::new()
}
}
impl<S: BosStr> IdentityBuilder<S, identity_state::Empty> {
pub fn new() -> Self {
IdentityBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IdentityBuilder<S, St>
where
St: identity_state::State,
St::Did: identity_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> IdentityBuilder<S, identity_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
IdentityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: identity_state::State> IdentityBuilder<S, St> {
pub fn handle(mut self, value: impl Into<Option<Handle<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_handle(mut self, value: Option<Handle<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> IdentityBuilder<S, St>
where
St: identity_state::State,
St::Seq: identity_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> IdentityBuilder<S, identity_state::SetSeq<St>> {
self._fields.2 = Option::Some(value.into());
IdentityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IdentityBuilder<S, St>
where
St: identity_state::State,
St::Time: identity_state::IsUnset,
{
pub fn time(
mut self,
value: impl Into<Datetime>,
) -> IdentityBuilder<S, identity_state::SetTime<St>> {
self._fields.3 = Option::Some(value.into());
IdentityBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IdentityBuilder<S, St>
where
St: identity_state::State,
St::Time: identity_state::IsSet,
St::Seq: identity_state::IsSet,
St::Did: identity_state::IsSet,
{
pub fn build(self) -> Identity<S> {
Identity {
did: self._fields.0.unwrap(),
handle: self._fields.1,
seq: self._fields.2.unwrap(),
time: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Identity<S> {
Identity {
did: self._fields.0.unwrap(),
handle: self._fields.1,
seq: self._fields.2.unwrap(),
time: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod subscribe_repos_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {}
#[allow(non_camel_case_types)]
pub mod members {}
}
pub struct SubscribeReposBuilder<St: subscribe_repos_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>,),
}
impl SubscribeRepos {
pub fn new() -> SubscribeReposBuilder<subscribe_repos_state::Empty> {
SubscribeReposBuilder::new()
}
}
impl SubscribeReposBuilder<subscribe_repos_state::Empty> {
pub fn new() -> Self {
SubscribeReposBuilder {
_state: PhantomData,
_fields: (None,),
}
}
}
impl<St: subscribe_repos_state::State> SubscribeReposBuilder<St> {
pub fn cursor(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<i64>) -> Self {
self._fields.0 = value;
self
}
}
impl<St> SubscribeReposBuilder<St>
where
St: subscribe_repos_state::State,
{
pub fn build(self) -> SubscribeRepos {
SubscribeRepos {
cursor: self._fields.0,
}
}
}
pub mod repo_op_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Path;
type Action;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Path = Unset;
type Action = Unset;
}
pub struct SetPath<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetPath<St> {}
impl<St: State> State for SetPath<St> {
type Path = Set<members::path>;
type Action = St::Action;
}
pub struct SetAction<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAction<St> {}
impl<St: State> State for SetAction<St> {
type Path = St::Path;
type Action = Set<members::action>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct path(());
pub struct action(());
}
}
pub struct RepoOpBuilder<S: BosStr, St: repo_op_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<RepoOpAction<S>>,
Option<CidLink<S>>,
Option<S>,
Option<CidLink<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> RepoOp<S> {
pub fn new() -> RepoOpBuilder<S, repo_op_state::Empty> {
RepoOpBuilder::new()
}
}
impl<S: BosStr> RepoOpBuilder<S, repo_op_state::Empty> {
pub fn new() -> Self {
RepoOpBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RepoOpBuilder<S, St>
where
St: repo_op_state::State,
St::Action: repo_op_state::IsUnset,
{
pub fn action(
mut self,
value: impl Into<RepoOpAction<S>>,
) -> RepoOpBuilder<S, repo_op_state::SetAction<St>> {
self._fields.0 = Option::Some(value.into());
RepoOpBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_op_state::State> RepoOpBuilder<S, St> {
pub fn cid(mut self, value: impl Into<Option<CidLink<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_cid(mut self, value: Option<CidLink<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> RepoOpBuilder<S, St>
where
St: repo_op_state::State,
St::Path: repo_op_state::IsUnset,
{
pub fn path(mut self, value: impl Into<S>) -> RepoOpBuilder<S, repo_op_state::SetPath<St>> {
self._fields.2 = Option::Some(value.into());
RepoOpBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_op_state::State> RepoOpBuilder<S, St> {
pub fn prev(mut self, value: impl Into<Option<CidLink<S>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_prev(mut self, value: Option<CidLink<S>>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> RepoOpBuilder<S, St>
where
St: repo_op_state::State,
St::Path: repo_op_state::IsSet,
St::Action: repo_op_state::IsSet,
{
pub fn build(self) -> RepoOp<S> {
RepoOp {
action: self._fields.0.unwrap(),
cid: self._fields.1,
path: self._fields.2.unwrap(),
prev: self._fields.3,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> RepoOp<S> {
RepoOp {
action: self._fields.0.unwrap(),
cid: self._fields.1,
path: self._fields.2.unwrap(),
prev: self._fields.3,
extra_data: Some(extra_data),
}
}
}
pub mod sync_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Time;
type Did;
type Seq;
type Rev;
type Blocks;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Time = Unset;
type Did = Unset;
type Seq = Unset;
type Rev = Unset;
type Blocks = Unset;
}
pub struct SetTime<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTime<St> {}
impl<St: State> State for SetTime<St> {
type Time = Set<members::time>;
type Did = St::Did;
type Seq = St::Seq;
type Rev = St::Rev;
type Blocks = St::Blocks;
}
pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetDid<St> {}
impl<St: State> State for SetDid<St> {
type Time = St::Time;
type Did = Set<members::did>;
type Seq = St::Seq;
type Rev = St::Rev;
type Blocks = St::Blocks;
}
pub struct SetSeq<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSeq<St> {}
impl<St: State> State for SetSeq<St> {
type Time = St::Time;
type Did = St::Did;
type Seq = Set<members::seq>;
type Rev = St::Rev;
type Blocks = St::Blocks;
}
pub struct SetRev<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRev<St> {}
impl<St: State> State for SetRev<St> {
type Time = St::Time;
type Did = St::Did;
type Seq = St::Seq;
type Rev = Set<members::rev>;
type Blocks = St::Blocks;
}
pub struct SetBlocks<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetBlocks<St> {}
impl<St: State> State for SetBlocks<St> {
type Time = St::Time;
type Did = St::Did;
type Seq = St::Seq;
type Rev = St::Rev;
type Blocks = Set<members::blocks>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct time(());
pub struct did(());
pub struct seq(());
pub struct rev(());
pub struct blocks(());
}
}
pub struct SyncBuilder<S: BosStr, St: sync_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Bytes>,
Option<Did<S>>,
Option<S>,
Option<i64>,
Option<Datetime>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Sync<S> {
pub fn new() -> SyncBuilder<S, sync_state::Empty> {
SyncBuilder::new()
}
}
impl<S: BosStr> SyncBuilder<S, sync_state::Empty> {
pub fn new() -> Self {
SyncBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SyncBuilder<S, St>
where
St: sync_state::State,
St::Blocks: sync_state::IsUnset,
{
pub fn blocks(mut self, value: impl Into<Bytes>) -> SyncBuilder<S, sync_state::SetBlocks<St>> {
self._fields.0 = Option::Some(value.into());
SyncBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SyncBuilder<S, St>
where
St: sync_state::State,
St::Did: sync_state::IsUnset,
{
pub fn did(mut self, value: impl Into<Did<S>>) -> SyncBuilder<S, sync_state::SetDid<St>> {
self._fields.1 = Option::Some(value.into());
SyncBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SyncBuilder<S, St>
where
St: sync_state::State,
St::Rev: sync_state::IsUnset,
{
pub fn rev(mut self, value: impl Into<S>) -> SyncBuilder<S, sync_state::SetRev<St>> {
self._fields.2 = Option::Some(value.into());
SyncBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SyncBuilder<S, St>
where
St: sync_state::State,
St::Seq: sync_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> SyncBuilder<S, sync_state::SetSeq<St>> {
self._fields.3 = Option::Some(value.into());
SyncBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SyncBuilder<S, St>
where
St: sync_state::State,
St::Time: sync_state::IsUnset,
{
pub fn time(mut self, value: impl Into<Datetime>) -> SyncBuilder<S, sync_state::SetTime<St>> {
self._fields.4 = Option::Some(value.into());
SyncBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SyncBuilder<S, St>
where
St: sync_state::State,
St::Time: sync_state::IsSet,
St::Did: sync_state::IsSet,
St::Seq: sync_state::IsSet,
St::Rev: sync_state::IsSet,
St::Blocks: sync_state::IsSet,
{
pub fn build(self) -> Sync<S> {
Sync {
blocks: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
rev: self._fields.2.unwrap(),
seq: self._fields.3.unwrap(),
time: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Sync<S> {
Sync {
blocks: self._fields.0.unwrap(),
did: self._fields.1.unwrap(),
rev: self._fields.2.unwrap(),
seq: self._fields.3.unwrap(),
time: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}