// @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, BosStr, 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::{Nsid, Datetime};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct JobStatus<S: BosStr = DefaultStr> {
    ///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")]
    pub error: Option<S>,
    ///UUID of the job
    pub job_id: S,
    ///Job result if completed successfully
    #[serde(skip_serializing_if = "Option::is_none")]
    pub result: Option<get_job_status::SyncJobResult<S>>,
    ///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
    pub status: 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 GetJobStatus<S: BosStr = DefaultStr> {
    pub job_id: S,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetJobStatusOutput<S: BosStr = DefaultStr> {
    #[serde(flatten)]
    pub value: Data<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 SyncJobResult<S: BosStr = DefaultStr> {
    ///List of collection NSIDs that were synced
    pub collections_synced: Vec<Nsid<S>>,
    ///Human-readable message about the job completion
    pub message: S,
    ///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,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for JobStatus<S> {
    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 marker for the `network.slices.slice.getJobStatus` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetJobStatusOutput<S>` for this endpoint.*/
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<S: BosStr> = GetJobStatusOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

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

/** Endpoint marker for the `network.slices.slice.getJobStatus` query.

Path: `/xrpc/network.slices.slice.getJobStatus`. The request payload type is `GetJobStatus<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
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<S: BosStr> = GetJobStatus<S>;
    type Response = GetJobStatusResponse;
}

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

/// Builder for constructing an instance of this type.
pub struct JobStatusBuilder<St: job_status_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Datetime>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<get_job_status::SyncJobResult<S>>,
        Option<i64>,
        Option<Datetime>,
        Option<S>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl JobStatus<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> JobStatusBuilder<job_status_state::Empty, DefaultStr> {
        JobStatusBuilder::new()
    }
}

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

impl JobStatusBuilder<job_status_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        JobStatusBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

impl<St: job_status_state::State, S: BosStr> JobStatusBuilder<St, 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<St, S: BosStr> JobStatusBuilder<St, S>
where
    St: job_status_state::State,
    St::CreatedAt: job_status_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> JobStatusBuilder<job_status_state::SetCreatedAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        JobStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St: job_status_state::State, S: BosStr> JobStatusBuilder<St, S> {
    /// Set the `result` field (optional)
    pub fn result(
        mut self,
        value: impl Into<Option<get_job_status::SyncJobResult<S>>>,
    ) -> 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<S>>,
    ) -> Self {
        self._fields.4 = value;
        self
    }
}

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

impl<St: job_status_state::State, S: BosStr> JobStatusBuilder<St, 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<St, S: BosStr> JobStatusBuilder<St, S>
where
    St: job_status_state::State,
    St::Status: job_status_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<S>,
    ) -> JobStatusBuilder<job_status_state::SetStatus<St>, S> {
        self._fields.7 = Option::Some(value.into());
        JobStatusBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> JobStatusBuilder<St, S>
where
    St: job_status_state::State,
    St::CreatedAt: job_status_state::IsSet,
    St::JobId: job_status_state::IsSet,
    St::RetryCount: job_status_state::IsSet,
    St::Status: job_status_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> JobStatus<S> {
        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<SmolStr, Data<S>>,
    ) -> JobStatus<S> {
        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<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetJobId<St> {}
    impl<St: State> State for SetJobId<St> {
        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<St: get_job_status_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<S>,),
    _type: PhantomData<fn() -> S>,
}

impl GetJobStatus<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> GetJobStatusBuilder<get_job_status_state::Empty, DefaultStr> {
        GetJobStatusBuilder::new()
    }
}

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

impl GetJobStatusBuilder<get_job_status_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        GetJobStatusBuilder {
            _state: PhantomData,
            _fields: (None,),
            _type: PhantomData,
        }
    }
}

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

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

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

/// Builder for constructing an instance of this type.
pub struct SyncJobResultBuilder<
    St: sync_job_result_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Vec<Nsid<S>>>, Option<S>, Option<i64>, Option<bool>, Option<i64>),
    _type: PhantomData<fn() -> S>,
}

impl SyncJobResult<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> SyncJobResultBuilder<sync_job_result_state::Empty, DefaultStr> {
        SyncJobResultBuilder::new()
    }
}

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

impl SyncJobResultBuilder<sync_job_result_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        SyncJobResultBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

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

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

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

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

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

impl<St, S: BosStr> SyncJobResultBuilder<St, S>
where
    St: sync_job_result_state::State,
    St::CollectionsSynced: sync_job_result_state::IsSet,
    St::Message: sync_job_result_state::IsSet,
    St::ReposProcessed: sync_job_result_state::IsSet,
    St::Success: sync_job_result_state::IsSet,
    St::TotalRecords: sync_job_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SyncJobResult<S> {
        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<SmolStr, Data<S>>,
    ) -> SyncJobResult<S> {
        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),
        }
    }
}