jacquard-api 0.12.0-beta.2

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.tangled.git.temp.analyzeMerge
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::AtUri;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

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

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
    rename_all = "camelCase",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ConflictInfo<S: BosStr = DefaultStr> {
    ///Name of the conflicted file
    pub filename: S,
    ///Reason for the conflict
    pub reason: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct AnalyzeMerge<S: BosStr = DefaultStr> {
    pub branch: S,
    pub patch: S,
    pub repo: AtUri<S>,
}

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct AnalyzeMergeOutput<S: BosStr = DefaultStr> {
    ///List of files with merge conflicts
    #[serde(skip_serializing_if = "Option::is_none")]
    pub conflicts: Option<Vec<analyze_merge::ConflictInfo<S>>>,
    ///Whether the merge has conflicts
    pub is_conflicted: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for ConflictInfo<S> {
    fn nsid() -> &'static str {
        "sh.tangled.git.temp.analyzeMerge"
    }
    fn def_name() -> &'static str {
        "conflictInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_tangled_git_temp_analyzeMerge()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/// Response type for sh.tangled.git.temp.analyzeMerge
pub struct AnalyzeMergeResponse;
impl jacquard_common::xrpc::XrpcResp for AnalyzeMergeResponse {
    const NSID: &'static str = "sh.tangled.git.temp.analyzeMerge";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = AnalyzeMergeOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for AnalyzeMerge<S> {
    const NSID: &'static str = "sh.tangled.git.temp.analyzeMerge";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = AnalyzeMergeResponse;
}

/// Endpoint type for sh.tangled.git.temp.analyzeMerge
pub struct AnalyzeMergeRequest;
impl jacquard_common::xrpc::XrpcEndpoint for AnalyzeMergeRequest {
    const PATH: &'static str = "/xrpc/sh.tangled.git.temp.analyzeMerge";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = AnalyzeMerge<S>;
    type Response = AnalyzeMergeResponse;
}

fn lexicon_doc_sh_tangled_git_temp_analyzeMerge() -> LexiconDoc<'static> {
    use alloc::collections::BTreeMap;
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("sh.tangled.git.temp.analyzeMerge"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("conflictInfo"),
                LexUserType::Object(LexObject {
                    required: Some(vec![
                        SmolStr::new_static("filename"),
                        SmolStr::new_static("reason"),
                    ]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("filename"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static(
                                    "Name of the conflicted file",
                                )),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("reason"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Reason for the conflict")),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(LexXrpcQueryParameter::Params(LexXrpcParameters {
                        required: Some(vec![
                            SmolStr::new_static("repo"),
                            SmolStr::new_static("patch"),
                            SmolStr::new_static("branch"),
                        ]),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("branch"),
                                LexXrpcParametersProperty::String(LexString {
                                    description: Some(CowStr::new_static(
                                        "Target branch to merge into",
                                    )),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("patch"),
                                LexXrpcParametersProperty::String(LexString {
                                    description: Some(CowStr::new_static(
                                        "Patch or pull request to check for merge conflicts",
                                    )),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("repo"),
                                LexXrpcParametersProperty::String(LexString {
                                    description: Some(CowStr::new_static(
                                        "AT-URI of the repository",
                                    )),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    })),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod analyze_merge_state {

    pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
    #[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 Patch;
        type Repo;
        type Branch;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Patch = Unset;
        type Repo = Unset;
        type Branch = Unset;
    }
    ///State transition - sets the `patch` field to Set
    pub struct SetPatch<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPatch<St> {}
    impl<St: State> State for SetPatch<St> {
        type Patch = Set<members::patch>;
        type Repo = St::Repo;
        type Branch = St::Branch;
    }
    ///State transition - sets the `repo` field to Set
    pub struct SetRepo<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRepo<St> {}
    impl<St: State> State for SetRepo<St> {
        type Patch = St::Patch;
        type Repo = Set<members::repo>;
        type Branch = St::Branch;
    }
    ///State transition - sets the `branch` field to Set
    pub struct SetBranch<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetBranch<St> {}
    impl<St: State> State for SetBranch<St> {
        type Patch = St::Patch;
        type Repo = St::Repo;
        type Branch = Set<members::branch>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `patch` field
        pub struct patch(());
        ///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 AnalyzeMergeBuilder<S: BosStr, St: analyze_merge_state::State> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>, Option<S>, Option<AtUri<S>>),
    _type: PhantomData<fn() -> S>,
}

impl<S: BosStr> AnalyzeMerge<S> {
    /// Create a new builder for this type.
    pub fn new() -> AnalyzeMergeBuilder<S, analyze_merge_state::Empty> {
        AnalyzeMergeBuilder::new()
    }
}

impl<S: BosStr> AnalyzeMergeBuilder<S, analyze_merge_state::Empty> {
    /// Create a new builder with all fields unset.
    pub fn new() -> Self {
        AnalyzeMergeBuilder {
            _state: PhantomData,
            _fields: (None, None, None),
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AnalyzeMergeBuilder<S, St>
where
    St: analyze_merge_state::State,
    St::Branch: analyze_merge_state::IsUnset,
{
    /// Set the `branch` field (required)
    pub fn branch(
        mut self,
        value: impl Into<S>,
    ) -> AnalyzeMergeBuilder<S, analyze_merge_state::SetBranch<St>> {
        self._fields.0 = Option::Some(value.into());
        AnalyzeMergeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AnalyzeMergeBuilder<S, St>
where
    St: analyze_merge_state::State,
    St::Patch: analyze_merge_state::IsUnset,
{
    /// Set the `patch` field (required)
    pub fn patch(
        mut self,
        value: impl Into<S>,
    ) -> AnalyzeMergeBuilder<S, analyze_merge_state::SetPatch<St>> {
        self._fields.1 = Option::Some(value.into());
        AnalyzeMergeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AnalyzeMergeBuilder<S, St>
where
    St: analyze_merge_state::State,
    St::Repo: analyze_merge_state::IsUnset,
{
    /// Set the `repo` field (required)
    pub fn repo(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> AnalyzeMergeBuilder<S, analyze_merge_state::SetRepo<St>> {
        self._fields.2 = Option::Some(value.into());
        AnalyzeMergeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<S: BosStr, St> AnalyzeMergeBuilder<S, St>
where
    St: analyze_merge_state::State,
    St::Patch: analyze_merge_state::IsSet,
    St::Repo: analyze_merge_state::IsSet,
    St::Branch: analyze_merge_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> AnalyzeMerge<S> {
        AnalyzeMerge {
            branch: self._fields.0.unwrap(),
            patch: self._fields.1.unwrap(),
            repo: self._fields.2.unwrap(),
        }
    }
}