// @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;
use jacquard_common::deps::bytes::Bytes;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::string::{Did, UriValue};
use jacquard_derive::{IntoStatic, lexicon, 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")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum SubscribeScanJobsMessage<'a> {
    #[serde(rename = "#scanJob")]
    ScanJob(Box<subscribe_scan_jobs::ScanJob<'a>>),
    #[serde(rename = "#scanResult")]
    ScanResult(Box<subscribe_scan_jobs::ScanResult<'a>>),
}

impl<'a> SubscribeScanJobsMessage<'a> {
    /// Decode a framed DAG-CBOR message (header + body).
    pub fn decode_framed<'de: 'a>(
        bytes: &'de [u8],
    ) -> Result<SubscribeScanJobsMessage<'a>, jacquard_common::error::DecodeError> {
        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()),
                )
            }
        }
    }
}


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

#[serde(tag = "error", content = "message")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum SubscribeScanJobsError<'a> {
    /// Scanner shared secret is invalid
    #[serde(rename = "InvalidSecret")]
    InvalidSecret(Option<CowStr<'a>>),
}

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::Unknown(err) => write!(f, "Unknown error: {:?}", err),
        }
    }
}

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

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

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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ScanResult<'a> {
    ///Manifest digest that was scanned
    #[serde(borrow)]
    pub digest: CowStr<'a>,
    ///Error message if scan failed
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub error: Option<CowStr<'a>>,
    ///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")]
    #[serde(borrow)]
    pub scanner_version: Option<CowStr<'a>>,
    ///Vulnerability count summary
    #[serde(borrow)]
    pub summary: subscribe_scan_jobs::VulnSummary<'a>,
    ///Message type discriminator
    #[serde(borrow)]
    pub r#type: CowStr<'a>,
    ///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>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct VulnSummary<'a> {
    ///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,
}

///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<'de> = SubscribeScanJobsMessage<'de>;
    type Error<'de> = SubscribeScanJobsError<'de>;
}

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<'de> = SubscribeScanJobs;
    type Stream = SubscribeScanJobsStream;
}

impl<'a> LexiconSchema for ScanJob<'a> {
    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<'a> LexiconSchema for ScanResult<'a> {
    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<'a> LexiconSchema for VulnSummary<'a> {
    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<S: subscribe_scan_jobs_state::State> {
    _state: PhantomData<fn() -> S>,
    _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
    pub fn new() -> Self {
        SubscribeScanJobsBuilder {
            _state: PhantomData,
            _fields: (None,),
        }
    }
}

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

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

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

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

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

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

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

impl<'a, S: scan_job_state::State> ScanJobBuilder<'a, 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<'a, S> ScanJobBuilder<'a, S>
where
    S: scan_job_state::State,
    S::Repository: scan_job_state::IsUnset,
{
    /// Set the `repository` field (required)
    pub fn repository(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ScanJobBuilder<'a, scan_job_state::SetRepository<S>> {
        self._fields.4 = Option::Some(value.into());
        ScanJobBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

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

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

impl<'a, S> ScanJobBuilder<'a, S>
where
    S: scan_job_state::State,
    S::HoldEndpoint: scan_job_state::IsSet,
    S::UserDid: scan_job_state::IsSet,
    S::Seq: scan_job_state::IsSet,
    S::Repository: scan_job_state::IsSet,
    S::Type: scan_job_state::IsSet,
    S::Digest: scan_job_state::IsSet,
    S::HoldDid: scan_job_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ScanJob<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ScanJob<'a> {
        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 Summary;
        type Digest;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Summary = Unset;
        type Digest = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `summary` field to Set
    pub struct SetSummary<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSummary<S> {}
    impl<S: State> State for SetSummary<S> {
        type Summary = Set<members::summary>;
        type Digest = S::Digest;
        type Type = S::Type;
    }
    ///State transition - sets the `digest` field to Set
    pub struct SetDigest<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDigest<S> {}
    impl<S: State> State for SetDigest<S> {
        type Summary = S::Summary;
        type Digest = Set<members::digest>;
        type Type = S::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetType<S> {}
    impl<S: State> State for SetType<S> {
        type Summary = S::Summary;
        type Digest = S::Digest;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `summary` field
        pub struct summary(());
        ///Marker type for the `digest` field
        pub struct digest(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

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

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

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

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

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

impl<'a, S: scan_result_state::State> ScanResultBuilder<'a, 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<'a, S: scan_result_state::State> ScanResultBuilder<'a, S> {
    /// Set the `scannerVersion` field (optional)
    pub fn scanner_version(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

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

impl<'a, S: scan_result_state::State> ScanResultBuilder<'a, 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<'a, S> ScanResultBuilder<'a, S>
where
    S: scan_result_state::State,
    S::Summary: scan_result_state::IsSet,
    S::Digest: scan_result_state::IsSet,
    S::Type: scan_result_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ScanResult<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> ScanResult<'a> {
        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 High;
        type Medium;
        type Total;
        type Critical;
        type Low;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type High = Unset;
        type Medium = Unset;
        type Total = Unset;
        type Critical = Unset;
        type Low = Unset;
    }
    ///State transition - sets the `high` field to Set
    pub struct SetHigh<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHigh<S> {}
    impl<S: State> State for SetHigh<S> {
        type High = Set<members::high>;
        type Medium = S::Medium;
        type Total = S::Total;
        type Critical = S::Critical;
        type Low = S::Low;
    }
    ///State transition - sets the `medium` field to Set
    pub struct SetMedium<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMedium<S> {}
    impl<S: State> State for SetMedium<S> {
        type High = S::High;
        type Medium = Set<members::medium>;
        type Total = S::Total;
        type Critical = S::Critical;
        type Low = S::Low;
    }
    ///State transition - sets the `total` field to Set
    pub struct SetTotal<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTotal<S> {}
    impl<S: State> State for SetTotal<S> {
        type High = S::High;
        type Medium = S::Medium;
        type Total = Set<members::total>;
        type Critical = S::Critical;
        type Low = S::Low;
    }
    ///State transition - sets the `critical` field to Set
    pub struct SetCritical<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCritical<S> {}
    impl<S: State> State for SetCritical<S> {
        type High = S::High;
        type Medium = S::Medium;
        type Total = S::Total;
        type Critical = Set<members::critical>;
        type Low = S::Low;
    }
    ///State transition - sets the `low` field to Set
    pub struct SetLow<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLow<S> {}
    impl<S: State> State for SetLow<S> {
        type High = S::High;
        type Medium = S::Medium;
        type Total = S::Total;
        type Critical = S::Critical;
        type Low = Set<members::low>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `high` field
        pub struct high(());
        ///Marker type for the `medium` field
        pub struct medium(());
        ///Marker type for the `total` field
        pub struct total(());
        ///Marker type for the `critical` field
        pub struct critical(());
        ///Marker type for the `low` field
        pub struct low(());
    }
}

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

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

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

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

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

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

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

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

impl<'a, S> VulnSummaryBuilder<'a, S>
where
    S: vuln_summary_state::State,
    S::High: vuln_summary_state::IsSet,
    S::Medium: vuln_summary_state::IsSet,
    S::Total: vuln_summary_state::IsSet,
    S::Critical: vuln_summary_state::IsSet,
    S::Low: vuln_summary_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> VulnSummary<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> VulnSummary<'a> {
        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),
        }
    }
}