// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: io.atcr.hold.subscribeScanJobs
//
// 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};
use jacquard_common::deps::bytes::Bytes;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Did, UriValue};
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
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::io_atcr::hold::subscribe_scan_jobs;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct SubscribeScanJobs {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cursor: Option<i64>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum SubscribeScanJobsMessage<S: BosStr = DefaultStr> {
    #[serde(rename = "#scanJob")]
    ScanJob(Box<subscribe_scan_jobs::ScanJob<S>>),
    #[serde(rename = "#scanResult")]
    ScanResult(Box<subscribe_scan_jobs::ScanResult<S>>),
}

impl<S: BosStr> SubscribeScanJobsMessage<S> {
    /// Decode a framed DAG-CBOR message (header + body).
    pub fn decode_framed<'de>(
        bytes: &'de [u8],
    ) -> Result<SubscribeScanJobsMessage<S>, jacquard_common::error::DecodeError>
    where
        S: serde::Deserialize<'de>,
    {
        let (header, body) = jacquard_common::xrpc::subscription::parse_event_header(
            bytes,
        )?;
        match header.t.as_str() {
            "#scanJob" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::ScanJob(Box::new(variant)))
            }
            "#scanResult" => {
                let variant = jacquard_common::deps::codegen::serde_ipld_dagcbor::from_slice(
                    body,
                )?;
                Ok(Self::ScanResult(Box::new(variant)))
            }
            unknown => {
                Err(
                    jacquard_common::error::DecodeError::UnknownEventType(unknown.into()),
                )
            }
        }
    }
}


#[derive(
    Serialize,
    Deserialize,
    Debug,
    Clone,
    PartialEq,
    Eq,
    thiserror::Error,
    miette::Diagnostic
)]

#[serde(tag = "error", content = "message")]
pub enum SubscribeScanJobsError {
    /// Scanner shared secret is invalid
    #[serde(rename = "InvalidSecret")]
    InvalidSecret(Option<SmolStr>),
    /// Catch-all for unknown error codes.
    #[serde(untagged)]
    Other { error: SmolStr, message: Option<SmolStr> },
}

impl core::fmt::Display for SubscribeScanJobsError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::InvalidSecret(msg) => {
                write!(f, "InvalidSecret")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::Other { error, message } => {
                write!(f, "{}", error)?;
                if let Some(msg) = message {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
        }
    }
}

/// A scan job dispatched from hold to scanner. Sent as a JSON WebSocket message.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ScanJob<S: BosStr = DefaultStr> {
    ///Manifest digest (e.g., sha256:abc123...)
    pub digest: S,
    ///DID of the hold where the image is stored
    pub hold_did: Did<S>,
    ///HTTP endpoint of the hold for blob downloads
    pub hold_endpoint: UriValue<S>,
    ///Scan priority (lower = higher priority). Tier-based scheduling.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub priority: Option<i64>,
    ///Repository name (e.g., myapp)
    pub repository: S,
    ///Monotonic sequence number for cursor-based resumption
    pub seq: i64,
    ///Optional tag that triggered the scan
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tag: Option<S>,
    ///Message type discriminator
    pub r#type: S,
    ///DID of the image owner
    pub user_did: Did<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A scan result sent from scanner back to hold. Sent as a JSON WebSocket message.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ScanResult<S: BosStr = DefaultStr> {
    ///Manifest digest that was scanned
    pub digest: S,
    ///Error message if scan failed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<S>,
    ///SBOM blob (SPDX JSON format, max 100MB)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")]
    pub sbom: Option<Bytes>,
    ///Scanner version string
    #[serde(skip_serializing_if = "Option::is_none")]
    pub scanner_version: Option<S>,
    ///Vulnerability count summary
    pub summary: subscribe_scan_jobs::VulnSummary<S>,
    ///Message type discriminator
    pub r#type: S,
    ///Grype vulnerability report blob (JSON, max 100MB)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default, with = "jacquard_common::opt_serde_bytes_helper")]
    pub vuln_report: Option<Bytes>,
    #[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 VulnSummary<S: BosStr = DefaultStr> {
    ///Count of critical severity vulnerabilities
    pub critical: i64,
    ///Count of high severity vulnerabilities
    pub high: i64,
    ///Count of low severity vulnerabilities
    pub low: i64,
    ///Count of medium severity vulnerabilities
    pub medium: i64,
    ///Total vulnerability count
    pub total: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

///Stream response type for
///io.atcr.hold.subscribeScanJobs
pub struct SubscribeScanJobsStream;
impl jacquard_common::xrpc::SubscriptionResp for SubscribeScanJobsStream {
    const NSID: &'static str = "io.atcr.hold.subscribeScanJobs";
    const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json;
    type Message<S: BosStr> = SubscribeScanJobsMessage<S>;
    type Error = SubscribeScanJobsError;
}

impl jacquard_common::xrpc::XrpcSubscription for SubscribeScanJobs {
    const NSID: &'static str = "io.atcr.hold.subscribeScanJobs";
    const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json;
    type Stream = SubscribeScanJobsStream;
}

pub struct SubscribeScanJobsEndpoint;
impl jacquard_common::xrpc::SubscriptionEndpoint for SubscribeScanJobsEndpoint {
    const PATH: &'static str = "/xrpc/io.atcr.hold.subscribeScanJobs";
    const ENCODING: jacquard_common::xrpc::MessageEncoding = jacquard_common::xrpc::MessageEncoding::Json;
    type Params<S: BosStr> = SubscribeScanJobs;
    type Stream = SubscribeScanJobsStream;
}

impl<S: BosStr> LexiconSchema for ScanJob<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.subscribeScanJobs"
    }
    fn def_name() -> &'static str {
        "scanJob"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_subscribeScanJobs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.digest;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("digest"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.repository;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("repository"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.tag {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tag"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.r#type;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("type"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ScanResult<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.subscribeScanJobs"
    }
    fn def_name() -> &'static str {
        "scanResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_subscribeScanJobs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.digest;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("digest"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.error {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 1024usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("error"),
                    max: 1024usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.scanner_version {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("scanner_version"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.r#type;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 32usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("type"),
                    max: 32usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for VulnSummary<S> {
    fn nsid() -> &'static str {
        "io.atcr.hold.subscribeScanJobs"
    }
    fn def_name() -> &'static str {
        "vulnSummary"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_atcr_hold_subscribeScanJobs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.critical;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("critical"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.high;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("high"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.low;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("low"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.medium;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("medium"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.total;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod subscribe_scan_jobs_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 {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

/// Builder for constructing an instance of this type.
pub struct SubscribeScanJobsBuilder<St: subscribe_scan_jobs_state::State> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<i64>,),
}

impl SubscribeScanJobs {
    /// Create a new builder for this type.
    pub fn new() -> SubscribeScanJobsBuilder<subscribe_scan_jobs_state::Empty> {
        SubscribeScanJobsBuilder::new()
    }
}

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

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

impl<St: subscribe_scan_jobs_state::State> SubscribeScanJobsBuilder<St> {
    /// Set the `cursor` field (optional)
    pub fn cursor(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cursor` field to an Option value (optional)
    pub fn maybe_cursor(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St> SubscribeScanJobsBuilder<St>
where
    St: subscribe_scan_jobs_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> SubscribeScanJobs {
        SubscribeScanJobs {
            cursor: self._fields.0,
        }
    }
}

pub mod scan_job_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 Digest;
        type HoldDid;
        type HoldEndpoint;
        type Repository;
        type Seq;
        type Type;
        type UserDid;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Digest = Unset;
        type HoldDid = Unset;
        type HoldEndpoint = Unset;
        type Repository = Unset;
        type Seq = Unset;
        type Type = Unset;
        type UserDid = Unset;
    }
    ///State transition - sets the `digest` field to Set
    pub struct SetDigest<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDigest<St> {}
    impl<St: State> State for SetDigest<St> {
        type Digest = Set<members::digest>;
        type HoldDid = St::HoldDid;
        type HoldEndpoint = St::HoldEndpoint;
        type Repository = St::Repository;
        type Seq = St::Seq;
        type Type = St::Type;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `hold_did` field to Set
    pub struct SetHoldDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHoldDid<St> {}
    impl<St: State> State for SetHoldDid<St> {
        type Digest = St::Digest;
        type HoldDid = Set<members::hold_did>;
        type HoldEndpoint = St::HoldEndpoint;
        type Repository = St::Repository;
        type Seq = St::Seq;
        type Type = St::Type;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `hold_endpoint` field to Set
    pub struct SetHoldEndpoint<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHoldEndpoint<St> {}
    impl<St: State> State for SetHoldEndpoint<St> {
        type Digest = St::Digest;
        type HoldDid = St::HoldDid;
        type HoldEndpoint = Set<members::hold_endpoint>;
        type Repository = St::Repository;
        type Seq = St::Seq;
        type Type = St::Type;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `repository` field to Set
    pub struct SetRepository<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRepository<St> {}
    impl<St: State> State for SetRepository<St> {
        type Digest = St::Digest;
        type HoldDid = St::HoldDid;
        type HoldEndpoint = St::HoldEndpoint;
        type Repository = Set<members::repository>;
        type Seq = St::Seq;
        type Type = St::Type;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `seq` field to Set
    pub struct SetSeq<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSeq<St> {}
    impl<St: State> State for SetSeq<St> {
        type Digest = St::Digest;
        type HoldDid = St::HoldDid;
        type HoldEndpoint = St::HoldEndpoint;
        type Repository = St::Repository;
        type Seq = Set<members::seq>;
        type Type = St::Type;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type Digest = St::Digest;
        type HoldDid = St::HoldDid;
        type HoldEndpoint = St::HoldEndpoint;
        type Repository = St::Repository;
        type Seq = St::Seq;
        type Type = Set<members::r#type>;
        type UserDid = St::UserDid;
    }
    ///State transition - sets the `user_did` field to Set
    pub struct SetUserDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUserDid<St> {}
    impl<St: State> State for SetUserDid<St> {
        type Digest = St::Digest;
        type HoldDid = St::HoldDid;
        type HoldEndpoint = St::HoldEndpoint;
        type Repository = St::Repository;
        type Seq = St::Seq;
        type Type = St::Type;
        type UserDid = Set<members::user_did>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `digest` field
        pub struct digest(());
        ///Marker type for the `hold_did` field
        pub struct hold_did(());
        ///Marker type for the `hold_endpoint` field
        pub struct hold_endpoint(());
        ///Marker type for the `repository` field
        pub struct repository(());
        ///Marker type for the `seq` field
        pub struct seq(());
        ///Marker type for the `type` field
        pub struct r#type(());
        ///Marker type for the `user_did` field
        pub struct user_did(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ScanJobBuilder<St: scan_job_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<Did<S>>,
        Option<UriValue<S>>,
        Option<i64>,
        Option<S>,
        Option<i64>,
        Option<S>,
        Option<S>,
        Option<Did<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ScanJob<S> {
    /// Create a new builder for this type
    pub fn builder() -> ScanJobBuilder<scan_job_state::Empty, S> {
        ScanJobBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::Digest: scan_job_state::IsUnset,
{
    /// Set the `digest` field (required)
    pub fn digest(
        mut self,
        value: impl Into<S>,
    ) -> ScanJobBuilder<scan_job_state::SetDigest<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::HoldDid: scan_job_state::IsUnset,
{
    /// Set the `holdDid` field (required)
    pub fn hold_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> ScanJobBuilder<scan_job_state::SetHoldDid<St>, S> {
        self._fields.1 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::HoldEndpoint: scan_job_state::IsUnset,
{
    /// Set the `holdEndpoint` field (required)
    pub fn hold_endpoint(
        mut self,
        value: impl Into<UriValue<S>>,
    ) -> ScanJobBuilder<scan_job_state::SetHoldEndpoint<St>, S> {
        self._fields.2 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: scan_job_state::State, S: BosStr> ScanJobBuilder<St, S> {
    /// Set the `priority` field (optional)
    pub fn priority(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `priority` field to an Option value (optional)
    pub fn maybe_priority(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::Repository: scan_job_state::IsUnset,
{
    /// Set the `repository` field (required)
    pub fn repository(
        mut self,
        value: impl Into<S>,
    ) -> ScanJobBuilder<scan_job_state::SetRepository<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::Seq: scan_job_state::IsUnset,
{
    /// Set the `seq` field (required)
    pub fn seq(
        mut self,
        value: impl Into<i64>,
    ) -> ScanJobBuilder<scan_job_state::SetSeq<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: scan_job_state::State, S: BosStr> ScanJobBuilder<St, S> {
    /// Set the `tag` field (optional)
    pub fn tag(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `tag` field to an Option value (optional)
    pub fn maybe_tag(mut self, value: Option<S>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::Type: scan_job_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<S>,
    ) -> ScanJobBuilder<scan_job_state::SetType<St>, S> {
        self._fields.7 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::UserDid: scan_job_state::IsUnset,
{
    /// Set the `userDid` field (required)
    pub fn user_did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> ScanJobBuilder<scan_job_state::SetUserDid<St>, S> {
        self._fields.8 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScanJobBuilder<St, S>
where
    St: scan_job_state::State,
    St::Digest: scan_job_state::IsSet,
    St::HoldDid: scan_job_state::IsSet,
    St::HoldEndpoint: scan_job_state::IsSet,
    St::Repository: scan_job_state::IsSet,
    St::Seq: scan_job_state::IsSet,
    St::Type: scan_job_state::IsSet,
    St::UserDid: scan_job_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ScanJob<S> {
        ScanJob {
            digest: self._fields.0.unwrap(),
            hold_did: self._fields.1.unwrap(),
            hold_endpoint: self._fields.2.unwrap(),
            priority: self._fields.3,
            repository: self._fields.4.unwrap(),
            seq: self._fields.5.unwrap(),
            tag: self._fields.6,
            r#type: self._fields.7.unwrap(),
            user_did: 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<SmolStr, Data<S>>) -> ScanJob<S> {
        ScanJob {
            digest: self._fields.0.unwrap(),
            hold_did: self._fields.1.unwrap(),
            hold_endpoint: self._fields.2.unwrap(),
            priority: self._fields.3,
            repository: self._fields.4.unwrap(),
            seq: self._fields.5.unwrap(),
            tag: self._fields.6,
            r#type: self._fields.7.unwrap(),
            user_did: self._fields.8.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_io_atcr_hold_subscribeScanJobs() -> 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("io.atcr.hold.subscribeScanJobs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcSubscription(LexXrpcSubscription {
                    parameters: Some(
                        LexXrpcSubscriptionParameter::Params(LexXrpcParameters {
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("cursor"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("scanJob"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A scan job dispatched from hold to scanner. Sent as a JSON WebSocket message.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("type"), SmolStr::new_static("seq"),
                            SmolStr::new_static("digest"),
                            SmolStr::new_static("repository"),
                            SmolStr::new_static("userDid"),
                            SmolStr::new_static("holdDid"),
                            SmolStr::new_static("holdEndpoint")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("digest"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Manifest digest (e.g., sha256:abc123...)",
                                    ),
                                ),
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("holdDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "DID of the hold where the image is stored",
                                    ),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("holdEndpoint"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "HTTP endpoint of the hold for blob downloads",
                                    ),
                                ),
                                format: Some(LexStringFormat::Uri),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("priority"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("repository"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Repository name (e.g., myapp)"),
                                ),
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("seq"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("tag"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Optional tag that triggered the scan"),
                                ),
                                max_length: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Message type discriminator"),
                                ),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("userDid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("DID of the image owner"),
                                ),
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("scanResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A scan result sent from scanner back to hold. Sent as a JSON WebSocket message.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("type"), SmolStr::new_static("digest"),
                            SmolStr::new_static("summary")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("digest"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Manifest digest that was scanned"),
                                ),
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("error"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Error message if scan failed"),
                                ),
                                max_length: Some(1024usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sbom"),
                            LexObjectProperty::Bytes(LexBytes {
                                max_length: Some(104857600usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("scannerVersion"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Scanner version string"),
                                ),
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("summary"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#vulnSummary"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Message type discriminator"),
                                ),
                                max_length: Some(32usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("vulnReport"),
                            LexObjectProperty::Bytes(LexBytes {
                                max_length: Some(104857600usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("vulnSummary"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("critical"), SmolStr::new_static("high"),
                            SmolStr::new_static("medium"), SmolStr::new_static("low"),
                            SmolStr::new_static("total")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("critical"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("high"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("low"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("medium"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("total"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod scan_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 Digest;
        type Summary;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Digest = Unset;
        type Summary = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `digest` field to Set
    pub struct SetDigest<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDigest<St> {}
    impl<St: State> State for SetDigest<St> {
        type Digest = Set<members::digest>;
        type Summary = St::Summary;
        type Type = St::Type;
    }
    ///State transition - sets the `summary` field to Set
    pub struct SetSummary<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSummary<St> {}
    impl<St: State> State for SetSummary<St> {
        type Digest = St::Digest;
        type Summary = Set<members::summary>;
        type Type = St::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type Digest = St::Digest;
        type Summary = St::Summary;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `digest` field
        pub struct digest(());
        ///Marker type for the `summary` field
        pub struct summary(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ScanResultBuilder<St: scan_result_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<S>,
        Option<Bytes>,
        Option<S>,
        Option<subscribe_scan_jobs::VulnSummary<S>>,
        Option<S>,
        Option<Bytes>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ScanResult<S> {
    /// Create a new builder for this type
    pub fn builder() -> ScanResultBuilder<scan_result_state::Empty, S> {
        ScanResultBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ScanResultBuilder<St, S>
where
    St: scan_result_state::State,
    St::Digest: scan_result_state::IsUnset,
{
    /// Set the `digest` field (required)
    pub fn digest(
        mut self,
        value: impl Into<S>,
    ) -> ScanResultBuilder<scan_result_state::SetDigest<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ScanResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St: scan_result_state::State, S: BosStr> ScanResultBuilder<St, S> {
    /// Set the `scannerVersion` field (optional)
    pub fn scanner_version(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `scannerVersion` field to an Option value (optional)
    pub fn maybe_scanner_version(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> ScanResultBuilder<St, S>
where
    St: scan_result_state::State,
    St::Summary: scan_result_state::IsUnset,
{
    /// Set the `summary` field (required)
    pub fn summary(
        mut self,
        value: impl Into<subscribe_scan_jobs::VulnSummary<S>>,
    ) -> ScanResultBuilder<scan_result_state::SetSummary<St>, S> {
        self._fields.4 = Option::Some(value.into());
        ScanResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScanResultBuilder<St, S>
where
    St: scan_result_state::State,
    St::Type: scan_result_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<S>,
    ) -> ScanResultBuilder<scan_result_state::SetType<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ScanResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: scan_result_state::State, S: BosStr> ScanResultBuilder<St, S> {
    /// Set the `vulnReport` field (optional)
    pub fn vuln_report(mut self, value: impl Into<Option<Bytes>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `vulnReport` field to an Option value (optional)
    pub fn maybe_vuln_report(mut self, value: Option<Bytes>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> ScanResultBuilder<St, S>
where
    St: scan_result_state::State,
    St::Digest: scan_result_state::IsSet,
    St::Summary: scan_result_state::IsSet,
    St::Type: scan_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ScanResult<S> {
        ScanResult {
            digest: self._fields.0.unwrap(),
            error: self._fields.1,
            sbom: self._fields.2,
            scanner_version: self._fields.3,
            summary: self._fields.4.unwrap(),
            r#type: self._fields.5.unwrap(),
            vuln_report: self._fields.6,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ScanResult<S> {
        ScanResult {
            digest: self._fields.0.unwrap(),
            error: self._fields.1,
            sbom: self._fields.2,
            scanner_version: self._fields.3,
            summary: self._fields.4.unwrap(),
            r#type: self._fields.5.unwrap(),
            vuln_report: self._fields.6,
            extra_data: Some(extra_data),
        }
    }
}

pub mod vuln_summary_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 Critical;
        type High;
        type Low;
        type Medium;
        type Total;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Critical = Unset;
        type High = Unset;
        type Low = Unset;
        type Medium = Unset;
        type Total = Unset;
    }
    ///State transition - sets the `critical` field to Set
    pub struct SetCritical<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCritical<St> {}
    impl<St: State> State for SetCritical<St> {
        type Critical = Set<members::critical>;
        type High = St::High;
        type Low = St::Low;
        type Medium = St::Medium;
        type Total = St::Total;
    }
    ///State transition - sets the `high` field to Set
    pub struct SetHigh<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHigh<St> {}
    impl<St: State> State for SetHigh<St> {
        type Critical = St::Critical;
        type High = Set<members::high>;
        type Low = St::Low;
        type Medium = St::Medium;
        type Total = St::Total;
    }
    ///State transition - sets the `low` field to Set
    pub struct SetLow<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLow<St> {}
    impl<St: State> State for SetLow<St> {
        type Critical = St::Critical;
        type High = St::High;
        type Low = Set<members::low>;
        type Medium = St::Medium;
        type Total = St::Total;
    }
    ///State transition - sets the `medium` field to Set
    pub struct SetMedium<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetMedium<St> {}
    impl<St: State> State for SetMedium<St> {
        type Critical = St::Critical;
        type High = St::High;
        type Low = St::Low;
        type Medium = Set<members::medium>;
        type Total = St::Total;
    }
    ///State transition - sets the `total` field to Set
    pub struct SetTotal<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTotal<St> {}
    impl<St: State> State for SetTotal<St> {
        type Critical = St::Critical;
        type High = St::High;
        type Low = St::Low;
        type Medium = St::Medium;
        type Total = Set<members::total>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `critical` field
        pub struct critical(());
        ///Marker type for the `high` field
        pub struct high(());
        ///Marker type for the `low` field
        pub struct low(());
        ///Marker type for the `medium` field
        pub struct medium(());
        ///Marker type for the `total` field
        pub struct total(());
    }
}

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

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

impl<S: BosStr> VulnSummary<S> {
    /// Create a new builder for this type
    pub fn builder() -> VulnSummaryBuilder<vuln_summary_state::Empty, S> {
        VulnSummaryBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> VulnSummaryBuilder<St, S>
where
    St: vuln_summary_state::State,
    St::Critical: vuln_summary_state::IsUnset,
{
    /// Set the `critical` field (required)
    pub fn critical(
        mut self,
        value: impl Into<i64>,
    ) -> VulnSummaryBuilder<vuln_summary_state::SetCritical<St>, S> {
        self._fields.0 = Option::Some(value.into());
        VulnSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> VulnSummaryBuilder<St, S>
where
    St: vuln_summary_state::State,
    St::High: vuln_summary_state::IsUnset,
{
    /// Set the `high` field (required)
    pub fn high(
        mut self,
        value: impl Into<i64>,
    ) -> VulnSummaryBuilder<vuln_summary_state::SetHigh<St>, S> {
        self._fields.1 = Option::Some(value.into());
        VulnSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> VulnSummaryBuilder<St, S>
where
    St: vuln_summary_state::State,
    St::Low: vuln_summary_state::IsUnset,
{
    /// Set the `low` field (required)
    pub fn low(
        mut self,
        value: impl Into<i64>,
    ) -> VulnSummaryBuilder<vuln_summary_state::SetLow<St>, S> {
        self._fields.2 = Option::Some(value.into());
        VulnSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> VulnSummaryBuilder<St, S>
where
    St: vuln_summary_state::State,
    St::Medium: vuln_summary_state::IsUnset,
{
    /// Set the `medium` field (required)
    pub fn medium(
        mut self,
        value: impl Into<i64>,
    ) -> VulnSummaryBuilder<vuln_summary_state::SetMedium<St>, S> {
        self._fields.3 = Option::Some(value.into());
        VulnSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> VulnSummaryBuilder<St, S>
where
    St: vuln_summary_state::State,
    St::Total: vuln_summary_state::IsUnset,
{
    /// Set the `total` field (required)
    pub fn total(
        mut self,
        value: impl Into<i64>,
    ) -> VulnSummaryBuilder<vuln_summary_state::SetTotal<St>, S> {
        self._fields.4 = Option::Some(value.into());
        VulnSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> VulnSummaryBuilder<St, S>
where
    St: vuln_summary_state::State,
    St::Critical: vuln_summary_state::IsSet,
    St::High: vuln_summary_state::IsSet,
    St::Low: vuln_summary_state::IsSet,
    St::Medium: vuln_summary_state::IsSet,
    St::Total: vuln_summary_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> VulnSummary<S> {
        VulnSummary {
            critical: self._fields.0.unwrap(),
            high: self._fields.1.unwrap(),
            low: self._fields.2.unwrap(),
            medium: self._fields.3.unwrap(),
            total: 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>>,
    ) -> VulnSummary<S> {
        VulnSummary {
            critical: self._fields.0.unwrap(),
            high: self._fields.1.unwrap(),
            low: self._fields.2.unwrap(),
            medium: self._fields.3.unwrap(),
            total: self._fields.4.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}