// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: network.slices.slice.getJobStatus
//
// 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::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Nsid, Datetime};
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::network_slices::slice::get_job_status;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct JobStatus<'a> {
    ///When the job completed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub completed_at: Option<Datetime>,
    ///When the job was created
    pub created_at: Datetime,
    ///Error message if job failed
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub error: Option<CowStr<'a>>,
    ///UUID of the job
    #[serde(borrow)]
    pub job_id: CowStr<'a>,
    ///Job result if completed successfully
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub result: Option<get_job_status::SyncJobResult<'a>>,
    ///Number of times the job has been retried
    pub retry_count: i64,
    ///When the job started executing
    #[serde(skip_serializing_if = "Option::is_none")]
    pub started_at: Option<Datetime>,
    ///Current status of the job
    #[serde(borrow)]
    pub status: CowStr<'a>,
}


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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetJobStatusOutput<'a> {
    #[serde(flatten)]
    #[serde(borrow)]
    pub value: jacquard_common::types::value::Data<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SyncJobResult<'a> {
    ///List of collection NSIDs that were synced
    #[serde(borrow)]
    pub collections_synced: Vec<Nsid<'a>>,
    ///Human-readable message about the job completion
    #[serde(borrow)]
    pub message: CowStr<'a>,
    ///Number of repositories processed
    pub repos_processed: i64,
    ///Whether the sync job completed successfully
    pub success: bool,
    ///Total number of records synced
    pub total_records: i64,
}

impl<'a> LexiconSchema for JobStatus<'a> {
    fn nsid() -> &'static str {
        "network.slices.slice.getJobStatus"
    }
    fn def_name() -> &'static str {
        "jobStatus"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_slice_getJobStatus()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

/// Response type for network.slices.slice.getJobStatus
pub struct GetJobStatusResponse;
impl jacquard_common::xrpc::XrpcResp for GetJobStatusResponse {
    const NSID: &'static str = "network.slices.slice.getJobStatus";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetJobStatusOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl<'a> jacquard_common::xrpc::XrpcRequest for GetJobStatus<'a> {
    const NSID: &'static str = "network.slices.slice.getJobStatus";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetJobStatusResponse;
}

/// Endpoint type for network.slices.slice.getJobStatus
pub struct GetJobStatusRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetJobStatusRequest {
    const PATH: &'static str = "/xrpc/network.slices.slice.getJobStatus";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetJobStatus<'de>;
    type Response = GetJobStatusResponse;
}

impl<'a> LexiconSchema for SyncJobResult<'a> {
    fn nsid() -> &'static str {
        "network.slices.slice.getJobStatus"
    }
    fn def_name() -> &'static str {
        "syncJobResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_network_slices_slice_getJobStatus()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod job_status_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 Status;
        type CreatedAt;
        type JobId;
        type RetryCount;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Status = Unset;
        type CreatedAt = Unset;
        type JobId = Unset;
        type RetryCount = Unset;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStatus<S> {}
    impl<S: State> State for SetStatus<S> {
        type Status = Set<members::status>;
        type CreatedAt = S::CreatedAt;
        type JobId = S::JobId;
        type RetryCount = S::RetryCount;
    }
    ///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 Status = S::Status;
        type CreatedAt = Set<members::created_at>;
        type JobId = S::JobId;
        type RetryCount = S::RetryCount;
    }
    ///State transition - sets the `job_id` field to Set
    pub struct SetJobId<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetJobId<S> {}
    impl<S: State> State for SetJobId<S> {
        type Status = S::Status;
        type CreatedAt = S::CreatedAt;
        type JobId = Set<members::job_id>;
        type RetryCount = S::RetryCount;
    }
    ///State transition - sets the `retry_count` field to Set
    pub struct SetRetryCount<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetRetryCount<S> {}
    impl<S: State> State for SetRetryCount<S> {
        type Status = S::Status;
        type CreatedAt = S::CreatedAt;
        type JobId = S::JobId;
        type RetryCount = Set<members::retry_count>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `job_id` field
        pub struct job_id(());
        ///Marker type for the `retry_count` field
        pub struct retry_count(());
    }
}

/// Builder for constructing an instance of this type
pub struct JobStatusBuilder<'a, S: job_status_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Datetime>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<get_job_status::SyncJobResult<'a>>,
        Option<i64>,
        Option<Datetime>,
        Option<CowStr<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> JobStatus<'a> {
    /// Create a new builder for this type
    pub fn new() -> JobStatusBuilder<'a, job_status_state::Empty> {
        JobStatusBuilder::new()
    }
}

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

impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
    /// Set the `completedAt` field (optional)
    pub fn completed_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `completedAt` field to an Option value (optional)
    pub fn maybe_completed_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
    /// Set the `error` field (optional)
    pub fn error(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `error` field to an Option value (optional)
    pub fn maybe_error(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> JobStatusBuilder<'a, S>
where
    S: job_status_state::State,
    S::JobId: job_status_state::IsUnset,
{
    /// Set the `jobId` field (required)
    pub fn job_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> JobStatusBuilder<'a, job_status_state::SetJobId<S>> {
        self._fields.3 = Option::Some(value.into());
        JobStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
    /// Set the `result` field (optional)
    pub fn result(
        mut self,
        value: impl Into<Option<get_job_status::SyncJobResult<'a>>>,
    ) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `result` field to an Option value (optional)
    pub fn maybe_result(
        mut self,
        value: Option<get_job_status::SyncJobResult<'a>>,
    ) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S> JobStatusBuilder<'a, S>
where
    S: job_status_state::State,
    S::RetryCount: job_status_state::IsUnset,
{
    /// Set the `retryCount` field (required)
    pub fn retry_count(
        mut self,
        value: impl Into<i64>,
    ) -> JobStatusBuilder<'a, job_status_state::SetRetryCount<S>> {
        self._fields.5 = Option::Some(value.into());
        JobStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: job_status_state::State> JobStatusBuilder<'a, S> {
    /// Set the `startedAt` field (optional)
    pub fn started_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `startedAt` field to an Option value (optional)
    pub fn maybe_started_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> JobStatusBuilder<'a, S>
where
    S: job_status_state::State,
    S::Status: job_status_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> JobStatusBuilder<'a, job_status_state::SetStatus<S>> {
        self._fields.7 = Option::Some(value.into());
        JobStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> JobStatusBuilder<'a, S>
where
    S: job_status_state::State,
    S::Status: job_status_state::IsSet,
    S::CreatedAt: job_status_state::IsSet,
    S::JobId: job_status_state::IsSet,
    S::RetryCount: job_status_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> JobStatus<'a> {
        JobStatus {
            completed_at: self._fields.0,
            created_at: self._fields.1.unwrap(),
            error: self._fields.2,
            job_id: self._fields.3.unwrap(),
            result: self._fields.4,
            retry_count: self._fields.5.unwrap(),
            started_at: self._fields.6,
            status: self._fields.7.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>,
        >,
    ) -> JobStatus<'a> {
        JobStatus {
            completed_at: self._fields.0,
            created_at: self._fields.1.unwrap(),
            error: self._fields.2,
            job_id: self._fields.3.unwrap(),
            result: self._fields.4,
            retry_count: self._fields.5.unwrap(),
            started_at: self._fields.6,
            status: self._fields.7.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_network_slices_slice_getJobStatus() -> 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("network.slices.slice.getJobStatus"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("jobStatus"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("jobId"), SmolStr::new_static("status"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("retryCount")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("completedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the job completed"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the job was created"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("error"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Error message if job failed"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("jobId"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("UUID of the job")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("result"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#syncJobResult"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("retryCount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("startedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("When the job started executing"),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Current status of the job"),
                                ),
                                ..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("jobId")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("jobId"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static("UUID of the sync job"),
                                        ),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("syncJobResult"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("success"),
                            SmolStr::new_static("totalRecords"),
                            SmolStr::new_static("collectionsSynced"),
                            SmolStr::new_static("reposProcessed"),
                            SmolStr::new_static("message")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("collectionsSynced"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of collection NSIDs that were synced",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Nsid),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("message"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Human-readable message about the job completion",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("reposProcessed"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("success"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("totalRecords"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

impl<'a> GetJobStatus<'a> {
    /// Create a new builder for this type
    pub fn new() -> GetJobStatusBuilder<'a, get_job_status_state::Empty> {
        GetJobStatusBuilder::new()
    }
}

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

impl<'a, S> GetJobStatusBuilder<'a, S>
where
    S: get_job_status_state::State,
    S::JobId: get_job_status_state::IsUnset,
{
    /// Set the `jobId` field (required)
    pub fn job_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> GetJobStatusBuilder<'a, get_job_status_state::SetJobId<S>> {
        self._fields.0 = Option::Some(value.into());
        GetJobStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> GetJobStatusBuilder<'a, S>
where
    S: get_job_status_state::State,
    S::JobId: get_job_status_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> GetJobStatus<'a> {
        GetJobStatus {
            job_id: self._fields.0.unwrap(),
        }
    }
}

pub mod sync_job_result_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 Success;
        type CollectionsSynced;
        type TotalRecords;
        type ReposProcessed;
        type Message;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Success = Unset;
        type CollectionsSynced = Unset;
        type TotalRecords = Unset;
        type ReposProcessed = Unset;
        type Message = Unset;
    }
    ///State transition - sets the `success` field to Set
    pub struct SetSuccess<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSuccess<S> {}
    impl<S: State> State for SetSuccess<S> {
        type Success = Set<members::success>;
        type CollectionsSynced = S::CollectionsSynced;
        type TotalRecords = S::TotalRecords;
        type ReposProcessed = S::ReposProcessed;
        type Message = S::Message;
    }
    ///State transition - sets the `collections_synced` field to Set
    pub struct SetCollectionsSynced<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCollectionsSynced<S> {}
    impl<S: State> State for SetCollectionsSynced<S> {
        type Success = S::Success;
        type CollectionsSynced = Set<members::collections_synced>;
        type TotalRecords = S::TotalRecords;
        type ReposProcessed = S::ReposProcessed;
        type Message = S::Message;
    }
    ///State transition - sets the `total_records` field to Set
    pub struct SetTotalRecords<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTotalRecords<S> {}
    impl<S: State> State for SetTotalRecords<S> {
        type Success = S::Success;
        type CollectionsSynced = S::CollectionsSynced;
        type TotalRecords = Set<members::total_records>;
        type ReposProcessed = S::ReposProcessed;
        type Message = S::Message;
    }
    ///State transition - sets the `repos_processed` field to Set
    pub struct SetReposProcessed<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetReposProcessed<S> {}
    impl<S: State> State for SetReposProcessed<S> {
        type Success = S::Success;
        type CollectionsSynced = S::CollectionsSynced;
        type TotalRecords = S::TotalRecords;
        type ReposProcessed = Set<members::repos_processed>;
        type Message = S::Message;
    }
    ///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 Success = S::Success;
        type CollectionsSynced = S::CollectionsSynced;
        type TotalRecords = S::TotalRecords;
        type ReposProcessed = S::ReposProcessed;
        type Message = Set<members::message>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `success` field
        pub struct success(());
        ///Marker type for the `collections_synced` field
        pub struct collections_synced(());
        ///Marker type for the `total_records` field
        pub struct total_records(());
        ///Marker type for the `repos_processed` field
        pub struct repos_processed(());
        ///Marker type for the `message` field
        pub struct message(());
    }
}

/// Builder for constructing an instance of this type
pub struct SyncJobResultBuilder<'a, S: sync_job_result_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<Nsid<'a>>>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<bool>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> SyncJobResult<'a> {
    /// Create a new builder for this type
    pub fn new() -> SyncJobResultBuilder<'a, sync_job_result_state::Empty> {
        SyncJobResultBuilder::new()
    }
}

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

impl<'a, S> SyncJobResultBuilder<'a, S>
where
    S: sync_job_result_state::State,
    S::CollectionsSynced: sync_job_result_state::IsUnset,
{
    /// Set the `collectionsSynced` field (required)
    pub fn collections_synced(
        mut self,
        value: impl Into<Vec<Nsid<'a>>>,
    ) -> SyncJobResultBuilder<'a, sync_job_result_state::SetCollectionsSynced<S>> {
        self._fields.0 = Option::Some(value.into());
        SyncJobResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SyncJobResultBuilder<'a, S>
where
    S: sync_job_result_state::State,
    S::Message: sync_job_result_state::IsUnset,
{
    /// Set the `message` field (required)
    pub fn message(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> SyncJobResultBuilder<'a, sync_job_result_state::SetMessage<S>> {
        self._fields.1 = Option::Some(value.into());
        SyncJobResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SyncJobResultBuilder<'a, S>
where
    S: sync_job_result_state::State,
    S::ReposProcessed: sync_job_result_state::IsUnset,
{
    /// Set the `reposProcessed` field (required)
    pub fn repos_processed(
        mut self,
        value: impl Into<i64>,
    ) -> SyncJobResultBuilder<'a, sync_job_result_state::SetReposProcessed<S>> {
        self._fields.2 = Option::Some(value.into());
        SyncJobResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SyncJobResultBuilder<'a, S>
where
    S: sync_job_result_state::State,
    S::Success: sync_job_result_state::IsUnset,
{
    /// Set the `success` field (required)
    pub fn success(
        mut self,
        value: impl Into<bool>,
    ) -> SyncJobResultBuilder<'a, sync_job_result_state::SetSuccess<S>> {
        self._fields.3 = Option::Some(value.into());
        SyncJobResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SyncJobResultBuilder<'a, S>
where
    S: sync_job_result_state::State,
    S::TotalRecords: sync_job_result_state::IsUnset,
{
    /// Set the `totalRecords` field (required)
    pub fn total_records(
        mut self,
        value: impl Into<i64>,
    ) -> SyncJobResultBuilder<'a, sync_job_result_state::SetTotalRecords<S>> {
        self._fields.4 = Option::Some(value.into());
        SyncJobResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SyncJobResultBuilder<'a, S>
where
    S: sync_job_result_state::State,
    S::Success: sync_job_result_state::IsSet,
    S::CollectionsSynced: sync_job_result_state::IsSet,
    S::TotalRecords: sync_job_result_state::IsSet,
    S::ReposProcessed: sync_job_result_state::IsSet,
    S::Message: sync_job_result_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SyncJobResult<'a> {
        SyncJobResult {
            collections_synced: self._fields.0.unwrap(),
            message: self._fields.1.unwrap(),
            repos_processed: self._fields.2.unwrap(),
            success: self._fields.3.unwrap(),
            total_records: 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,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> SyncJobResult<'a> {
        SyncJobResult {
            collections_synced: self._fields.0.unwrap(),
            message: self._fields.1.unwrap(),
            repos_processed: self._fields.2.unwrap(),
            success: self._fields.3.unwrap(),
            total_records: self._fields.4.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}