#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, 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::{Did, Tid, Cid};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::sync::list_repos;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListRepos<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
#[serde(default = "_default_limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListReposOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<S>,
pub repos: Vec<list_repos::Repo<S>>,
#[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 Repo<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub active: Option<bool>,
pub did: Did<S>,
pub head: Cid<S>,
pub rev: Tid,
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<RepoStatus<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 RepoStatus<S: BosStr = DefaultStr> {
Takendown,
Suspended,
Deleted,
Deactivated,
Desynchronized,
Throttled,
Other(S),
}
impl<S: BosStr> RepoStatus<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 RepoStatus<S> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.as_str())
}
}
impl<S: BosStr> AsRef<str> for RepoStatus<S> {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl<S: BosStr> Serialize for RepoStatus<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 RepoStatus<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 RepoStatus<S> {
fn default() -> Self {
Self::Other(Default::default())
}
}
impl<S: BosStr> jacquard_common::IntoStatic for RepoStatus<S>
where
S: BosStr + jacquard_common::IntoStatic,
S::Output: BosStr,
{
type Output = RepoStatus<S::Output>;
fn into_static(self) -> Self::Output {
match self {
RepoStatus::Takendown => RepoStatus::Takendown,
RepoStatus::Suspended => RepoStatus::Suspended,
RepoStatus::Deleted => RepoStatus::Deleted,
RepoStatus::Deactivated => RepoStatus::Deactivated,
RepoStatus::Desynchronized => RepoStatus::Desynchronized,
RepoStatus::Throttled => RepoStatus::Throttled,
RepoStatus::Other(v) => RepoStatus::Other(v.into_static()),
}
}
}
pub struct ListReposResponse;
impl jacquard_common::xrpc::XrpcResp for ListReposResponse {
const NSID: &'static str = "com.atproto.sync.listRepos";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = ListReposOutput<S>;
type Err = jacquard_common::xrpc::GenericError;
}
impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ListRepos<S> {
const NSID: &'static str = "com.atproto.sync.listRepos";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Response = ListReposResponse;
}
pub struct ListReposRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ListReposRequest {
const PATH: &'static str = "/xrpc/com.atproto.sync.listRepos";
const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
type Request<S: BosStr> = ListRepos<S>;
type Response = ListReposResponse;
}
impl<S: BosStr> LexiconSchema for Repo<S> {
fn nsid() -> &'static str {
"com.atproto.sync.listRepos"
}
fn def_name() -> &'static str {
"repo"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_atproto_sync_listRepos()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn _default_limit() -> Option<i64> {
Some(500i64)
}
pub mod list_repos_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[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 ListReposBuilder<S: BosStr, St: list_repos_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ListRepos<S> {
pub fn new() -> ListReposBuilder<S, list_repos_state::Empty> {
ListReposBuilder::new()
}
}
impl<S: BosStr> ListReposBuilder<S, list_repos_state::Empty> {
pub fn new() -> Self {
ListReposBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: list_repos_state::State> ListReposBuilder<S, St> {
pub fn cursor(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_cursor(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: list_repos_state::State> ListReposBuilder<S, St> {
pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> ListReposBuilder<S, St>
where
St: list_repos_state::State,
{
pub fn build(self) -> ListRepos<S> {
ListRepos {
cursor: self._fields.0,
limit: self._fields.1,
}
}
}
pub mod repo_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Rev;
type Did;
type Head;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Rev = Unset;
type Did = Unset;
type Head = 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 Did = St::Did;
type Head = St::Head;
}
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 Rev = St::Rev;
type Did = Set<members::did>;
type Head = St::Head;
}
pub struct SetHead<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHead<St> {}
impl<St: State> State for SetHead<St> {
type Rev = St::Rev;
type Did = St::Did;
type Head = Set<members::head>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct rev(());
pub struct did(());
pub struct head(());
}
}
pub struct RepoBuilder<S: BosStr, St: repo_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<bool>,
Option<Did<S>>,
Option<Cid<S>>,
Option<Tid>,
Option<RepoStatus<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Repo<S> {
pub fn new() -> RepoBuilder<S, repo_state::Empty> {
RepoBuilder::new()
}
}
impl<S: BosStr> RepoBuilder<S, repo_state::Empty> {
pub fn new() -> Self {
RepoBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn active(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_active(mut self, value: Option<bool>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Did: repo_state::IsUnset,
{
pub fn did(
mut self,
value: impl Into<Did<S>>,
) -> RepoBuilder<S, repo_state::SetDid<St>> {
self._fields.1 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Head: repo_state::IsUnset,
{
pub fn head(
mut self,
value: impl Into<Cid<S>>,
) -> RepoBuilder<S, repo_state::SetHead<St>> {
self._fields.2 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Rev: repo_state::IsUnset,
{
pub fn rev(
mut self,
value: impl Into<Tid>,
) -> RepoBuilder<S, repo_state::SetRev<St>> {
self._fields.3 = Option::Some(value.into());
RepoBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: repo_state::State> RepoBuilder<S, St> {
pub fn status(mut self, value: impl Into<Option<RepoStatus<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_status(mut self, value: Option<RepoStatus<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> RepoBuilder<S, St>
where
St: repo_state::State,
St::Rev: repo_state::IsSet,
St::Did: repo_state::IsSet,
St::Head: repo_state::IsSet,
{
pub fn build(self) -> Repo<S> {
Repo {
active: self._fields.0,
did: self._fields.1.unwrap(),
head: self._fields.2.unwrap(),
rev: self._fields.3.unwrap(),
status: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Repo<S> {
Repo {
active: self._fields.0,
did: self._fields.1.unwrap(),
head: self._fields.2.unwrap(),
rev: self._fields.3.unwrap(),
status: self._fields.4,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_atproto_sync_listRepos() -> LexiconDoc<'static> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("com.atproto.sync.listRepos"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::XrpcQuery(LexXrpcQuery {
parameters: Some(
LexXrpcQueryParameter::Params(LexXrpcParameters {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("cursor"),
LexXrpcParametersProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("limit"),
LexXrpcParametersProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repo"),
LexUserType::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("did"), SmolStr::new_static("head"),
SmolStr::new_static("rev")
],
),
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("head"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Current repo commit CID"),
),
format: Some(LexStringFormat::Cid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("rev"),
LexObjectProperty::String(LexString {
format: Some(LexStringFormat::Tid),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("status"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted.",
),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}