// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.tangled.git.temp.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

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;
/// blob metadata. This object doesn't include the blob content

#[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>,
    ///The file name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///File size in bytes
    pub size: i64,
    ///Submodule information if path is a submodule
    #[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> {
    ///hydrated commit object
    #[serde(borrow)]
    pub commit: temp::Commit<'a>,
    ///branch name
    #[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> {
    ///Person email
    #[serde(borrow)]
    pub email: CowStr<'a>,
    ///Person name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Timestamp of the signature
    pub when: Datetime,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Submodule<'a> {
    ///Branch to track in the submodule
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub branch: Option<CowStr<'a>>,
    ///Submodule name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Submodule repository URL
    #[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>>,
    ///tag name
    #[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 {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Name;
        type LastCommit;
        type Size;
        type Mode;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Name = Unset;
        type LastCommit = Unset;
        type Size = Unset;
        type Mode = Unset;
    }
    ///State transition - sets the `name` field to Set
    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;
    }
    ///State transition - sets the `last_commit` field to Set
    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;
    }
    ///State transition - sets the `size` field to Set
    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;
    }
    ///State transition - sets the `mode` field to Set
    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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `last_commit` field
        pub struct last_commit(());
        ///Marker type for the `size` field
        pub struct size(());
        ///Marker type for the `mode` field
        pub struct mode(());
    }
}

/// Builder for constructing an instance of this type
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> {
    /// Create a new builder for this type
    pub fn new() -> BlobBuilder<'a, blob_state::Empty> {
        BlobBuilder::new()
    }
}

impl<'a> BlobBuilder<'a, blob_state::Empty> {
    /// Create a new builder with all fields unset
    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,
{
    /// Set the `lastCommit` field (required)
    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,
{
    /// Set the `mode` field (required)
    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,
{
    /// Set the `name` field (required)
    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,
{
    /// Set the `size` field (required)
    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> {
    /// Set the `submodule` field (optional)
    pub fn submodule(mut self, value: impl Into<Option<temp::Submodule<'a>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `submodule` field to an Option value (optional)
    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,
{
    /// Build the final struct
    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(),
        }
    }
    /// Build the final struct with custom extra_data
    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 {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Name;
        type Commit;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Name = Unset;
        type Commit = Unset;
    }
    ///State transition - sets the `name` field to Set
    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;
    }
    ///State transition - sets the `commit` field to Set
    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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `commit` field
        pub struct commit(());
    }
}

/// Builder for constructing an instance of this type
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> {
    /// Create a new builder for this type
    pub fn new() -> BranchBuilder<'a, branch_state::Empty> {
        BranchBuilder::new()
    }
}

impl<'a> BranchBuilder<'a, branch_state::Empty> {
    /// Create a new builder with all fields unset
    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,
{
    /// Set the `commit` field (required)
    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,
{
    /// Set the `name` field (required)
    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,
{
    /// Build the final struct
    pub fn build(self) -> Branch<'a> {
        Branch {
            commit: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    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 {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Hash;
        type Message;
        type Tree;
        type Author;
        type Committer;
    }
    /// Empty state - all required fields are unset
    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;
    }
    ///State transition - sets the `hash` field to Set
    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;
    }
    ///State transition - sets the `message` field to Set
    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;
    }
    ///State transition - sets the `tree` field to Set
    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;
    }
    ///State transition - sets the `author` field to Set
    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;
    }
    ///State transition - sets the `committer` field to Set
    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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `hash` field
        pub struct hash(());
        ///Marker type for the `message` field
        pub struct message(());
        ///Marker type for the `tree` field
        pub struct tree(());
        ///Marker type for the `author` field
        pub struct author(());
        ///Marker type for the `committer` field
        pub struct committer(());
    }
}

/// Builder for constructing an instance of this type
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> {
    /// Create a new builder for this type
    pub fn new() -> CommitBuilder<'a, commit_state::Empty> {
        CommitBuilder::new()
    }
}

impl<'a> CommitBuilder<'a, commit_state::Empty> {
    /// Create a new builder with all fields unset
    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,
{
    /// Set the `author` field (required)
    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,
{
    /// Set the `committer` field (required)
    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,
{
    /// Set the `hash` field (required)
    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,
{
    /// Set the `message` field (required)
    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,
{
    /// Set the `tree` field (required)
    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,
{
    /// Build the final struct
    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(),
        }
    }
    /// Build the final struct with custom extra_data
    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 {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Name;
        type Email;
        type When;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Name = Unset;
        type Email = Unset;
        type When = Unset;
    }
    ///State transition - sets the `name` field to Set
    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;
    }
    ///State transition - sets the `email` field to Set
    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;
    }
    ///State transition - sets the `when` field to Set
    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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `email` field
        pub struct email(());
        ///Marker type for the `when` field
        pub struct when(());
    }
}

/// Builder for constructing an instance of this type
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> {
    /// Create a new builder for this type
    pub fn new() -> SignatureBuilder<'a, signature_state::Empty> {
        SignatureBuilder::new()
    }
}

impl<'a> SignatureBuilder<'a, signature_state::Empty> {
    /// Create a new builder with all fields unset
    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,
{
    /// Set the `email` field (required)
    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,
{
    /// Set the `name` field (required)
    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,
{
    /// Set the `when` field (required)
    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,
{
    /// Build the final struct
    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(),
        }
    }
    /// Build the final struct with custom extra_data
    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 {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type Name;
        type Target;
        type Tagger;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Name = Unset;
        type Target = Unset;
        type Tagger = Unset;
    }
    ///State transition - sets the `name` field to Set
    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;
    }
    ///State transition - sets the `target` field to Set
    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;
    }
    ///State transition - sets the `tagger` field to Set
    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>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `target` field
        pub struct target(());
        ///Marker type for the `tagger` field
        pub struct tagger(());
    }
}

/// Builder for constructing an instance of this type
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> {
    /// Create a new builder for this type
    pub fn new() -> TagBuilder<'a, tag_state::Empty> {
        TagBuilder::new()
    }
}

impl<'a> TagBuilder<'a, tag_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        TagBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: tag_state::State> TagBuilder<'a, S> {
    /// Set the `message` field (optional)
    pub fn message(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `message` field to an Option value (optional)
    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,
{
    /// Set the `name` field (required)
    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,
{
    /// Set the `tagger` field (required)
    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,
{
    /// Set the `target` field (required)
    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,
{
    /// Build the final struct
    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(),
        }
    }
    /// Build the final struct with custom extra_data
    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),
        }
    }
}