#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
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::string::{AtUri, Datetime, Did};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::sh_tangled::knot::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 GitSync1<S: BosStr = DefaultStr> {
pub did: Did<S>,
pub seq: i64,
#[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 GitSync2<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub did: Option<AtUri<S>>,
pub seq: i64,
#[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>,
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)]
#[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 = "#identity")]
Identity(Box<subscribe_repos::Identity<S>>),
#[serde(rename = "gitRefUpdate")]
GitRefUpdate(Box<Data<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() {
"#identity" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::Identity(Box::new(variant)))
}
"gitRefUpdate" => {
let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(body)?;
Ok(Self::GitRefUpdate(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(())
}
}
}
}
impl<S: BosStr> LexiconSchema for GitSync1<S> {
fn nsid() -> &'static str {
"sh.tangled.knot.subscribeRepos"
}
fn def_name() -> &'static str {
"gitSync1"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_knot_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for GitSync2<S> {
fn nsid() -> &'static str {
"sh.tangled.knot.subscribeRepos"
}
fn def_name() -> &'static str {
"gitSync2"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_knot_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Identity<S> {
fn nsid() -> &'static str {
"sh.tangled.knot.subscribeRepos"
}
fn def_name() -> &'static str {
"identity"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_knot_subscribeRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub struct SubscribeReposStream;
impl jacquard_common::xrpc::SubscriptionResp for SubscribeReposStream {
const NSID: &'static str = "sh.tangled.knot.subscribeRepos";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::Json;
type Message<S: BosStr> = SubscribeReposMessage<S>;
type Error = SubscribeReposError;
}
impl jacquard_common::xrpc::XrpcSubscription for SubscribeRepos {
const NSID: &'static str = "sh.tangled.knot.subscribeRepos";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::Json;
type Stream = SubscribeReposStream;
}
pub struct SubscribeReposEndpoint;
impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeReposEndpoint {
const PATH: &'static str = "/xrpc/sh.tangled.knot.subscribeRepos";
const ENCODING: jacquard_common::xrpc::MessageEncoding =
jacquard_common::xrpc::MessageEncoding::Json;
type Params<S: BosStr> = SubscribeRepos;
type Stream = SubscribeReposStream;
}
pub mod git_sync1_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;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Seq = Unset;
type Did = 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;
}
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>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct seq(());
pub struct did(());
}
}
pub struct GitSync1Builder<S: BosStr, St: git_sync1_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Did<S>>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GitSync1<S> {
pub fn new() -> GitSync1Builder<S, git_sync1_state::Empty> {
GitSync1Builder::new()
}
}
impl<S: BosStr> GitSync1Builder<S, git_sync1_state::Empty> {
pub fn new() -> Self {
GitSync1Builder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GitSync1Builder<S, St>
where
St: git_sync1_state::State,
St::Did: git_sync1_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> GitSync1Builder<S, git_sync1_state::SetDid<St>> {
self._fields.0 = Option::Some(value.into());
GitSync1Builder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GitSync1Builder<S, St>
where
St: git_sync1_state::State,
St::Seq: git_sync1_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> GitSync1Builder<S, git_sync1_state::SetSeq<St>> {
self._fields.1 = Option::Some(value.into());
GitSync1Builder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GitSync1Builder<S, St>
where
St: git_sync1_state::State,
St::Seq: git_sync1_state::IsSet,
St::Did: git_sync1_state::IsSet,
{
pub fn build(self) -> GitSync1<S> {
GitSync1 {
did: self._fields.0.unwrap(),
seq: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> GitSync1<S> {
GitSync1 {
did: self._fields.0.unwrap(),
seq: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_knot_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("sh.tangled.knot.subscribeRepos"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("gitSync1"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("seq"), SmolStr::new_static("did")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Repository DID identifier")),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("gitSync2"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("seq"),
SmolStr::new_static("repo"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("did"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Repository AT-URI identifier",
)),
format: Some(LexStringFormat::AtUri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("seq"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("identity"),
LexUserType::Object(LexObject {
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 {
description: Some(CowStr::new_static("Repository DID identifier")),
format: Some(LexStringFormat::Did),
..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("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
},
..Default::default()
}
}
pub mod git_sync2_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 Repo;
type Seq;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Repo = Unset;
type Seq = Unset;
}
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 Repo = Set<members::repo>;
type Seq = St::Seq;
}
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 Repo = St::Repo;
type Seq = Set<members::seq>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct repo(());
pub struct seq(());
}
}
pub struct GitSync2Builder<S: BosStr, St: git_sync2_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<AtUri<S>>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> GitSync2<S> {
pub fn new() -> GitSync2Builder<S, git_sync2_state::Empty> {
GitSync2Builder::new()
}
}
impl<S: BosStr> GitSync2Builder<S, git_sync2_state::Empty> {
pub fn new() -> Self {
GitSync2Builder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: git_sync2_state::State> GitSync2Builder<S, St> {
pub fn did(mut self, value: impl Into<Option<AtUri<S>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_did(mut self, value: Option<AtUri<S>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> GitSync2Builder<S, St>
where
St: git_sync2_state::State,
St::Seq: git_sync2_state::IsUnset,
{
pub fn seq(mut self, value: impl Into<i64>) -> GitSync2Builder<S, git_sync2_state::SetSeq<St>> {
self._fields.1 = Option::Some(value.into());
GitSync2Builder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> GitSync2Builder<S, St>
where
St: git_sync2_state::State,
St::Repo: git_sync2_state::IsSet,
St::Seq: git_sync2_state::IsSet,
{
pub fn build(self) -> GitSync2<S> {
GitSync2 {
did: self._fields.0,
seq: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> GitSync2<S> {
GitSync2 {
did: self._fields.0,
seq: self._fields.1.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<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),
_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> 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.1 = 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.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::IsSet,
St::Seq: identity_state::IsSet,
St::Did: identity_state::IsSet,
{
pub fn build(self) -> Identity<S> {
Identity {
did: self._fields.0.unwrap(),
seq: self._fields.1.unwrap(),
time: self._fields.2.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(),
seq: self._fields.1.unwrap(),
time: self._fields.2.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,
}
}
}