#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
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::sh_tangled::git::ref_update;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CommitCountBreakdown<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub by_email: Option<Vec<ref_update::IndividualEmailCommitCount<'a>>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct IndividualEmailCommitCount<'a> {
pub count: i64,
#[serde(borrow)]
pub email: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct IndividualLanguageSize<'a> {
#[serde(borrow)]
pub lang: CowStr<'a>,
pub size: i64,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct LangBreakdown<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub inputs: Option<Vec<ref_update::IndividualLanguageSize<'a>>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RefUpdate<'a> {
#[serde(borrow)]
pub committer_did: Did<'a>,
#[serde(borrow)]
pub meta: ref_update::Meta<'a>,
#[serde(borrow)]
pub new_sha: CowStr<'a>,
#[serde(borrow)]
pub old_sha: CowStr<'a>,
#[serde(borrow)]
pub r#ref: CowStr<'a>,
#[serde(borrow)]
pub repo_did: Did<'a>,
#[serde(borrow)]
pub repo_name: CowStr<'a>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RefUpdateGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: RefUpdate<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Meta<'a> {
#[serde(borrow)]
pub commit_count: ref_update::CommitCountBreakdown<'a>,
#[serde(default = "_default_meta_is_default_ref")]
pub is_default_ref: bool,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub lang_breakdown: Option<ref_update::LangBreakdown<'a>>,
}
impl<'a> RefUpdate<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, RefUpdateRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
impl<'a> LexiconSchema for CommitCountBreakdown<'a> {
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<'a> LexiconSchema for IndividualEmailCommitCount<'a> {
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<'a> LexiconSchema for IndividualLanguageSize<'a> {
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<'a> LexiconSchema for LangBreakdown<'a> {
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<'de> = RefUpdateGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<RefUpdateGetRecordOutput<'_>> for RefUpdate<'_> {
fn from(output: RefUpdateGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for RefUpdate<'_> {
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<'a> LexiconSchema for RefUpdate<'a> {
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<'a> LexiconSchema for Meta<'a> {
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> {
#[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("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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Email;
type Count;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Email = Unset;
type Count = Unset;
}
pub struct SetEmail<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetEmail<S> {}
impl<S: State> State for SetEmail<S> {
type Email = Set<members::email>;
type Count = S::Count;
}
pub struct SetCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCount<S> {}
impl<S: State> State for SetCount<S> {
type Email = S::Email;
type Count = Set<members::count>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct email(());
pub struct count(());
}
}
pub struct IndividualEmailCommitCountBuilder<
'a,
S: individual_email_commit_count_state::State,
> {
_state: PhantomData<fn() -> S>,
_fields: (Option<i64>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> IndividualEmailCommitCount<'a> {
pub fn new() -> IndividualEmailCommitCountBuilder<
'a,
individual_email_commit_count_state::Empty,
> {
IndividualEmailCommitCountBuilder::new()
}
}
impl<
'a,
> IndividualEmailCommitCountBuilder<'a, individual_email_commit_count_state::Empty> {
pub fn new() -> Self {
IndividualEmailCommitCountBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> IndividualEmailCommitCountBuilder<'a, S>
where
S: individual_email_commit_count_state::State,
S::Count: individual_email_commit_count_state::IsUnset,
{
pub fn count(
mut self,
value: impl Into<i64>,
) -> IndividualEmailCommitCountBuilder<
'a,
individual_email_commit_count_state::SetCount<S>,
> {
self._fields.0 = Option::Some(value.into());
IndividualEmailCommitCountBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IndividualEmailCommitCountBuilder<'a, S>
where
S: individual_email_commit_count_state::State,
S::Email: individual_email_commit_count_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<CowStr<'a>>,
) -> IndividualEmailCommitCountBuilder<
'a,
individual_email_commit_count_state::SetEmail<S>,
> {
self._fields.1 = Option::Some(value.into());
IndividualEmailCommitCountBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IndividualEmailCommitCountBuilder<'a, S>
where
S: individual_email_commit_count_state::State,
S::Email: individual_email_commit_count_state::IsSet,
S::Count: individual_email_commit_count_state::IsSet,
{
pub fn build(self) -> IndividualEmailCommitCount<'a> {
IndividualEmailCommitCount {
count: self._fields.0.unwrap(),
email: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> IndividualEmailCommitCount<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLang<S> {}
impl<S: State> State for SetLang<S> {
type Lang = Set<members::lang>;
type Size = S::Size;
}
pub struct SetSize<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetSize<S> {}
impl<S: State> State for SetSize<S> {
type Lang = S::Lang;
type Size = Set<members::size>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct lang(());
pub struct size(());
}
}
pub struct IndividualLanguageSizeBuilder<'a, S: individual_language_size_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<i64>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> IndividualLanguageSize<'a> {
pub fn new() -> IndividualLanguageSizeBuilder<
'a,
individual_language_size_state::Empty,
> {
IndividualLanguageSizeBuilder::new()
}
}
impl<'a> IndividualLanguageSizeBuilder<'a, individual_language_size_state::Empty> {
pub fn new() -> Self {
IndividualLanguageSizeBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> IndividualLanguageSizeBuilder<'a, S>
where
S: individual_language_size_state::State,
S::Lang: individual_language_size_state::IsUnset,
{
pub fn lang(
mut self,
value: impl Into<CowStr<'a>>,
) -> IndividualLanguageSizeBuilder<'a, individual_language_size_state::SetLang<S>> {
self._fields.0 = Option::Some(value.into());
IndividualLanguageSizeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IndividualLanguageSizeBuilder<'a, S>
where
S: individual_language_size_state::State,
S::Size: individual_language_size_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> IndividualLanguageSizeBuilder<'a, individual_language_size_state::SetSize<S>> {
self._fields.1 = Option::Some(value.into());
IndividualLanguageSizeBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> IndividualLanguageSizeBuilder<'a, S>
where
S: individual_language_size_state::State,
S::Lang: individual_language_size_state::IsSet,
S::Size: individual_language_size_state::IsSet,
{
pub fn build(self) -> IndividualLanguageSize<'a> {
IndividualLanguageSize {
lang: self._fields.0.unwrap(),
size: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> IndividualLanguageSize<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type NewSha;
type CommitterDid;
type RepoDid;
type RepoName;
type Meta;
type Ref;
type OldSha;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type NewSha = Unset;
type CommitterDid = Unset;
type RepoDid = Unset;
type RepoName = Unset;
type Meta = Unset;
type Ref = Unset;
type OldSha = Unset;
}
pub struct SetNewSha<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetNewSha<S> {}
impl<S: State> State for SetNewSha<S> {
type NewSha = Set<members::new_sha>;
type CommitterDid = S::CommitterDid;
type RepoDid = S::RepoDid;
type RepoName = S::RepoName;
type Meta = S::Meta;
type Ref = S::Ref;
type OldSha = S::OldSha;
}
pub struct SetCommitterDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCommitterDid<S> {}
impl<S: State> State for SetCommitterDid<S> {
type NewSha = S::NewSha;
type CommitterDid = Set<members::committer_did>;
type RepoDid = S::RepoDid;
type RepoName = S::RepoName;
type Meta = S::Meta;
type Ref = S::Ref;
type OldSha = S::OldSha;
}
pub struct SetRepoDid<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRepoDid<S> {}
impl<S: State> State for SetRepoDid<S> {
type NewSha = S::NewSha;
type CommitterDid = S::CommitterDid;
type RepoDid = Set<members::repo_did>;
type RepoName = S::RepoName;
type Meta = S::Meta;
type Ref = S::Ref;
type OldSha = S::OldSha;
}
pub struct SetRepoName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRepoName<S> {}
impl<S: State> State for SetRepoName<S> {
type NewSha = S::NewSha;
type CommitterDid = S::CommitterDid;
type RepoDid = S::RepoDid;
type RepoName = Set<members::repo_name>;
type Meta = S::Meta;
type Ref = S::Ref;
type OldSha = S::OldSha;
}
pub struct SetMeta<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMeta<S> {}
impl<S: State> State for SetMeta<S> {
type NewSha = S::NewSha;
type CommitterDid = S::CommitterDid;
type RepoDid = S::RepoDid;
type RepoName = S::RepoName;
type Meta = Set<members::meta>;
type Ref = S::Ref;
type OldSha = S::OldSha;
}
pub struct SetRef<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetRef<S> {}
impl<S: State> State for SetRef<S> {
type NewSha = S::NewSha;
type CommitterDid = S::CommitterDid;
type RepoDid = S::RepoDid;
type RepoName = S::RepoName;
type Meta = S::Meta;
type Ref = Set<members::r#ref>;
type OldSha = S::OldSha;
}
pub struct SetOldSha<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetOldSha<S> {}
impl<S: State> State for SetOldSha<S> {
type NewSha = S::NewSha;
type CommitterDid = S::CommitterDid;
type RepoDid = S::RepoDid;
type RepoName = S::RepoName;
type Meta = S::Meta;
type Ref = S::Ref;
type OldSha = Set<members::old_sha>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct new_sha(());
pub struct committer_did(());
pub struct repo_did(());
pub struct repo_name(());
pub struct meta(());
pub struct r#ref(());
pub struct old_sha(());
}
}
pub struct RefUpdateBuilder<'a, S: ref_update_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<Did<'a>>,
Option<ref_update::Meta<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Did<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> RefUpdate<'a> {
pub fn new() -> RefUpdateBuilder<'a, ref_update_state::Empty> {
RefUpdateBuilder::new()
}
}
impl<'a> RefUpdateBuilder<'a, ref_update_state::Empty> {
pub fn new() -> Self {
RefUpdateBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::CommitterDid: ref_update_state::IsUnset,
{
pub fn committer_did(
mut self,
value: impl Into<Did<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetCommitterDid<S>> {
self._fields.0 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::Meta: ref_update_state::IsUnset,
{
pub fn meta(
mut self,
value: impl Into<ref_update::Meta<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetMeta<S>> {
self._fields.1 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::NewSha: ref_update_state::IsUnset,
{
pub fn new_sha(
mut self,
value: impl Into<CowStr<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetNewSha<S>> {
self._fields.2 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::OldSha: ref_update_state::IsUnset,
{
pub fn old_sha(
mut self,
value: impl Into<CowStr<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetOldSha<S>> {
self._fields.3 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::Ref: ref_update_state::IsUnset,
{
pub fn r#ref(
mut self,
value: impl Into<CowStr<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetRef<S>> {
self._fields.4 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::RepoDid: ref_update_state::IsUnset,
{
pub fn repo_did(
mut self,
value: impl Into<Did<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetRepoDid<S>> {
self._fields.5 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::RepoName: ref_update_state::IsUnset,
{
pub fn repo_name(
mut self,
value: impl Into<CowStr<'a>>,
) -> RefUpdateBuilder<'a, ref_update_state::SetRepoName<S>> {
self._fields.6 = Option::Some(value.into());
RefUpdateBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> RefUpdateBuilder<'a, S>
where
S: ref_update_state::State,
S::NewSha: ref_update_state::IsSet,
S::CommitterDid: ref_update_state::IsSet,
S::RepoDid: ref_update_state::IsSet,
S::RepoName: ref_update_state::IsSet,
S::Meta: ref_update_state::IsSet,
S::Ref: ref_update_state::IsSet,
S::OldSha: ref_update_state::IsSet,
{
pub fn build(self) -> RefUpdate<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> RefUpdate<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type IsDefaultRef;
type CommitCount;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type IsDefaultRef = Unset;
type CommitCount = Unset;
}
pub struct SetIsDefaultRef<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetIsDefaultRef<S> {}
impl<S: State> State for SetIsDefaultRef<S> {
type IsDefaultRef = Set<members::is_default_ref>;
type CommitCount = S::CommitCount;
}
pub struct SetCommitCount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCommitCount<S> {}
impl<S: State> State for SetCommitCount<S> {
type IsDefaultRef = S::IsDefaultRef;
type CommitCount = Set<members::commit_count>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct is_default_ref(());
pub struct commit_count(());
}
}
pub struct MetaBuilder<'a, S: meta_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<ref_update::CommitCountBreakdown<'a>>,
Option<bool>,
Option<ref_update::LangBreakdown<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Meta<'a> {
pub fn new() -> MetaBuilder<'a, meta_state::Empty> {
MetaBuilder::new()
}
}
impl<'a> MetaBuilder<'a, meta_state::Empty> {
pub fn new() -> Self {
MetaBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> MetaBuilder<'a, S>
where
S: meta_state::State,
S::CommitCount: meta_state::IsUnset,
{
pub fn commit_count(
mut self,
value: impl Into<ref_update::CommitCountBreakdown<'a>>,
) -> MetaBuilder<'a, meta_state::SetCommitCount<S>> {
self._fields.0 = Option::Some(value.into());
MetaBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> MetaBuilder<'a, S>
where
S: meta_state::State,
S::IsDefaultRef: meta_state::IsUnset,
{
pub fn is_default_ref(
mut self,
value: impl Into<bool>,
) -> MetaBuilder<'a, meta_state::SetIsDefaultRef<S>> {
self._fields.1 = Option::Some(value.into());
MetaBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: meta_state::State> MetaBuilder<'a, S> {
pub fn lang_breakdown(
mut self,
value: impl Into<Option<ref_update::LangBreakdown<'a>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_lang_breakdown(
mut self,
value: Option<ref_update::LangBreakdown<'a>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<'a, S> MetaBuilder<'a, S>
where
S: meta_state::State,
S::IsDefaultRef: meta_state::IsSet,
S::CommitCount: meta_state::IsSet,
{
pub fn build(self) -> Meta<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Meta<'a> {
Meta {
commit_count: self._fields.0.unwrap(),
is_default_ref: self._fields.1.unwrap(),
lang_breakdown: self._fields.2,
extra_data: Some(extra_data),
}
}
}