#[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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Did};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::sh_tangled::git::ref_update;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CommitCountBreakdown<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub by_email: Option<Vec<ref_update::IndividualEmailCommitCount<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 IndividualEmailCommitCount<S: BosStr = DefaultStr> {
pub count: i64,
pub email: 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 IndividualLanguageSize<S: BosStr = DefaultStr> {
pub lang: S,
pub size: 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, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct LangBreakdown<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub inputs: Option<Vec<ref_update::IndividualLanguageSize<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",
rename = "sh.tangled.git.refUpdate",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct RefUpdate<S: BosStr = DefaultStr> {
pub committer_did: Did<S>,
pub meta: ref_update::Meta<S>,
pub new_sha: S,
pub old_sha: S,
pub r#ref: S,
pub repo_did: Did<S>,
pub repo_name: 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")]
pub struct RefUpdateGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: RefUpdate<S>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Meta<S: BosStr = DefaultStr> {
pub commit_count: ref_update::CommitCountBreakdown<S>,
#[serde(default = "_default_meta_is_default_ref")]
pub is_default_ref: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub lang_breakdown: Option<ref_update::LangBreakdown<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> RefUpdate<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, RefUpdateRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
impl<S: BosStr> LexiconSchema for CommitCountBreakdown<S> {
fn nsid() -> &'static str {
"sh.tangled.git.refUpdate"
}
fn def_name() -> &'static str {
"commitCountBreakdown"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_refUpdate()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for IndividualEmailCommitCount<S> {
fn nsid() -> &'static str {
"sh.tangled.git.refUpdate"
}
fn def_name() -> &'static str {
"individualEmailCommitCount"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_refUpdate()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for IndividualLanguageSize<S> {
fn nsid() -> &'static str {
"sh.tangled.git.refUpdate"
}
fn def_name() -> &'static str {
"individualLanguageSize"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_refUpdate()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for LangBreakdown<S> {
fn nsid() -> &'static str {
"sh.tangled.git.refUpdate"
}
fn def_name() -> &'static str {
"langBreakdown"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_refUpdate()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct RefUpdateRecord;
impl XrpcResp for RefUpdateRecord {
const NSID: &'static str = "sh.tangled.git.refUpdate";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = RefUpdateGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<RefUpdateGetRecordOutput<S>> for RefUpdate<S> {
fn from(output: RefUpdateGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for RefUpdate<S> {
const NSID: &'static str = "sh.tangled.git.refUpdate";
type Record = RefUpdateRecord;
}
impl Collection for RefUpdateRecord {
const NSID: &'static str = "sh.tangled.git.refUpdate";
type Record = RefUpdateRecord;
}
impl<S: BosStr> LexiconSchema for RefUpdate<S> {
fn nsid() -> &'static str {
"sh.tangled.git.refUpdate"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_refUpdate()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.new_sha;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 40usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("new_sha"),
max: 40usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.new_sha;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 40usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("new_sha"),
min: 40usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.old_sha;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 40usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("old_sha"),
max: 40usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.old_sha;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) < 40usize {
return Err(ConstraintError::MinLength {
path: ValidationPath::from_field("old_sha"),
min: 40usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.r#ref;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 2560usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("ref"),
max: 2560usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.r#ref;
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 256usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("ref"),
max: 256usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Meta<S> {
fn nsid() -> &'static str {
"sh.tangled.git.refUpdate"
}
fn def_name() -> &'static str {
"meta"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_refUpdate()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
fn lexicon_doc_sh_tangled_git_refUpdate() -> 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.git.refUpdate"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("commitCountBreakdown"),
LexUserType::Object(LexObject {
required: Some(vec![]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("byEmail"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#individualEmailCommitCount"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("individualEmailCommitCount"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("email"),
SmolStr::new_static("count"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("count"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("email"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("individualLanguageSize"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("lang"),
SmolStr::new_static("size"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("lang"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("langBreakdown"),
LexUserType::Object(LexObject {
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("inputs"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#individualLanguageSize"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(CowStr::new_static(
"An update to a git repository, emitted by knots.",
)),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(vec![
SmolStr::new_static("ref"),
SmolStr::new_static("committerDid"),
SmolStr::new_static("repoDid"),
SmolStr::new_static("repoName"),
SmolStr::new_static("oldSha"),
SmolStr::new_static("newSha"),
SmolStr::new_static("meta"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("committerDid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"did of the user that pushed this ref",
)),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("meta"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#meta"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("newSha"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("new SHA of this ref")),
min_length: Some(40usize),
max_length: Some(40usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("oldSha"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("old SHA of this ref")),
min_length: Some(40usize),
max_length: Some(40usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("ref"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Ref being updated")),
max_length: Some(2560usize),
max_graphemes: Some(256usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repoDid"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"did of the owner of the repo",
)),
format: Some(LexStringFormat::Did),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("repoName"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("name of the repo")),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("meta"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("isDefaultRef"),
SmolStr::new_static("commitCount"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("commitCount"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#commitCountBreakdown"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("isDefaultRef"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("langBreakdown"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#langBreakdown"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod individual_email_commit_count_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 Count;
type Email;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Count = Unset;
type Email = Unset;
}
pub struct SetCount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCount<St> {}
impl<St: State> State for SetCount<St> {
type Count = Set<members::count>;
type Email = St::Email;
}
pub struct SetEmail<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetEmail<St> {}
impl<St: State> State for SetEmail<St> {
type Count = St::Count;
type Email = Set<members::email>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct count(());
pub struct email(());
}
}
pub struct IndividualEmailCommitCountBuilder<
S: BosStr,
St: individual_email_commit_count_state::State,
> {
_state: PhantomData<fn() -> St>,
_fields: (Option<i64>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> IndividualEmailCommitCount<S> {
pub fn new() -> IndividualEmailCommitCountBuilder<S, individual_email_commit_count_state::Empty>
{
IndividualEmailCommitCountBuilder::new()
}
}
impl<S: BosStr> IndividualEmailCommitCountBuilder<S, individual_email_commit_count_state::Empty> {
pub fn new() -> Self {
IndividualEmailCommitCountBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IndividualEmailCommitCountBuilder<S, St>
where
St: individual_email_commit_count_state::State,
St::Count: individual_email_commit_count_state::IsUnset,
{
pub fn count(
mut self,
value: impl Into<i64>,
) -> IndividualEmailCommitCountBuilder<S, individual_email_commit_count_state::SetCount<St>>
{
self._fields.0 = Option::Some(value.into());
IndividualEmailCommitCountBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IndividualEmailCommitCountBuilder<S, St>
where
St: individual_email_commit_count_state::State,
St::Email: individual_email_commit_count_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<S>,
) -> IndividualEmailCommitCountBuilder<S, individual_email_commit_count_state::SetEmail<St>>
{
self._fields.1 = Option::Some(value.into());
IndividualEmailCommitCountBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IndividualEmailCommitCountBuilder<S, St>
where
St: individual_email_commit_count_state::State,
St::Count: individual_email_commit_count_state::IsSet,
St::Email: individual_email_commit_count_state::IsSet,
{
pub fn build(self) -> IndividualEmailCommitCount<S> {
IndividualEmailCommitCount {
count: self._fields.0.unwrap(),
email: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> IndividualEmailCommitCount<S> {
IndividualEmailCommitCount {
count: self._fields.0.unwrap(),
email: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod individual_language_size_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 Lang;
type Size;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Lang = Unset;
type Size = Unset;
}
pub struct SetLang<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLang<St> {}
impl<St: State> State for SetLang<St> {
type Lang = Set<members::lang>;
type Size = St::Size;
}
pub struct SetSize<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetSize<St> {}
impl<St: State> State for SetSize<St> {
type Lang = St::Lang;
type Size = Set<members::size>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct lang(());
pub struct size(());
}
}
pub struct IndividualLanguageSizeBuilder<S: BosStr, St: individual_language_size_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> IndividualLanguageSize<S> {
pub fn new() -> IndividualLanguageSizeBuilder<S, individual_language_size_state::Empty> {
IndividualLanguageSizeBuilder::new()
}
}
impl<S: BosStr> IndividualLanguageSizeBuilder<S, individual_language_size_state::Empty> {
pub fn new() -> Self {
IndividualLanguageSizeBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IndividualLanguageSizeBuilder<S, St>
where
St: individual_language_size_state::State,
St::Lang: individual_language_size_state::IsUnset,
{
pub fn lang(
mut self,
value: impl Into<S>,
) -> IndividualLanguageSizeBuilder<S, individual_language_size_state::SetLang<St>> {
self._fields.0 = Option::Some(value.into());
IndividualLanguageSizeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IndividualLanguageSizeBuilder<S, St>
where
St: individual_language_size_state::State,
St::Size: individual_language_size_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> IndividualLanguageSizeBuilder<S, individual_language_size_state::SetSize<St>> {
self._fields.1 = Option::Some(value.into());
IndividualLanguageSizeBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> IndividualLanguageSizeBuilder<S, St>
where
St: individual_language_size_state::State,
St::Lang: individual_language_size_state::IsSet,
St::Size: individual_language_size_state::IsSet,
{
pub fn build(self) -> IndividualLanguageSize<S> {
IndividualLanguageSize {
lang: self._fields.0.unwrap(),
size: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> IndividualLanguageSize<S> {
IndividualLanguageSize {
lang: self._fields.0.unwrap(),
size: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod ref_update_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 RepoDid;
type RepoName;
type Meta;
type Ref;
type NewSha;
type CommitterDid;
type OldSha;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type RepoDid = Unset;
type RepoName = Unset;
type Meta = Unset;
type Ref = Unset;
type NewSha = Unset;
type CommitterDid = Unset;
type OldSha = Unset;
}
pub struct SetRepoDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepoDid<St> {}
impl<St: State> State for SetRepoDid<St> {
type RepoDid = Set<members::repo_did>;
type RepoName = St::RepoName;
type Meta = St::Meta;
type Ref = St::Ref;
type NewSha = St::NewSha;
type CommitterDid = St::CommitterDid;
type OldSha = St::OldSha;
}
pub struct SetRepoName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRepoName<St> {}
impl<St: State> State for SetRepoName<St> {
type RepoDid = St::RepoDid;
type RepoName = Set<members::repo_name>;
type Meta = St::Meta;
type Ref = St::Ref;
type NewSha = St::NewSha;
type CommitterDid = St::CommitterDid;
type OldSha = St::OldSha;
}
pub struct SetMeta<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMeta<St> {}
impl<St: State> State for SetMeta<St> {
type RepoDid = St::RepoDid;
type RepoName = St::RepoName;
type Meta = Set<members::meta>;
type Ref = St::Ref;
type NewSha = St::NewSha;
type CommitterDid = St::CommitterDid;
type OldSha = St::OldSha;
}
pub struct SetRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetRef<St> {}
impl<St: State> State for SetRef<St> {
type RepoDid = St::RepoDid;
type RepoName = St::RepoName;
type Meta = St::Meta;
type Ref = Set<members::r#ref>;
type NewSha = St::NewSha;
type CommitterDid = St::CommitterDid;
type OldSha = St::OldSha;
}
pub struct SetNewSha<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetNewSha<St> {}
impl<St: State> State for SetNewSha<St> {
type RepoDid = St::RepoDid;
type RepoName = St::RepoName;
type Meta = St::Meta;
type Ref = St::Ref;
type NewSha = Set<members::new_sha>;
type CommitterDid = St::CommitterDid;
type OldSha = St::OldSha;
}
pub struct SetCommitterDid<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCommitterDid<St> {}
impl<St: State> State for SetCommitterDid<St> {
type RepoDid = St::RepoDid;
type RepoName = St::RepoName;
type Meta = St::Meta;
type Ref = St::Ref;
type NewSha = St::NewSha;
type CommitterDid = Set<members::committer_did>;
type OldSha = St::OldSha;
}
pub struct SetOldSha<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetOldSha<St> {}
impl<St: State> State for SetOldSha<St> {
type RepoDid = St::RepoDid;
type RepoName = St::RepoName;
type Meta = St::Meta;
type Ref = St::Ref;
type NewSha = St::NewSha;
type CommitterDid = St::CommitterDid;
type OldSha = Set<members::old_sha>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct repo_did(());
pub struct repo_name(());
pub struct meta(());
pub struct r#ref(());
pub struct new_sha(());
pub struct committer_did(());
pub struct old_sha(());
}
}
pub struct RefUpdateBuilder<S: BosStr, St: ref_update_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Did<S>>,
Option<ref_update::Meta<S>>,
Option<S>,
Option<S>,
Option<S>,
Option<Did<S>>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> RefUpdate<S> {
pub fn new() -> RefUpdateBuilder<S, ref_update_state::Empty> {
RefUpdateBuilder::new()
}
}
impl<S: BosStr> RefUpdateBuilder<S, ref_update_state::Empty> {
pub fn new() -> Self {
RefUpdateBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::CommitterDid: ref_update_state::IsUnset,
{
pub fn committer_did(
mut self,
value: impl Into<Did<S>>,
) -> RefUpdateBuilder<S, ref_update_state::SetCommitterDid<St>> {
self._fields.0 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::Meta: ref_update_state::IsUnset,
{
pub fn meta(
mut self,
value: impl Into<ref_update::Meta<S>>,
) -> RefUpdateBuilder<S, ref_update_state::SetMeta<St>> {
self._fields.1 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::NewSha: ref_update_state::IsUnset,
{
pub fn new_sha(
mut self,
value: impl Into<S>,
) -> RefUpdateBuilder<S, ref_update_state::SetNewSha<St>> {
self._fields.2 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::OldSha: ref_update_state::IsUnset,
{
pub fn old_sha(
mut self,
value: impl Into<S>,
) -> RefUpdateBuilder<S, ref_update_state::SetOldSha<St>> {
self._fields.3 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::Ref: ref_update_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<S>,
) -> RefUpdateBuilder<S, ref_update_state::SetRef<St>> {
self._fields.4 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::RepoDid: ref_update_state::IsUnset,
{
pub fn repo_did(
mut self,
value: impl Into<Did<S>>,
) -> RefUpdateBuilder<S, ref_update_state::SetRepoDid<St>> {
self._fields.5 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::RepoName: ref_update_state::IsUnset,
{
pub fn repo_name(
mut self,
value: impl Into<S>,
) -> RefUpdateBuilder<S, ref_update_state::SetRepoName<St>> {
self._fields.6 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> RefUpdateBuilder<S, St>
where
St: ref_update_state::State,
St::RepoDid: ref_update_state::IsSet,
St::RepoName: ref_update_state::IsSet,
St::Meta: ref_update_state::IsSet,
St::Ref: ref_update_state::IsSet,
St::NewSha: ref_update_state::IsSet,
St::CommitterDid: ref_update_state::IsSet,
St::OldSha: ref_update_state::IsSet,
{
pub fn build(self) -> RefUpdate<S> {
RefUpdate {
committer_did: self._fields.0.unwrap(),
meta: self._fields.1.unwrap(),
new_sha: self._fields.2.unwrap(),
old_sha: self._fields.3.unwrap(),
r#ref: self._fields.4.unwrap(),
repo_did: self._fields.5.unwrap(),
repo_name: self._fields.6.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> RefUpdate<S> {
RefUpdate {
committer_did: self._fields.0.unwrap(),
meta: self._fields.1.unwrap(),
new_sha: self._fields.2.unwrap(),
old_sha: self._fields.3.unwrap(),
r#ref: self._fields.4.unwrap(),
repo_did: self._fields.5.unwrap(),
repo_name: self._fields.6.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn _default_meta_is_default_ref() -> bool {
false
}
pub mod meta_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 CommitCount;
type IsDefaultRef;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type CommitCount = Unset;
type IsDefaultRef = Unset;
}
pub struct SetCommitCount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCommitCount<St> {}
impl<St: State> State for SetCommitCount<St> {
type CommitCount = Set<members::commit_count>;
type IsDefaultRef = St::IsDefaultRef;
}
pub struct SetIsDefaultRef<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetIsDefaultRef<St> {}
impl<St: State> State for SetIsDefaultRef<St> {
type CommitCount = St::CommitCount;
type IsDefaultRef = Set<members::is_default_ref>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct commit_count(());
pub struct is_default_ref(());
}
}
pub struct MetaBuilder<S: BosStr, St: meta_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<ref_update::CommitCountBreakdown<S>>,
Option<bool>,
Option<ref_update::LangBreakdown<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Meta<S> {
pub fn new() -> MetaBuilder<S, meta_state::Empty> {
MetaBuilder::new()
}
}
impl<S: BosStr> MetaBuilder<S, meta_state::Empty> {
pub fn new() -> Self {
MetaBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MetaBuilder<S, St>
where
St: meta_state::State,
St::CommitCount: meta_state::IsUnset,
{
pub fn commit_count(
mut self,
value: impl Into<ref_update::CommitCountBreakdown<S>>,
) -> MetaBuilder<S, meta_state::SetCommitCount<St>> {
self._fields.0 = Option::Some(value.into());
MetaBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> MetaBuilder<S, St>
where
St: meta_state::State,
St::IsDefaultRef: meta_state::IsUnset,
{
pub fn is_default_ref(
mut self,
value: impl Into<bool>,
) -> MetaBuilder<S, meta_state::SetIsDefaultRef<St>> {
self._fields.1 = Option::Some(value.into());
MetaBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: meta_state::State> MetaBuilder<S, St> {
pub fn lang_breakdown(
mut self,
value: impl Into<Option<ref_update::LangBreakdown<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_lang_breakdown(mut self, value: Option<ref_update::LangBreakdown<S>>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> MetaBuilder<S, St>
where
St: meta_state::State,
St::CommitCount: meta_state::IsSet,
St::IsDefaultRef: meta_state::IsSet,
{
pub fn build(self) -> Meta<S> {
Meta {
commit_count: self._fields.0.unwrap(),
is_default_ref: self._fields.1.unwrap(),
lang_breakdown: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Meta<S> {
Meta {
commit_count: self._fields.0.unwrap(),
is_default_ref: self._fields.1.unwrap(),
lang_breakdown: self._fields.2,
extra_data: Some(extra_data),
}
}
}