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

pub mod comment;
pub mod status;


#[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::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{Did, AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::sh_tangled::repo::pull;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Pull<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub body: Option<CowStr<'a>>,
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub mentions: Option<Vec<Did<'a>>>,
    ///(deprecated) use patchBlob instead
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub patch: Option<CowStr<'a>>,
    ///patch content
    #[serde(borrow)]
    pub patch_blob: BlobRef<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub references: Option<Vec<AtUri<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub source: Option<pull::Source<'a>>,
    #[serde(borrow)]
    pub target: pull::Target<'a>,
    #[serde(borrow)]
    pub title: CowStr<'a>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct PullGetRecordOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub value: Pull<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Source<'a> {
    #[serde(borrow)]
    pub branch: CowStr<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub repo: Option<AtUri<'a>>,
    #[serde(borrow)]
    pub sha: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Target<'a> {
    #[serde(borrow)]
    pub branch: CowStr<'a>,
    #[serde(borrow)]
    pub repo: AtUri<'a>,
}

impl<'a> Pull<'a> {
    pub fn uri(
        uri: impl Into<CowStr<'a>>,
    ) -> Result<RecordUri<'a, PullRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct PullRecord;
impl XrpcResp for PullRecord {
    const NSID: &'static str = "sh.tangled.repo.pull";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = PullGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

impl From<PullGetRecordOutput<'_>> for Pull<'_> {
    fn from(output: PullGetRecordOutput<'_>) -> Self {
        use jacquard_common::IntoStatic;
        output.value.into_static()
    }
}

impl Collection for Pull<'_> {
    const NSID: &'static str = "sh.tangled.repo.pull";
    type Record = PullRecord;
}

impl Collection for PullRecord {
    const NSID: &'static str = "sh.tangled.repo.pull";
    type Record = PullRecord;
}

impl<'a> LexiconSchema for Pull<'a> {
    fn nsid() -> &'static str {
        "sh.tangled.repo.pull"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_repo_pull()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.patch_blob;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["text/x-patch"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("patch_blob"),
                        accepted: vec!["text/x-patch".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Source<'a> {
    fn nsid() -> &'static str {
        "sh.tangled.repo.pull"
    }
    fn def_name() -> &'static str {
        "source"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_repo_pull()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 40usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("sha"),
                    max: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.sha;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) < 40usize {
                return Err(ConstraintError::MinLength {
                    path: ValidationPath::from_field("sha"),
                    min: 40usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Target<'a> {
    fn nsid() -> &'static str {
        "sh.tangled.repo.pull"
    }
    fn def_name() -> &'static str {
        "target"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_repo_pull()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod pull_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 Title;
        type PatchBlob;
        type Target;
        type CreatedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Title = Unset;
        type PatchBlob = Unset;
        type Target = Unset;
        type CreatedAt = Unset;
    }
    ///State transition - sets the `title` field to Set
    pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTitle<S> {}
    impl<S: State> State for SetTitle<S> {
        type Title = Set<members::title>;
        type PatchBlob = S::PatchBlob;
        type Target = S::Target;
        type CreatedAt = S::CreatedAt;
    }
    ///State transition - sets the `patch_blob` field to Set
    pub struct SetPatchBlob<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetPatchBlob<S> {}
    impl<S: State> State for SetPatchBlob<S> {
        type Title = S::Title;
        type PatchBlob = Set<members::patch_blob>;
        type Target = S::Target;
        type CreatedAt = S::CreatedAt;
    }
    ///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 Title = S::Title;
        type PatchBlob = S::PatchBlob;
        type Target = Set<members::target>;
        type CreatedAt = S::CreatedAt;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type Title = S::Title;
        type PatchBlob = S::PatchBlob;
        type Target = S::Target;
        type CreatedAt = Set<members::created_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `title` field
        pub struct title(());
        ///Marker type for the `patch_blob` field
        pub struct patch_blob(());
        ///Marker type for the `target` field
        pub struct target(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
    }
}

/// Builder for constructing an instance of this type
pub struct PullBuilder<'a, S: pull_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<Vec<Did<'a>>>,
        Option<CowStr<'a>>,
        Option<BlobRef<'a>>,
        Option<Vec<AtUri<'a>>>,
        Option<pull::Source<'a>>,
        Option<pull::Target<'a>>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Pull<'a> {
    /// Create a new builder for this type
    pub fn new() -> PullBuilder<'a, pull_state::Empty> {
        PullBuilder::new()
    }
}

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

impl<'a, S: pull_state::State> PullBuilder<'a, S> {
    /// Set the `body` field (optional)
    pub fn body(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `body` field to an Option value (optional)
    pub fn maybe_body(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> PullBuilder<'a, S>
where
    S: pull_state::State,
    S::CreatedAt: pull_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> PullBuilder<'a, pull_state::SetCreatedAt<S>> {
        self._fields.1 = Option::Some(value.into());
        PullBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: pull_state::State> PullBuilder<'a, S> {
    /// Set the `mentions` field (optional)
    pub fn mentions(mut self, value: impl Into<Option<Vec<Did<'a>>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `mentions` field to an Option value (optional)
    pub fn maybe_mentions(mut self, value: Option<Vec<Did<'a>>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: pull_state::State> PullBuilder<'a, S> {
    /// Set the `patch` field (optional)
    pub fn patch(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `patch` field to an Option value (optional)
    pub fn maybe_patch(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> PullBuilder<'a, S>
where
    S: pull_state::State,
    S::PatchBlob: pull_state::IsUnset,
{
    /// Set the `patchBlob` field (required)
    pub fn patch_blob(
        mut self,
        value: impl Into<BlobRef<'a>>,
    ) -> PullBuilder<'a, pull_state::SetPatchBlob<S>> {
        self._fields.4 = Option::Some(value.into());
        PullBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: pull_state::State> PullBuilder<'a, S> {
    /// Set the `references` field (optional)
    pub fn references(mut self, value: impl Into<Option<Vec<AtUri<'a>>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `references` field to an Option value (optional)
    pub fn maybe_references(mut self, value: Option<Vec<AtUri<'a>>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: pull_state::State> PullBuilder<'a, S> {
    /// Set the `source` field (optional)
    pub fn source(mut self, value: impl Into<Option<pull::Source<'a>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `source` field to an Option value (optional)
    pub fn maybe_source(mut self, value: Option<pull::Source<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> PullBuilder<'a, S>
where
    S: pull_state::State,
    S::Target: pull_state::IsUnset,
{
    /// Set the `target` field (required)
    pub fn target(
        mut self,
        value: impl Into<pull::Target<'a>>,
    ) -> PullBuilder<'a, pull_state::SetTarget<S>> {
        self._fields.7 = Option::Some(value.into());
        PullBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> PullBuilder<'a, S>
where
    S: pull_state::State,
    S::Title: pull_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> PullBuilder<'a, pull_state::SetTitle<S>> {
        self._fields.8 = Option::Some(value.into());
        PullBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> PullBuilder<'a, S>
where
    S: pull_state::State,
    S::Title: pull_state::IsSet,
    S::PatchBlob: pull_state::IsSet,
    S::Target: pull_state::IsSet,
    S::CreatedAt: pull_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Pull<'a> {
        Pull {
            body: self._fields.0,
            created_at: self._fields.1.unwrap(),
            mentions: self._fields.2,
            patch: self._fields.3,
            patch_blob: self._fields.4.unwrap(),
            references: self._fields.5,
            source: self._fields.6,
            target: self._fields.7.unwrap(),
            title: self._fields.8.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,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Pull<'a> {
        Pull {
            body: self._fields.0,
            created_at: self._fields.1.unwrap(),
            mentions: self._fields.2,
            patch: self._fields.3,
            patch_blob: self._fields.4.unwrap(),
            references: self._fields.5,
            source: self._fields.6,
            target: self._fields.7.unwrap(),
            title: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_tangled_repo_pull() -> 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.repo.pull"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("target"), SmolStr::new_static("title"),
                                SmolStr::new_static("patchBlob"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("body"),
                                LexObjectProperty::String(LexString {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("mentions"),
                                LexObjectProperty::Array(LexArray {
                                    items: LexArrayItem::String(LexString {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("patch"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("(deprecated) use patchBlob instead"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("patchBlob"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("references"),
                                LexObjectProperty::Array(LexArray {
                                    items: LexArrayItem::String(LexString {
                                        format: Some(LexStringFormat::AtUri),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("source"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#source"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("target"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#target"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("title"),
                                LexObjectProperty::String(LexString {
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("source"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("branch"), SmolStr::new_static("sha")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("branch"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("repo"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sha"),
                            LexObjectProperty::String(LexString {
                                min_length: Some(40usize),
                                max_length: Some(40usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("target"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("repo"), SmolStr::new_static("branch")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("branch"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("repo"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod target_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 Repo;
        type Branch;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Repo = Unset;
        type Branch = Unset;
    }
    ///State transition - sets the `repo` field to Set
    pub struct SetRepo<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRepo<S> {}
    impl<S: State> State for SetRepo<S> {
        type Repo = Set<members::repo>;
        type Branch = S::Branch;
    }
    ///State transition - sets the `branch` field to Set
    pub struct SetBranch<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBranch<S> {}
    impl<S: State> State for SetBranch<S> {
        type Repo = S::Repo;
        type Branch = Set<members::branch>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `repo` field
        pub struct repo(());
        ///Marker type for the `branch` field
        pub struct branch(());
    }
}

/// Builder for constructing an instance of this type
pub struct TargetBuilder<'a, S: target_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<AtUri<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Target<'a> {
    /// Create a new builder for this type
    pub fn new() -> TargetBuilder<'a, target_state::Empty> {
        TargetBuilder::new()
    }
}

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

impl<'a, S> TargetBuilder<'a, S>
where
    S: target_state::State,
    S::Branch: target_state::IsUnset,
{
    /// Set the `branch` field (required)
    pub fn branch(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> TargetBuilder<'a, target_state::SetBranch<S>> {
        self._fields.0 = Option::Some(value.into());
        TargetBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TargetBuilder<'a, S>
where
    S: target_state::State,
    S::Repo: target_state::IsUnset,
{
    /// Set the `repo` field (required)
    pub fn repo(
        mut self,
        value: impl Into<AtUri<'a>>,
    ) -> TargetBuilder<'a, target_state::SetRepo<S>> {
        self._fields.1 = Option::Some(value.into());
        TargetBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> TargetBuilder<'a, S>
where
    S: target_state::State,
    S::Repo: target_state::IsSet,
    S::Branch: target_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Target<'a> {
        Target {
            branch: self._fields.0.unwrap(),
            repo: 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,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Target<'a> {
        Target {
            branch: self._fields.0.unwrap(),
            repo: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}