pub mod analyze_merge;
pub mod get_archive;
pub mod get_blob;
pub mod get_branch;
pub mod get_commit;
pub mod get_diff;
pub mod get_entity;
pub mod get_head;
pub mod get_tag;
pub mod get_tree;
pub mod list_branches;
pub mod list_commits;
pub mod list_languages;
pub mod list_tags;
#[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::Datetime;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::sh_tangled::git::temp;
#[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 Blob<S: BosStr = DefaultStr> {
pub last_commit: temp::Commit<S>,
pub mode: S,
pub name: S,
pub size: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub submodule: Option<temp::Submodule<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 Branch<S: BosStr = DefaultStr> {
pub commit: temp::Commit<S>,
pub 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",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Commit<S: BosStr = DefaultStr> {
pub author: temp::Signature<S>,
pub committer: temp::Signature<S>,
pub hash: temp::Hash<S>,
pub message: S,
pub tree: temp::Hash<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
pub type Hash<S = DefaultStr> = S;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Signature<S: BosStr = DefaultStr> {
pub email: S,
pub name: S,
pub when: 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 Submodule<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub branch: Option<S>,
pub name: S,
pub url: 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 Tag<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<S>,
pub name: S,
pub tagger: temp::Signature<S>,
pub target: Data<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for Blob<S> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.defs"
}
fn def_name() -> &'static str {
"blob"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Branch<S> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.defs"
}
fn def_name() -> &'static str {
"branch"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Commit<S> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.defs"
}
fn def_name() -> &'static str {
"commit"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Signature<S> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.defs"
}
fn def_name() -> &'static str {
"signature"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Submodule<S> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.defs"
}
fn def_name() -> &'static str {
"submodule"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Tag<S> {
fn nsid() -> &'static str {
"sh.tangled.git.temp.defs"
}
fn def_name() -> &'static str {
"tag"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_sh_tangled_git_temp_defs()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod blob_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 LastCommit;
type Mode;
type Size;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type LastCommit = Unset;
type Mode = Unset;
type Size = Unset;
type Name = Unset;
}
pub struct SetLastCommit<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLastCommit<St> {}
impl<St: State> State for SetLastCommit<St> {
type LastCommit = Set<members::last_commit>;
type Mode = St::Mode;
type Size = St::Size;
type Name = St::Name;
}
pub struct SetMode<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMode<St> {}
impl<St: State> State for SetMode<St> {
type LastCommit = St::LastCommit;
type Mode = Set<members::mode>;
type Size = St::Size;
type Name = St::Name;
}
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 LastCommit = St::LastCommit;
type Mode = St::Mode;
type Size = Set<members::size>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type LastCommit = St::LastCommit;
type Mode = St::Mode;
type Size = St::Size;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct last_commit(());
pub struct mode(());
pub struct size(());
pub struct name(());
}
}
pub struct BlobBuilder<S: BosStr, St: blob_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<temp::Commit<S>>,
Option<S>,
Option<S>,
Option<i64>,
Option<temp::Submodule<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Blob<S> {
pub fn new() -> BlobBuilder<S, blob_state::Empty> {
BlobBuilder::new()
}
}
impl<S: BosStr> BlobBuilder<S, blob_state::Empty> {
pub fn new() -> Self {
BlobBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlobBuilder<S, St>
where
St: blob_state::State,
St::LastCommit: blob_state::IsUnset,
{
pub fn last_commit(
mut self,
value: impl Into<temp::Commit<S>>,
) -> BlobBuilder<S, blob_state::SetLastCommit<St>> {
self._fields.0 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlobBuilder<S, St>
where
St: blob_state::State,
St::Mode: blob_state::IsUnset,
{
pub fn mode(mut self, value: impl Into<S>) -> BlobBuilder<S, blob_state::SetMode<St>> {
self._fields.1 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlobBuilder<S, St>
where
St: blob_state::State,
St::Name: blob_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> BlobBuilder<S, blob_state::SetName<St>> {
self._fields.2 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BlobBuilder<S, St>
where
St: blob_state::State,
St::Size: blob_state::IsUnset,
{
pub fn size(mut self, value: impl Into<i64>) -> BlobBuilder<S, blob_state::SetSize<St>> {
self._fields.3 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: blob_state::State> BlobBuilder<S, St> {
pub fn submodule(mut self, value: impl Into<Option<temp::Submodule<S>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_submodule(mut self, value: Option<temp::Submodule<S>>) -> Self {
self._fields.4 = value;
self
}
}
impl<S: BosStr, St> BlobBuilder<S, St>
where
St: blob_state::State,
St::LastCommit: blob_state::IsSet,
St::Mode: blob_state::IsSet,
St::Size: blob_state::IsSet,
St::Name: blob_state::IsSet,
{
pub fn build(self) -> Blob<S> {
Blob {
last_commit: self._fields.0.unwrap(),
mode: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
size: self._fields.3.unwrap(),
submodule: self._fields.4,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Blob<S> {
Blob {
last_commit: self._fields.0.unwrap(),
mode: self._fields.1.unwrap(),
name: self._fields.2.unwrap(),
size: self._fields.3.unwrap(),
submodule: self._fields.4,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_sh_tangled_git_temp_defs() -> 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.temp.defs"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("blob"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"blob metadata. This object doesn't include the blob content",
)),
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("mode"),
SmolStr::new_static("size"),
SmolStr::new_static("lastCommit"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("lastCommit"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#commit"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("mode"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("The file name")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("size"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("submodule"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#submodule"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("branch"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("commit"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("commit"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#commit"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("branch name")),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("commit"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("hash"),
SmolStr::new_static("author"),
SmolStr::new_static("committer"),
SmolStr::new_static("message"),
SmolStr::new_static("tree"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("author"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#signature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("committer"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#signature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hash"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#hash"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tree"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#hash"),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hash"),
LexUserType::String(LexString {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("signature"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("email"),
SmolStr::new_static("when"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("email"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Person email")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Person name")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("when"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Timestamp of the signature")),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("submodule"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("url"),
]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("branch"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Branch to track in the submodule",
)),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("name"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Submodule name")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("url"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("Submodule repository URL")),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tag"),
LexUserType::Object(LexObject {
required: Some(vec![
SmolStr::new_static("name"),
SmolStr::new_static("tagger"),
SmolStr::new_static("target"),
]),
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 {
description: Some(CowStr::new_static("tag name")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("tagger"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static("#signature"),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("target"),
LexObjectProperty::Unknown(LexUnknown {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod branch_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 Name;
type Commit;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Commit = Unset;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Name = Set<members::name>;
type Commit = St::Commit;
}
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 Name = St::Name;
type Commit = Set<members::commit>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct commit(());
}
}
pub struct BranchBuilder<S: BosStr, St: branch_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<temp::Commit<S>>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Branch<S> {
pub fn new() -> BranchBuilder<S, branch_state::Empty> {
BranchBuilder::new()
}
}
impl<S: BosStr> BranchBuilder<S, branch_state::Empty> {
pub fn new() -> Self {
BranchBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BranchBuilder<S, St>
where
St: branch_state::State,
St::Commit: branch_state::IsUnset,
{
pub fn commit(
mut self,
value: impl Into<temp::Commit<S>>,
) -> BranchBuilder<S, branch_state::SetCommit<St>> {
self._fields.0 = Option::Some(value.into());
BranchBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BranchBuilder<S, St>
where
St: branch_state::State,
St::Name: branch_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> BranchBuilder<S, branch_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
BranchBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BranchBuilder<S, St>
where
St: branch_state::State,
St::Name: branch_state::IsSet,
St::Commit: branch_state::IsSet,
{
pub fn build(self) -> Branch<S> {
Branch {
commit: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Branch<S> {
Branch {
commit: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
extra_data: Some(extra_data),
}
}
}
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 Message;
type Committer;
type Author;
type Hash;
type Tree;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Message = Unset;
type Committer = Unset;
type Author = Unset;
type Hash = Unset;
type Tree = Unset;
}
pub struct SetMessage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMessage<St> {}
impl<St: State> State for SetMessage<St> {
type Message = Set<members::message>;
type Committer = St::Committer;
type Author = St::Author;
type Hash = St::Hash;
type Tree = St::Tree;
}
pub struct SetCommitter<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetCommitter<St> {}
impl<St: State> State for SetCommitter<St> {
type Message = St::Message;
type Committer = Set<members::committer>;
type Author = St::Author;
type Hash = St::Hash;
type Tree = St::Tree;
}
pub struct SetAuthor<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetAuthor<St> {}
impl<St: State> State for SetAuthor<St> {
type Message = St::Message;
type Committer = St::Committer;
type Author = Set<members::author>;
type Hash = St::Hash;
type Tree = St::Tree;
}
pub struct SetHash<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetHash<St> {}
impl<St: State> State for SetHash<St> {
type Message = St::Message;
type Committer = St::Committer;
type Author = St::Author;
type Hash = Set<members::hash>;
type Tree = St::Tree;
}
pub struct SetTree<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTree<St> {}
impl<St: State> State for SetTree<St> {
type Message = St::Message;
type Committer = St::Committer;
type Author = St::Author;
type Hash = St::Hash;
type Tree = Set<members::tree>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct message(());
pub struct committer(());
pub struct author(());
pub struct hash(());
pub struct tree(());
}
}
pub struct CommitBuilder<S: BosStr, St: commit_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<temp::Signature<S>>,
Option<temp::Signature<S>>,
Option<temp::Hash<S>>,
Option<S>,
Option<temp::Hash<S>>,
),
_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),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> CommitBuilder<S, St>
where
St: commit_state::State,
St::Author: commit_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<temp::Signature<S>>,
) -> CommitBuilder<S, commit_state::SetAuthor<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::Committer: commit_state::IsUnset,
{
pub fn committer(
mut self,
value: impl Into<temp::Signature<S>>,
) -> CommitBuilder<S, commit_state::SetCommitter<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::Hash: commit_state::IsUnset,
{
pub fn hash(
mut self,
value: impl Into<temp::Hash<S>>,
) -> CommitBuilder<S, commit_state::SetHash<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::Message: commit_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<S>,
) -> CommitBuilder<S, commit_state::SetMessage<St>> {
self._fields.3 = 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::Tree: commit_state::IsUnset,
{
pub fn tree(
mut self,
value: impl Into<temp::Hash<S>>,
) -> CommitBuilder<S, commit_state::SetTree<St>> {
self._fields.4 = 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::Message: commit_state::IsSet,
St::Committer: commit_state::IsSet,
St::Author: commit_state::IsSet,
St::Hash: commit_state::IsSet,
St::Tree: commit_state::IsSet,
{
pub fn build(self) -> Commit<S> {
Commit {
author: self._fields.0.unwrap(),
committer: self._fields.1.unwrap(),
hash: self._fields.2.unwrap(),
message: self._fields.3.unwrap(),
tree: self._fields.4.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Commit<S> {
Commit {
author: self._fields.0.unwrap(),
committer: self._fields.1.unwrap(),
hash: self._fields.2.unwrap(),
message: self._fields.3.unwrap(),
tree: self._fields.4.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod signature_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 When;
type Email;
type Name;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type When = Unset;
type Email = Unset;
type Name = Unset;
}
pub struct SetWhen<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetWhen<St> {}
impl<St: State> State for SetWhen<St> {
type When = Set<members::when>;
type Email = St::Email;
type Name = St::Name;
}
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 When = St::When;
type Email = Set<members::email>;
type Name = St::Name;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type When = St::When;
type Email = St::Email;
type Name = Set<members::name>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct when(());
pub struct email(());
pub struct name(());
}
}
pub struct SignatureBuilder<S: BosStr, St: signature_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<S>, Option<S>, Option<Datetime>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Signature<S> {
pub fn new() -> SignatureBuilder<S, signature_state::Empty> {
SignatureBuilder::new()
}
}
impl<S: BosStr> SignatureBuilder<S, signature_state::Empty> {
pub fn new() -> Self {
SignatureBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Email: signature_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<S>,
) -> SignatureBuilder<S, signature_state::SetEmail<St>> {
self._fields.0 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::Name: signature_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<S>,
) -> SignatureBuilder<S, signature_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::When: signature_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> SignatureBuilder<S, signature_state::SetWhen<St>> {
self._fields.2 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> SignatureBuilder<S, St>
where
St: signature_state::State,
St::When: signature_state::IsSet,
St::Email: signature_state::IsSet,
St::Name: signature_state::IsSet,
{
pub fn build(self) -> Signature<S> {
Signature {
email: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
when: self._fields.2.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Signature<S> {
Signature {
email: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
when: self._fields.2.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod tag_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 Name;
type Target;
type Tagger;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Target = Unset;
type Tagger = Unset;
}
pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetName<St> {}
impl<St: State> State for SetName<St> {
type Name = Set<members::name>;
type Target = St::Target;
type Tagger = St::Tagger;
}
pub struct SetTarget<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTarget<St> {}
impl<St: State> State for SetTarget<St> {
type Name = St::Name;
type Target = Set<members::target>;
type Tagger = St::Tagger;
}
pub struct SetTagger<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTagger<St> {}
impl<St: State> State for SetTagger<St> {
type Name = St::Name;
type Target = St::Target;
type Tagger = Set<members::tagger>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct target(());
pub struct tagger(());
}
}
pub struct TagBuilder<S: BosStr, St: tag_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<S>,
Option<temp::Signature<S>>,
Option<Data<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Tag<S> {
pub fn new() -> TagBuilder<S, tag_state::Empty> {
TagBuilder::new()
}
}
impl<S: BosStr> TagBuilder<S, tag_state::Empty> {
pub fn new() -> Self {
TagBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: tag_state::State> TagBuilder<S, St> {
pub fn message(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_message(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> TagBuilder<S, St>
where
St: tag_state::State,
St::Name: tag_state::IsUnset,
{
pub fn name(mut self, value: impl Into<S>) -> TagBuilder<S, tag_state::SetName<St>> {
self._fields.1 = Option::Some(value.into());
TagBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TagBuilder<S, St>
where
St: tag_state::State,
St::Tagger: tag_state::IsUnset,
{
pub fn tagger(
mut self,
value: impl Into<temp::Signature<S>>,
) -> TagBuilder<S, tag_state::SetTagger<St>> {
self._fields.2 = Option::Some(value.into());
TagBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TagBuilder<S, St>
where
St: tag_state::State,
St::Target: tag_state::IsUnset,
{
pub fn target(mut self, value: impl Into<Data<S>>) -> TagBuilder<S, tag_state::SetTarget<St>> {
self._fields.3 = Option::Some(value.into());
TagBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> TagBuilder<S, St>
where
St: tag_state::State,
St::Name: tag_state::IsSet,
St::Target: tag_state::IsSet,
St::Tagger: tag_state::IsSet,
{
pub fn build(self) -> Tag<S> {
Tag {
message: self._fields.0,
name: self._fields.1.unwrap(),
tagger: self._fields.2.unwrap(),
target: self._fields.3.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Tag<S> {
Tag {
message: self._fields.0,
name: self._fields.1.unwrap(),
tagger: self._fields.2.unwrap(),
target: self._fields.3.unwrap(),
extra_data: Some(extra_data),
}
}
}