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::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::Datetime;
use jacquard_common::types::value::Data;
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::temp;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Blob<'a> {
#[serde(borrow)]
pub last_commit: temp::Commit<'a>,
#[serde(borrow)]
pub mode: CowStr<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
pub size: i64,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub submodule: Option<temp::Submodule<'a>>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Branch<'a> {
#[serde(borrow)]
pub commit: temp::Commit<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Commit<'a> {
#[serde(borrow)]
pub author: temp::Signature<'a>,
#[serde(borrow)]
pub committer: temp::Signature<'a>,
#[serde(borrow)]
pub hash: temp::Hash<'a>,
#[serde(borrow)]
pub message: CowStr<'a>,
#[serde(borrow)]
pub tree: temp::Hash<'a>,
}
pub type Hash<'a> = CowStr<'a>;
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Signature<'a> {
#[serde(borrow)]
pub email: CowStr<'a>,
#[serde(borrow)]
pub name: CowStr<'a>,
pub when: Datetime,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Submodule<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub branch: Option<CowStr<'a>>,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(borrow)]
pub url: CowStr<'a>,
}
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Tag<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub message: Option<CowStr<'a>>,
#[serde(borrow)]
pub name: CowStr<'a>,
#[serde(borrow)]
pub tagger: temp::Signature<'a>,
#[serde(borrow)]
pub target: Data<'a>,
}
impl<'a> LexiconSchema for Blob<'a> {
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<'a> LexiconSchema for Branch<'a> {
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<'a> LexiconSchema for Commit<'a> {
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<'a> LexiconSchema for Signature<'a> {
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<'a> LexiconSchema for Submodule<'a> {
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<'a> LexiconSchema for Tag<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type LastCommit;
type Size;
type Mode;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type LastCommit = Unset;
type Size = Unset;
type Mode = Unset;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type LastCommit = S::LastCommit;
type Size = S::Size;
type Mode = S::Mode;
}
pub struct SetLastCommit<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetLastCommit<S> {}
impl<S: State> State for SetLastCommit<S> {
type Name = S::Name;
type LastCommit = Set<members::last_commit>;
type Size = S::Size;
type Mode = S::Mode;
}
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 Name = S::Name;
type LastCommit = S::LastCommit;
type Size = Set<members::size>;
type Mode = S::Mode;
}
pub struct SetMode<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMode<S> {}
impl<S: State> State for SetMode<S> {
type Name = S::Name;
type LastCommit = S::LastCommit;
type Size = S::Size;
type Mode = Set<members::mode>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct last_commit(());
pub struct size(());
pub struct mode(());
}
}
pub struct BlobBuilder<'a, S: blob_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<temp::Commit<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<i64>,
Option<temp::Submodule<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Blob<'a> {
pub fn new() -> BlobBuilder<'a, blob_state::Empty> {
BlobBuilder::new()
}
}
impl<'a> BlobBuilder<'a, blob_state::Empty> {
pub fn new() -> Self {
BlobBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlobBuilder<'a, S>
where
S: blob_state::State,
S::LastCommit: blob_state::IsUnset,
{
pub fn last_commit(
mut self,
value: impl Into<temp::Commit<'a>>,
) -> BlobBuilder<'a, blob_state::SetLastCommit<S>> {
self._fields.0 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlobBuilder<'a, S>
where
S: blob_state::State,
S::Mode: blob_state::IsUnset,
{
pub fn mode(
mut self,
value: impl Into<CowStr<'a>>,
) -> BlobBuilder<'a, blob_state::SetMode<S>> {
self._fields.1 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlobBuilder<'a, S>
where
S: blob_state::State,
S::Name: blob_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> BlobBuilder<'a, blob_state::SetName<S>> {
self._fields.2 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BlobBuilder<'a, S>
where
S: blob_state::State,
S::Size: blob_state::IsUnset,
{
pub fn size(
mut self,
value: impl Into<i64>,
) -> BlobBuilder<'a, blob_state::SetSize<S>> {
self._fields.3 = Option::Some(value.into());
BlobBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: blob_state::State> BlobBuilder<'a, S> {
pub fn submodule(mut self, value: impl Into<Option<temp::Submodule<'a>>>) -> Self {
self._fields.4 = value.into();
self
}
pub fn maybe_submodule(mut self, value: Option<temp::Submodule<'a>>) -> Self {
self._fields.4 = value;
self
}
}
impl<'a, S> BlobBuilder<'a, S>
where
S: blob_state::State,
S::Name: blob_state::IsSet,
S::LastCommit: blob_state::IsSet,
S::Size: blob_state::IsSet,
S::Mode: blob_state::IsSet,
{
pub fn build(self) -> Blob<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Blob<'a> {
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> {
#[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.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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type Commit = S::Commit;
}
pub struct SetCommit<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCommit<S> {}
impl<S: State> State for SetCommit<S> {
type Name = S::Name;
type Commit = Set<members::commit>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct commit(());
}
}
pub struct BranchBuilder<'a, S: branch_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<temp::Commit<'a>>, Option<CowStr<'a>>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Branch<'a> {
pub fn new() -> BranchBuilder<'a, branch_state::Empty> {
BranchBuilder::new()
}
}
impl<'a> BranchBuilder<'a, branch_state::Empty> {
pub fn new() -> Self {
BranchBuilder {
_state: PhantomData,
_fields: (None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> BranchBuilder<'a, S>
where
S: branch_state::State,
S::Commit: branch_state::IsUnset,
{
pub fn commit(
mut self,
value: impl Into<temp::Commit<'a>>,
) -> BranchBuilder<'a, branch_state::SetCommit<S>> {
self._fields.0 = Option::Some(value.into());
BranchBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BranchBuilder<'a, S>
where
S: branch_state::State,
S::Name: branch_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> BranchBuilder<'a, branch_state::SetName<S>> {
self._fields.1 = Option::Some(value.into());
BranchBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> BranchBuilder<'a, S>
where
S: branch_state::State,
S::Name: branch_state::IsSet,
S::Commit: branch_state::IsSet,
{
pub fn build(self) -> Branch<'a> {
Branch {
commit: self._fields.0.unwrap(),
name: self._fields.1.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Branch<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Hash;
type Message;
type Tree;
type Author;
type Committer;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Hash = Unset;
type Message = Unset;
type Tree = Unset;
type Author = Unset;
type Committer = Unset;
}
pub struct SetHash<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetHash<S> {}
impl<S: State> State for SetHash<S> {
type Hash = Set<members::hash>;
type Message = S::Message;
type Tree = S::Tree;
type Author = S::Author;
type Committer = S::Committer;
}
pub struct SetMessage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMessage<S> {}
impl<S: State> State for SetMessage<S> {
type Hash = S::Hash;
type Message = Set<members::message>;
type Tree = S::Tree;
type Author = S::Author;
type Committer = S::Committer;
}
pub struct SetTree<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTree<S> {}
impl<S: State> State for SetTree<S> {
type Hash = S::Hash;
type Message = S::Message;
type Tree = Set<members::tree>;
type Author = S::Author;
type Committer = S::Committer;
}
pub struct SetAuthor<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetAuthor<S> {}
impl<S: State> State for SetAuthor<S> {
type Hash = S::Hash;
type Message = S::Message;
type Tree = S::Tree;
type Author = Set<members::author>;
type Committer = S::Committer;
}
pub struct SetCommitter<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetCommitter<S> {}
impl<S: State> State for SetCommitter<S> {
type Hash = S::Hash;
type Message = S::Message;
type Tree = S::Tree;
type Author = S::Author;
type Committer = Set<members::committer>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct hash(());
pub struct message(());
pub struct tree(());
pub struct author(());
pub struct committer(());
}
}
pub struct CommitBuilder<'a, S: commit_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<temp::Signature<'a>>,
Option<temp::Signature<'a>>,
Option<temp::Hash<'a>>,
Option<CowStr<'a>>,
Option<temp::Hash<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Commit<'a> {
pub fn new() -> CommitBuilder<'a, commit_state::Empty> {
CommitBuilder::new()
}
}
impl<'a> CommitBuilder<'a, commit_state::Empty> {
pub fn new() -> Self {
CommitBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommitBuilder<'a, S>
where
S: commit_state::State,
S::Author: commit_state::IsUnset,
{
pub fn author(
mut self,
value: impl Into<temp::Signature<'a>>,
) -> CommitBuilder<'a, commit_state::SetAuthor<S>> {
self._fields.0 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommitBuilder<'a, S>
where
S: commit_state::State,
S::Committer: commit_state::IsUnset,
{
pub fn committer(
mut self,
value: impl Into<temp::Signature<'a>>,
) -> CommitBuilder<'a, commit_state::SetCommitter<S>> {
self._fields.1 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommitBuilder<'a, S>
where
S: commit_state::State,
S::Hash: commit_state::IsUnset,
{
pub fn hash(
mut self,
value: impl Into<temp::Hash<'a>>,
) -> CommitBuilder<'a, commit_state::SetHash<S>> {
self._fields.2 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommitBuilder<'a, S>
where
S: commit_state::State,
S::Message: commit_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<CowStr<'a>>,
) -> CommitBuilder<'a, commit_state::SetMessage<S>> {
self._fields.3 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommitBuilder<'a, S>
where
S: commit_state::State,
S::Tree: commit_state::IsUnset,
{
pub fn tree(
mut self,
value: impl Into<temp::Hash<'a>>,
) -> CommitBuilder<'a, commit_state::SetTree<S>> {
self._fields.4 = Option::Some(value.into());
CommitBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> CommitBuilder<'a, S>
where
S: commit_state::State,
S::Hash: commit_state::IsSet,
S::Message: commit_state::IsSet,
S::Tree: commit_state::IsSet,
S::Author: commit_state::IsSet,
S::Committer: commit_state::IsSet,
{
pub fn build(self) -> Commit<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Commit<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Name;
type Email;
type When;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Name = Unset;
type Email = Unset;
type When = Unset;
}
pub struct SetName<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type Email = S::Email;
type When = S::When;
}
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 Name = S::Name;
type Email = Set<members::email>;
type When = S::When;
}
pub struct SetWhen<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetWhen<S> {}
impl<S: State> State for SetWhen<S> {
type Name = S::Name;
type Email = S::Email;
type When = Set<members::when>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct name(());
pub struct email(());
pub struct when(());
}
}
pub struct SignatureBuilder<'a, S: signature_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (Option<CowStr<'a>>, Option<CowStr<'a>>, Option<Datetime>),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Signature<'a> {
pub fn new() -> SignatureBuilder<'a, signature_state::Empty> {
SignatureBuilder::new()
}
}
impl<'a> SignatureBuilder<'a, signature_state::Empty> {
pub fn new() -> Self {
SignatureBuilder {
_state: PhantomData,
_fields: (None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Email: signature_state::IsUnset,
{
pub fn email(
mut self,
value: impl Into<CowStr<'a>>,
) -> SignatureBuilder<'a, signature_state::SetEmail<S>> {
self._fields.0 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Name: signature_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> SignatureBuilder<'a, signature_state::SetName<S>> {
self._fields.1 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::When: signature_state::IsUnset,
{
pub fn when(
mut self,
value: impl Into<Datetime>,
) -> SignatureBuilder<'a, signature_state::SetWhen<S>> {
self._fields.2 = Option::Some(value.into());
SignatureBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> SignatureBuilder<'a, S>
where
S: signature_state::State,
S::Name: signature_state::IsSet,
S::Email: signature_state::IsSet,
S::When: signature_state::IsSet,
{
pub fn build(self) -> Signature<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Signature<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[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<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetName<S> {}
impl<S: State> State for SetName<S> {
type Name = Set<members::name>;
type Target = S::Target;
type Tagger = S::Tagger;
}
pub struct SetTarget<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTarget<S> {}
impl<S: State> State for SetTarget<S> {
type Name = S::Name;
type Target = Set<members::target>;
type Tagger = S::Tagger;
}
pub struct SetTagger<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTagger<S> {}
impl<S: State> State for SetTagger<S> {
type Name = S::Name;
type Target = S::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<'a, S: tag_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<temp::Signature<'a>>,
Option<Data<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Tag<'a> {
pub fn new() -> TagBuilder<'a, tag_state::Empty> {
TagBuilder::new()
}
}
impl<'a> TagBuilder<'a, tag_state::Empty> {
pub fn new() -> Self {
TagBuilder {
_state: PhantomData,
_fields: (None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: tag_state::State> TagBuilder<'a, S> {
pub fn message(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_message(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S> TagBuilder<'a, S>
where
S: tag_state::State,
S::Name: tag_state::IsUnset,
{
pub fn name(
mut self,
value: impl Into<CowStr<'a>>,
) -> TagBuilder<'a, tag_state::SetName<S>> {
self._fields.1 = Option::Some(value.into());
TagBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TagBuilder<'a, S>
where
S: tag_state::State,
S::Tagger: tag_state::IsUnset,
{
pub fn tagger(
mut self,
value: impl Into<temp::Signature<'a>>,
) -> TagBuilder<'a, tag_state::SetTagger<S>> {
self._fields.2 = Option::Some(value.into());
TagBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TagBuilder<'a, S>
where
S: tag_state::State,
S::Target: tag_state::IsUnset,
{
pub fn target(
mut self,
value: impl Into<Data<'a>>,
) -> TagBuilder<'a, tag_state::SetTarget<S>> {
self._fields.3 = Option::Some(value.into());
TagBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S> TagBuilder<'a, S>
where
S: tag_state::State,
S::Name: tag_state::IsSet,
S::Target: tag_state::IsSet,
S::Tagger: tag_state::IsSet,
{
pub fn build(self) -> Tag<'a> {
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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
) -> Tag<'a> {
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),
}
}
}