// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.gainforest.evaluator.defs
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

//! Generated bindings for the `app.gainforest.evaluator` Lexicon namespace/module.
pub mod evaluation;
pub mod service;
pub mod subscription;


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

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

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_gainforest::evaluator;
/// A candidate taxon identification with confidence score and rank.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct CandidateTaxon<S: BosStr = DefaultStr> {
    ///Confidence score (0-1000, where 1000 = 100.0%).
    pub confidence: i64,
    ///Family of the candidate taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub family: Option<S>,
    ///GBIF backbone taxonomy key for the candidate.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub gbif_taxon_key: Option<S>,
    ///Genus of the candidate taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub genus: Option<S>,
    ///Kingdom of the candidate taxon.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kingdom: Option<S>,
    ///Rank position among candidates (1 = best match).
    pub rank: i64,
    ///Full scientific name of the candidate taxon.
    pub scientific_name: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Generic categorical classification result (e.g., conservation priority, habitat type).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ClassificationResult<S: BosStr = DefaultStr> {
    ///The classification category (e.g., 'conservation-priority', 'habitat-type').
    pub category: S,
    ///Additional notes about the classification.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remarks: Option<S>,
    ///The assigned classification value (e.g., 'critical', 'tropical-rainforest').
    pub value: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Data quality assessment result with per-field quality flags.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DataQualityResult<S: BosStr = DefaultStr> {
    ///Overall completeness score (0-1000, where 1000 = 100.0%).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub completeness_score: Option<i64>,
    ///List of quality issues found in the record.
    pub flags: Vec<evaluator::QualityFlag<S>>,
    ///Additional notes about the quality assessment.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remarks: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A single measurement derived by an evaluator from source data.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct DerivedMeasurement<S: BosStr = DefaultStr> {
    ///Description of the method used to obtain the measurement.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_method: Option<S>,
    ///The nature of the measurement (e.g., 'canopy cover', 'NDVI', 'tree height').
    pub measurement_type: S,
    ///The units for the measurement value (e.g., '%', 'm', 'kg').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measurement_unit: Option<S>,
    ///The value of the measurement.
    pub measurement_value: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Derived measurements produced by an evaluator from source data (e.g., remote sensing metrics).

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct MeasurementResult<S: BosStr = DefaultStr> {
    ///List of derived measurements.
    pub measurements: Vec<evaluator::DerivedMeasurement<S>>,
    ///Additional notes about the measurements.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remarks: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Provenance metadata describing the method used to produce an evaluation.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct MethodInfo<S: BosStr = DefaultStr> {
    ///Identifier for the specific model checkpoint used (e.g., date or hash).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub model_checkpoint: Option<S>,
    ///Human-readable name of the method or model (e.g., 'GainForest BioClassifier').
    pub name: S,
    ///URIs to papers, documentation, or repositories describing this method.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub references: Option<Vec<UriValue<S>>>,
    ///Version string of the method or model (e.g., '2.1.0').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub version: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// A single data quality flag indicating an issue with a specific field.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct QualityFlag<S: BosStr = DefaultStr> {
    ///The field name that has the quality issue.
    pub field: S,
    ///Description of the quality issue.
    pub issue: S,
    ///Severity level of the quality issue.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub severity: Option<QualityFlagSeverity<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Severity level of the quality issue.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum QualityFlagSeverity<S: BosStr = DefaultStr> {
    Error,
    Warning,
    Info,
    Other(S),
}

impl<S: BosStr> QualityFlagSeverity<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Error => "error",
            Self::Warning => "warning",
            Self::Info => "info",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "error" => Self::Error,
            "warning" => Self::Warning,
            "info" => Self::Info,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for QualityFlagSeverity<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for QualityFlagSeverity<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for QualityFlagSeverity<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for QualityFlagSeverity<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for QualityFlagSeverity<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for QualityFlagSeverity<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = QualityFlagSeverity<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            QualityFlagSeverity::Error => QualityFlagSeverity::Error,
            QualityFlagSeverity::Warning => QualityFlagSeverity::Warning,
            QualityFlagSeverity::Info => QualityFlagSeverity::Info,
            QualityFlagSeverity::Other(v) => QualityFlagSeverity::Other(v.into_static()),
        }
    }
}

/// AI or human species recognition result with ranked candidate identifications.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SpeciesIdResult<S: BosStr = DefaultStr> {
    ///Ranked list of candidate species identifications.
    pub candidates: Vec<evaluator::CandidateTaxon<S>>,
    ///Which feature of the subject record was used as input (e.g., 'mediaEvidence').
    #[serde(skip_serializing_if = "Option::is_none")]
    pub input_feature: Option<S>,
    ///Additional notes about the species identification.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remarks: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Reference to a target record that is being evaluated.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct SubjectRef<S: BosStr = DefaultStr> {
    ///CID pinning the exact version of the target record.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    ///AT-URI of the target record.
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Expert verification result for a previous identification or evaluation.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct VerificationResult<S: BosStr = DefaultStr> {
    ///Notes about the verification decision.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remarks: Option<S>,
    ///Verification status: confirmed, rejected, or uncertain.
    pub status: VerificationResultStatus<S>,
    ///Suggested corrections if the original identification was rejected or uncertain.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub suggested_corrections: Option<S>,
    ///Name of the person who performed the verification.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub verified_by: Option<S>,
    ///Persistent identifier (e.g., ORCID) of the verifier.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub verified_by_id: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Verification status: confirmed, rejected, or uncertain.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VerificationResultStatus<S: BosStr = DefaultStr> {
    Confirmed,
    Rejected,
    Uncertain,
    Other(S),
}

impl<S: BosStr> VerificationResultStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Confirmed => "confirmed",
            Self::Rejected => "rejected",
            Self::Uncertain => "uncertain",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "confirmed" => Self::Confirmed,
            "rejected" => Self::Rejected,
            "uncertain" => Self::Uncertain,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for VerificationResultStatus<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for VerificationResultStatus<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for VerificationResultStatus<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for VerificationResultStatus<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for VerificationResultStatus<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for VerificationResultStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = VerificationResultStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            VerificationResultStatus::Confirmed => VerificationResultStatus::Confirmed,
            VerificationResultStatus::Rejected => VerificationResultStatus::Rejected,
            VerificationResultStatus::Uncertain => VerificationResultStatus::Uncertain,
            VerificationResultStatus::Other(v) => {
                VerificationResultStatus::Other(v.into_static())
            }
        }
    }
}

impl<S: BosStr> LexiconSchema for CandidateTaxon<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "candidateTaxon"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.confidence;
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("confidence"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.confidence;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("confidence"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.family {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("family"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.gbif_taxon_key {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("gbif_taxon_key"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.genus {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("genus"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.kingdom {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("kingdom"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.rank;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("rank"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.scientific_name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 512usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("scientific_name"),
                        max: 512usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ClassificationResult<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "classificationResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.category;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("category"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.value;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("value"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DataQualityResult<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "dataQualityResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.completeness_score {
            if *value > 1000i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("completeness_score"),
                    max: 1000i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.completeness_score {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("completeness_score"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.flags;
            #[allow(unused_comparisons)]
            if value.len() > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("flags"),
                    max: 50usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for DerivedMeasurement<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "derivedMeasurement"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.measurement_method {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_method"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.measurement_type;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_type"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.measurement_unit {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_unit"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.measurement_value;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 1024usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("measurement_value"),
                        max: 1024usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for MeasurementResult<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "measurementResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.measurements;
            #[allow(unused_comparisons)]
            if value.len() > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("measurements"),
                    max: 20usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for MethodInfo<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "methodInfo"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.model_checkpoint {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 128usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("model_checkpoint"),
                        max: 128usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.name;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.references {
            #[allow(unused_comparisons)]
            if value.len() > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("references"),
                    max: 10usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.version {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("version"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for QualityFlag<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "qualityFlag"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.field;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("field"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.issue;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("issue"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.severity {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("severity"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SpeciesIdResult<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "speciesIdResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.candidates;
            #[allow(unused_comparisons)]
            if value.len() > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("candidates"),
                    max: 20usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.input_feature {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("input_feature"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for SubjectRef<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "subjectRef"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for VerificationResult<S> {
    fn nsid() -> &'static str {
        "app.gainforest.evaluator.defs"
    }
    fn def_name() -> &'static str {
        "verificationResult"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_gainforest_evaluator_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.remarks {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 2048usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("remarks"),
                        max: 2048usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.status;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("status"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.suggested_corrections {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 5000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("suggested_corrections"),
                        max: 5000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.verified_by {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("verified_by"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.verified_by_id {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 256usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("verified_by_id"),
                        max: 256usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

pub mod candidate_taxon_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 Confidence;
        type Rank;
        type ScientificName;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Confidence = Unset;
        type Rank = Unset;
        type ScientificName = Unset;
    }
    ///State transition - sets the `confidence` field to Set
    pub struct SetConfidence<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetConfidence<St> {}
    impl<St: State> State for SetConfidence<St> {
        type Confidence = Set<members::confidence>;
        type Rank = St::Rank;
        type ScientificName = St::ScientificName;
    }
    ///State transition - sets the `rank` field to Set
    pub struct SetRank<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRank<St> {}
    impl<St: State> State for SetRank<St> {
        type Confidence = St::Confidence;
        type Rank = Set<members::rank>;
        type ScientificName = St::ScientificName;
    }
    ///State transition - sets the `scientific_name` field to Set
    pub struct SetScientificName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetScientificName<St> {}
    impl<St: State> State for SetScientificName<St> {
        type Confidence = St::Confidence;
        type Rank = St::Rank;
        type ScientificName = Set<members::scientific_name>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `confidence` field
        pub struct confidence(());
        ///Marker type for the `rank` field
        pub struct rank(());
        ///Marker type for the `scientific_name` field
        pub struct scientific_name(());
    }
}

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

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

impl<S: BosStr> CandidateTaxon<S> {
    /// Create a new builder for this type
    pub fn builder() -> CandidateTaxonBuilder<candidate_taxon_state::Empty, S> {
        CandidateTaxonBuilder::builder()
    }
}

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

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

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

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

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

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

impl<St: candidate_taxon_state::State, S: BosStr> CandidateTaxonBuilder<St, S> {
    /// Set the `kingdom` field (optional)
    pub fn kingdom(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `kingdom` field to an Option value (optional)
    pub fn maybe_kingdom(mut self, value: Option<S>) -> Self {
        self._fields.4 = value;
        self
    }
}

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

impl<St, S: BosStr> CandidateTaxonBuilder<St, S>
where
    St: candidate_taxon_state::State,
    St::ScientificName: candidate_taxon_state::IsUnset,
{
    /// Set the `scientificName` field (required)
    pub fn scientific_name(
        mut self,
        value: impl Into<S>,
    ) -> CandidateTaxonBuilder<candidate_taxon_state::SetScientificName<St>, S> {
        self._fields.6 = Option::Some(value.into());
        CandidateTaxonBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CandidateTaxonBuilder<St, S>
where
    St: candidate_taxon_state::State,
    St::Confidence: candidate_taxon_state::IsSet,
    St::Rank: candidate_taxon_state::IsSet,
    St::ScientificName: candidate_taxon_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> CandidateTaxon<S> {
        CandidateTaxon {
            confidence: self._fields.0.unwrap(),
            family: self._fields.1,
            gbif_taxon_key: self._fields.2,
            genus: self._fields.3,
            kingdom: self._fields.4,
            rank: self._fields.5.unwrap(),
            scientific_name: self._fields.6.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>>,
    ) -> CandidateTaxon<S> {
        CandidateTaxon {
            confidence: self._fields.0.unwrap(),
            family: self._fields.1,
            gbif_taxon_key: self._fields.2,
            genus: self._fields.3,
            kingdom: self._fields.4,
            rank: self._fields.5.unwrap(),
            scientific_name: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_gainforest_evaluator_defs() -> 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("app.gainforest.evaluator.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("candidateTaxon"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A candidate taxon identification with confidence score and rank.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("scientificName"),
                            SmolStr::new_static("confidence"),
                            SmolStr::new_static("rank")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("confidence"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(1000i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("family"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Family of the candidate taxon."),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("gbifTaxonKey"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "GBIF backbone taxonomy key for the candidate.",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("genus"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Genus of the candidate taxon."),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("kingdom"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Kingdom of the candidate taxon."),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rank"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("scientificName"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Full scientific name of the candidate taxon.",
                                    ),
                                ),
                                max_graphemes: Some(512usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("classificationResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Generic categorical classification result (e.g., conservation priority, habitat type).",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("category"), SmolStr::new_static("value")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("category"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The classification category (e.g., 'conservation-priority', 'habitat-type').",
                                    ),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the classification.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The assigned classification value (e.g., 'critical', 'tropical-rainforest').",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("dataQualityResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Data quality assessment result with per-field quality flags.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("flags")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("completenessScore"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(1000i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("flags"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of quality issues found in the record.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#qualityFlag"),
                                    ..Default::default()
                                }),
                                max_length: Some(50usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the quality assessment.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("derivedMeasurement"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single measurement derived by an evaluator from source data.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("measurementType"),
                            SmolStr::new_static("measurementValue")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("measurementMethod"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Description of the method used to obtain the measurement.",
                                    ),
                                ),
                                max_graphemes: Some(1024usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measurementType"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The nature of the measurement (e.g., 'canopy cover', 'NDVI', 'tree height').",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measurementUnit"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The units for the measurement value (e.g., '%', 'm', 'kg').",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measurementValue"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The value of the measurement."),
                                ),
                                max_graphemes: Some(1024usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("measurementResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Derived measurements produced by an evaluator from source data (e.g., remote sensing metrics).",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("measurements")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("measurements"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("List of derived measurements."),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#derivedMeasurement"),
                                    ..Default::default()
                                }),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the measurements.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("methodInfo"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Provenance metadata describing the method used to produce an evaluation.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("name")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("modelCheckpoint"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Identifier for the specific model checkpoint used (e.g., date or hash).",
                                    ),
                                ),
                                max_graphemes: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Human-readable name of the method or model (e.g., 'GainForest BioClassifier').",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("references"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "URIs to papers, documentation, or repositories describing this method.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                                max_length: Some(10usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("version"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Version string of the method or model (e.g., '2.1.0').",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("qualityFlag"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "A single data quality flag indicating an issue with a specific field.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("field"), SmolStr::new_static("issue")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("field"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "The field name that has the quality issue.",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("issue"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Description of the quality issue."),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("severity"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Severity level of the quality issue."),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("speciesIdResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "AI or human species recognition result with ranked candidate identifications.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("candidates")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("candidates"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Ranked list of candidate species identifications.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#candidateTaxon"),
                                    ..Default::default()
                                }),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("inputFeature"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Which feature of the subject record was used as input (e.g., 'mediaEvidence').",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Additional notes about the species identification.",
                                    ),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("subjectRef"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Reference to a target record that is being evaluated.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("uri")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "CID pinning the exact version of the target record.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("AT-URI of the target record."),
                                ),
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("verificationResult"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Expert verification result for a previous identification or evaluation.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("status")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("remarks"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Notes about the verification decision."),
                                ),
                                max_graphemes: Some(2048usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Verification status: confirmed, rejected, or uncertain.",
                                    ),
                                ),
                                max_graphemes: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("suggestedCorrections"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Suggested corrections if the original identification was rejected or uncertain.",
                                    ),
                                ),
                                max_graphemes: Some(5000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("verifiedBy"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Name of the person who performed the verification.",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("verifiedByID"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Persistent identifier (e.g., ORCID) of the verifier.",
                                    ),
                                ),
                                max_graphemes: Some(256usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

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

impl<S: BosStr> DataQualityResult<S> {
    /// Create a new builder for this type
    pub fn builder() -> DataQualityResultBuilder<data_quality_result_state::Empty, S> {
        DataQualityResultBuilder::builder()
    }
}

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

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

impl<St: data_quality_result_state::State, S: BosStr> DataQualityResultBuilder<St, S> {
    /// Set the `completenessScore` field (optional)
    pub fn completeness_score(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `completenessScore` field to an Option value (optional)
    pub fn maybe_completeness_score(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> DataQualityResultBuilder<St, S>
where
    St: data_quality_result_state::State,
    St::Flags: data_quality_result_state::IsUnset,
{
    /// Set the `flags` field (required)
    pub fn flags(
        mut self,
        value: impl Into<Vec<evaluator::QualityFlag<S>>>,
    ) -> DataQualityResultBuilder<data_quality_result_state::SetFlags<St>, S> {
        self._fields.1 = Option::Some(value.into());
        DataQualityResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> DataQualityResultBuilder<St, S>
where
    St: data_quality_result_state::State,
    St::Flags: data_quality_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> DataQualityResult<S> {
        DataQualityResult {
            completeness_score: self._fields.0,
            flags: self._fields.1.unwrap(),
            remarks: self._fields.2,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> DataQualityResult<S> {
        DataQualityResult {
            completeness_score: self._fields.0,
            flags: self._fields.1.unwrap(),
            remarks: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> MeasurementResult<S> {
    /// Create a new builder for this type
    pub fn builder() -> MeasurementResultBuilder<measurement_result_state::Empty, S> {
        MeasurementResultBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> MeasurementResultBuilder<St, S>
where
    St: measurement_result_state::State,
    St::Measurements: measurement_result_state::IsUnset,
{
    /// Set the `measurements` field (required)
    pub fn measurements(
        mut self,
        value: impl Into<Vec<evaluator::DerivedMeasurement<S>>>,
    ) -> MeasurementResultBuilder<measurement_result_state::SetMeasurements<St>, S> {
        self._fields.0 = Option::Some(value.into());
        MeasurementResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> MeasurementResultBuilder<St, S>
where
    St: measurement_result_state::State,
    St::Measurements: measurement_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> MeasurementResult<S> {
        MeasurementResult {
            measurements: self._fields.0.unwrap(),
            remarks: self._fields.1,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> MeasurementResult<S> {
        MeasurementResult {
            measurements: self._fields.0.unwrap(),
            remarks: self._fields.1,
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> SpeciesIdResult<S> {
    /// Create a new builder for this type
    pub fn builder() -> SpeciesIdResultBuilder<species_id_result_state::Empty, S> {
        SpeciesIdResultBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> SpeciesIdResultBuilder<St, S>
where
    St: species_id_result_state::State,
    St::Candidates: species_id_result_state::IsUnset,
{
    /// Set the `candidates` field (required)
    pub fn candidates(
        mut self,
        value: impl Into<Vec<evaluator::CandidateTaxon<S>>>,
    ) -> SpeciesIdResultBuilder<species_id_result_state::SetCandidates<St>, S> {
        self._fields.0 = Option::Some(value.into());
        SpeciesIdResultBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St, S: BosStr> SpeciesIdResultBuilder<St, S>
where
    St: species_id_result_state::State,
    St::Candidates: species_id_result_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SpeciesIdResult<S> {
        SpeciesIdResult {
            candidates: self._fields.0.unwrap(),
            input_feature: self._fields.1,
            remarks: self._fields.2,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> SpeciesIdResult<S> {
        SpeciesIdResult {
            candidates: self._fields.0.unwrap(),
            input_feature: self._fields.1,
            remarks: self._fields.2,
            extra_data: Some(extra_data),
        }
    }
}

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

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

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

impl<S: BosStr> SubjectRef<S> {
    /// Create a new builder for this type
    pub fn builder() -> SubjectRefBuilder<subject_ref_state::Empty, S> {
        SubjectRefBuilder::builder()
    }
}

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

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

impl<St: subject_ref_state::State, S: BosStr> SubjectRefBuilder<St, S> {
    /// Set the `cid` field (optional)
    pub fn cid(mut self, value: impl Into<Option<Cid<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cid` field to an Option value (optional)
    pub fn maybe_cid(mut self, value: Option<Cid<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St, S: BosStr> SubjectRefBuilder<St, S>
where
    St: subject_ref_state::State,
    St::Uri: subject_ref_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> SubjectRefBuilder<subject_ref_state::SetUri<St>, S> {
        self._fields.1 = Option::Some(value.into());
        SubjectRefBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> SubjectRefBuilder<St, S>
where
    St: subject_ref_state::State,
    St::Uri: subject_ref_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> SubjectRef<S> {
        SubjectRef {
            cid: self._fields.0,
            uri: self._fields.1.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>>,
    ) -> SubjectRef<S> {
        SubjectRef {
            cid: self._fields.0,
            uri: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}