qontinui-types 0.6.0

Canonical DTO types for Qontinui. Rust is the source of truth; TypeScript and Python are generated from JSON Schema emitted by schemars.
Documentation
// @generated from diagnostics/codes.json — do not edit
//!
//! Canonical UI Bridge diagnostic code vocabulary.
//!
//! Source of truth: `ui-bridge/diagnostics/codes.json`. Regenerated by
//! `ui-bridge/scripts/gen-diagnostics.ts`. `FromStr` / `From<&str>` match
//! the canonical `UB-` strings ONLY — there is intentionally no
//! legacy-bare-string arm (single-user coordinated cutover, plan D1).
//!
//! Generated artifact: layout is owned by the generator, not `cargo fmt`.
//! Each item carries `#[rustfmt::skip]` (stable; file-level `#![rustfmt::skip]`
//! is nightly-only) so regen stays byte-stable and decoupled from rustfmt
//! line-width drift across toolchain versions.
#![allow(clippy::all)]

use std::fmt;
use std::str::FromStr;

#[rustfmt::skip]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum UiBridgeErrorCode {
    /// `UB-ACTION-FAILED`
    UbActionFailed,
    /// `UB-ACTION-REJECTED`
    UbActionRejected,
    /// `UB-ACTION-TIMEOUT`
    UbActionTimeout,
    /// `UB-AMBIGUOUS-MATCH`
    UbAmbiguousMatch,
    /// `UB-ASSERT-CONTRAST`
    UbAssertContrast,
    /// `UB-ASSERT-ELEMENT-MISSING`
    UbAssertElementMissing,
    /// `UB-ASSERT-LAYOUT`
    UbAssertLayout,
    /// `UB-ASSERT-TEXT-MISMATCH`
    UbAssertTextMismatch,
    /// `UB-ASSERT-TIMEOUT`
    UbAssertTimeout,
    /// `UB-ASSERT-VISIBILITY`
    UbAssertVisibility,
    /// `UB-ELEM-BLOCKED`
    UbElemBlocked,
    /// `UB-ELEM-DISABLED`
    UbElemDisabled,
    /// `UB-ELEM-NOT-ENABLED`
    UbElemNotEnabled,
    /// `UB-ELEM-NOT-FOUND`
    UbElemNotFound,
    /// `UB-ELEM-NOT-INTERACTABLE`
    UbElemNotInteractable,
    /// `UB-ELEM-NOT-VISIBLE`
    UbElemNotVisible,
    /// `UB-HEALTH-EMPTY-CONTENT-AREA`
    UbHealthEmptyContentArea,
    /// `UB-HEALTH-EMPTY-TEXT-SIGNAL`
    UbHealthEmptyTextSignal,
    /// `UB-HEALTH-ERROR-TEXT-SIGNAL`
    UbHealthErrorTextSignal,
    /// `UB-HEALTH-LOADING-CLASS-SIGNAL`
    UbHealthLoadingClassSignal,
    /// `UB-HEALTH-LOADING-TEXT-SIGNAL`
    UbHealthLoadingTextSignal,
    /// `UB-HEALTH-LOW-ELEMENT-DIVERSITY`
    UbHealthLowElementDiversity,
    /// `UB-HEALTH-LOW-SPATIAL-COVERAGE`
    UbHealthLowSpatialCoverage,
    /// `UB-HEALTH-MANY-DISABLED-INTERACTIVE`
    UbHealthManyDisabledInteractive,
    /// `UB-HEALTH-NO-CONTENT-ELEMENTS`
    UbHealthNoContentElements,
    /// `UB-HEALTH-OFF-SCREEN-ELEMENT`
    UbHealthOffScreenElement,
    /// `UB-HEALTH-SPARSE-CONTENT`
    UbHealthSparseContent,
    /// `UB-HEALTH-ZERO-SIZE-ELEMENT`
    UbHealthZeroSizeElement,
    /// `UB-LOW-CONFIDENCE`
    UbLowConfidence,
    /// `UB-MULTIPLE-ELEMENTS`
    UbMultipleElements,
    /// `UB-NAVIGATION-ERROR`
    UbNavigationError,
    /// `UB-NET-ERROR`
    UbNetError,
    /// `UB-PAGE-LOAD-ERROR`
    UbPageLoadError,
    /// `UB-PARSE-ERROR`
    UbParseError,
    /// `UB-STALE-ELEMENT`
    UbStaleElement,
    /// `UB-STATE-NOT-REACHED`
    UbStateNotReached,
    /// `UB-UNEXPECTED-STATE`
    UbUnexpectedState,
    /// `UB-UNKNOWN-ERROR`
    UbUnknownError,
    /// `UB-UNSUPPORTED-ACTION`
    UbUnsupportedAction,
    /// `UB-VALIDATION-ERROR`
    UbValidationError,
    /// `UB-VLM-STRUCTURED-PARSE-FAIL`
    UbVlmStructuredParseFail,
}

#[rustfmt::skip]
impl UiBridgeErrorCode {
    /// The canonical `UB-` wire string for this code.
    pub fn as_str(&self) -> &'static str {
        match self {
            UiBridgeErrorCode::UbActionFailed => "UB-ACTION-FAILED",
            UiBridgeErrorCode::UbActionRejected => "UB-ACTION-REJECTED",
            UiBridgeErrorCode::UbActionTimeout => "UB-ACTION-TIMEOUT",
            UiBridgeErrorCode::UbAmbiguousMatch => "UB-AMBIGUOUS-MATCH",
            UiBridgeErrorCode::UbAssertContrast => "UB-ASSERT-CONTRAST",
            UiBridgeErrorCode::UbAssertElementMissing => "UB-ASSERT-ELEMENT-MISSING",
            UiBridgeErrorCode::UbAssertLayout => "UB-ASSERT-LAYOUT",
            UiBridgeErrorCode::UbAssertTextMismatch => "UB-ASSERT-TEXT-MISMATCH",
            UiBridgeErrorCode::UbAssertTimeout => "UB-ASSERT-TIMEOUT",
            UiBridgeErrorCode::UbAssertVisibility => "UB-ASSERT-VISIBILITY",
            UiBridgeErrorCode::UbElemBlocked => "UB-ELEM-BLOCKED",
            UiBridgeErrorCode::UbElemDisabled => "UB-ELEM-DISABLED",
            UiBridgeErrorCode::UbElemNotEnabled => "UB-ELEM-NOT-ENABLED",
            UiBridgeErrorCode::UbElemNotFound => "UB-ELEM-NOT-FOUND",
            UiBridgeErrorCode::UbElemNotInteractable => "UB-ELEM-NOT-INTERACTABLE",
            UiBridgeErrorCode::UbElemNotVisible => "UB-ELEM-NOT-VISIBLE",
            UiBridgeErrorCode::UbHealthEmptyContentArea => "UB-HEALTH-EMPTY-CONTENT-AREA",
            UiBridgeErrorCode::UbHealthEmptyTextSignal => "UB-HEALTH-EMPTY-TEXT-SIGNAL",
            UiBridgeErrorCode::UbHealthErrorTextSignal => "UB-HEALTH-ERROR-TEXT-SIGNAL",
            UiBridgeErrorCode::UbHealthLoadingClassSignal => "UB-HEALTH-LOADING-CLASS-SIGNAL",
            UiBridgeErrorCode::UbHealthLoadingTextSignal => "UB-HEALTH-LOADING-TEXT-SIGNAL",
            UiBridgeErrorCode::UbHealthLowElementDiversity => "UB-HEALTH-LOW-ELEMENT-DIVERSITY",
            UiBridgeErrorCode::UbHealthLowSpatialCoverage => "UB-HEALTH-LOW-SPATIAL-COVERAGE",
            UiBridgeErrorCode::UbHealthManyDisabledInteractive => "UB-HEALTH-MANY-DISABLED-INTERACTIVE",
            UiBridgeErrorCode::UbHealthNoContentElements => "UB-HEALTH-NO-CONTENT-ELEMENTS",
            UiBridgeErrorCode::UbHealthOffScreenElement => "UB-HEALTH-OFF-SCREEN-ELEMENT",
            UiBridgeErrorCode::UbHealthSparseContent => "UB-HEALTH-SPARSE-CONTENT",
            UiBridgeErrorCode::UbHealthZeroSizeElement => "UB-HEALTH-ZERO-SIZE-ELEMENT",
            UiBridgeErrorCode::UbLowConfidence => "UB-LOW-CONFIDENCE",
            UiBridgeErrorCode::UbMultipleElements => "UB-MULTIPLE-ELEMENTS",
            UiBridgeErrorCode::UbNavigationError => "UB-NAVIGATION-ERROR",
            UiBridgeErrorCode::UbNetError => "UB-NET-ERROR",
            UiBridgeErrorCode::UbPageLoadError => "UB-PAGE-LOAD-ERROR",
            UiBridgeErrorCode::UbParseError => "UB-PARSE-ERROR",
            UiBridgeErrorCode::UbStaleElement => "UB-STALE-ELEMENT",
            UiBridgeErrorCode::UbStateNotReached => "UB-STATE-NOT-REACHED",
            UiBridgeErrorCode::UbUnexpectedState => "UB-UNEXPECTED-STATE",
            UiBridgeErrorCode::UbUnknownError => "UB-UNKNOWN-ERROR",
            UiBridgeErrorCode::UbUnsupportedAction => "UB-UNSUPPORTED-ACTION",
            UiBridgeErrorCode::UbValidationError => "UB-VALIDATION-ERROR",
            UiBridgeErrorCode::UbVlmStructuredParseFail => "UB-VLM-STRUCTURED-PARSE-FAIL",
        }
    }

    /// Every code, in stable sorted order.
    pub fn all() -> &'static [UiBridgeErrorCode] {
        &[
            UiBridgeErrorCode::UbActionFailed,
            UiBridgeErrorCode::UbActionRejected,
            UiBridgeErrorCode::UbActionTimeout,
            UiBridgeErrorCode::UbAmbiguousMatch,
            UiBridgeErrorCode::UbAssertContrast,
            UiBridgeErrorCode::UbAssertElementMissing,
            UiBridgeErrorCode::UbAssertLayout,
            UiBridgeErrorCode::UbAssertTextMismatch,
            UiBridgeErrorCode::UbAssertTimeout,
            UiBridgeErrorCode::UbAssertVisibility,
            UiBridgeErrorCode::UbElemBlocked,
            UiBridgeErrorCode::UbElemDisabled,
            UiBridgeErrorCode::UbElemNotEnabled,
            UiBridgeErrorCode::UbElemNotFound,
            UiBridgeErrorCode::UbElemNotInteractable,
            UiBridgeErrorCode::UbElemNotVisible,
            UiBridgeErrorCode::UbHealthEmptyContentArea,
            UiBridgeErrorCode::UbHealthEmptyTextSignal,
            UiBridgeErrorCode::UbHealthErrorTextSignal,
            UiBridgeErrorCode::UbHealthLoadingClassSignal,
            UiBridgeErrorCode::UbHealthLoadingTextSignal,
            UiBridgeErrorCode::UbHealthLowElementDiversity,
            UiBridgeErrorCode::UbHealthLowSpatialCoverage,
            UiBridgeErrorCode::UbHealthManyDisabledInteractive,
            UiBridgeErrorCode::UbHealthNoContentElements,
            UiBridgeErrorCode::UbHealthOffScreenElement,
            UiBridgeErrorCode::UbHealthSparseContent,
            UiBridgeErrorCode::UbHealthZeroSizeElement,
            UiBridgeErrorCode::UbLowConfidence,
            UiBridgeErrorCode::UbMultipleElements,
            UiBridgeErrorCode::UbNavigationError,
            UiBridgeErrorCode::UbNetError,
            UiBridgeErrorCode::UbPageLoadError,
            UiBridgeErrorCode::UbParseError,
            UiBridgeErrorCode::UbStaleElement,
            UiBridgeErrorCode::UbStateNotReached,
            UiBridgeErrorCode::UbUnexpectedState,
            UiBridgeErrorCode::UbUnknownError,
            UiBridgeErrorCode::UbUnsupportedAction,
            UiBridgeErrorCode::UbValidationError,
            UiBridgeErrorCode::UbVlmStructuredParseFail,
        ]
    }
}

impl fmt::Display for UiBridgeErrorCode {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str(self.as_str())
    }
}

/// Returned when a string is not a recognized canonical `UB-` code.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParseUiBridgeErrorCodeError(pub String);

impl fmt::Display for ParseUiBridgeErrorCodeError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "unrecognized UI Bridge diagnostic code: {}", self.0)
    }
}

impl std::error::Error for ParseUiBridgeErrorCodeError {}

#[rustfmt::skip]
impl FromStr for UiBridgeErrorCode {
    type Err = ParseUiBridgeErrorCodeError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "UB-ACTION-FAILED" => Ok(UiBridgeErrorCode::UbActionFailed),
            "UB-ACTION-REJECTED" => Ok(UiBridgeErrorCode::UbActionRejected),
            "UB-ACTION-TIMEOUT" => Ok(UiBridgeErrorCode::UbActionTimeout),
            "UB-AMBIGUOUS-MATCH" => Ok(UiBridgeErrorCode::UbAmbiguousMatch),
            "UB-ASSERT-CONTRAST" => Ok(UiBridgeErrorCode::UbAssertContrast),
            "UB-ASSERT-ELEMENT-MISSING" => Ok(UiBridgeErrorCode::UbAssertElementMissing),
            "UB-ASSERT-LAYOUT" => Ok(UiBridgeErrorCode::UbAssertLayout),
            "UB-ASSERT-TEXT-MISMATCH" => Ok(UiBridgeErrorCode::UbAssertTextMismatch),
            "UB-ASSERT-TIMEOUT" => Ok(UiBridgeErrorCode::UbAssertTimeout),
            "UB-ASSERT-VISIBILITY" => Ok(UiBridgeErrorCode::UbAssertVisibility),
            "UB-ELEM-BLOCKED" => Ok(UiBridgeErrorCode::UbElemBlocked),
            "UB-ELEM-DISABLED" => Ok(UiBridgeErrorCode::UbElemDisabled),
            "UB-ELEM-NOT-ENABLED" => Ok(UiBridgeErrorCode::UbElemNotEnabled),
            "UB-ELEM-NOT-FOUND" => Ok(UiBridgeErrorCode::UbElemNotFound),
            "UB-ELEM-NOT-INTERACTABLE" => Ok(UiBridgeErrorCode::UbElemNotInteractable),
            "UB-ELEM-NOT-VISIBLE" => Ok(UiBridgeErrorCode::UbElemNotVisible),
            "UB-HEALTH-EMPTY-CONTENT-AREA" => Ok(UiBridgeErrorCode::UbHealthEmptyContentArea),
            "UB-HEALTH-EMPTY-TEXT-SIGNAL" => Ok(UiBridgeErrorCode::UbHealthEmptyTextSignal),
            "UB-HEALTH-ERROR-TEXT-SIGNAL" => Ok(UiBridgeErrorCode::UbHealthErrorTextSignal),
            "UB-HEALTH-LOADING-CLASS-SIGNAL" => Ok(UiBridgeErrorCode::UbHealthLoadingClassSignal),
            "UB-HEALTH-LOADING-TEXT-SIGNAL" => Ok(UiBridgeErrorCode::UbHealthLoadingTextSignal),
            "UB-HEALTH-LOW-ELEMENT-DIVERSITY" => Ok(UiBridgeErrorCode::UbHealthLowElementDiversity),
            "UB-HEALTH-LOW-SPATIAL-COVERAGE" => Ok(UiBridgeErrorCode::UbHealthLowSpatialCoverage),
            "UB-HEALTH-MANY-DISABLED-INTERACTIVE" => Ok(UiBridgeErrorCode::UbHealthManyDisabledInteractive),
            "UB-HEALTH-NO-CONTENT-ELEMENTS" => Ok(UiBridgeErrorCode::UbHealthNoContentElements),
            "UB-HEALTH-OFF-SCREEN-ELEMENT" => Ok(UiBridgeErrorCode::UbHealthOffScreenElement),
            "UB-HEALTH-SPARSE-CONTENT" => Ok(UiBridgeErrorCode::UbHealthSparseContent),
            "UB-HEALTH-ZERO-SIZE-ELEMENT" => Ok(UiBridgeErrorCode::UbHealthZeroSizeElement),
            "UB-LOW-CONFIDENCE" => Ok(UiBridgeErrorCode::UbLowConfidence),
            "UB-MULTIPLE-ELEMENTS" => Ok(UiBridgeErrorCode::UbMultipleElements),
            "UB-NAVIGATION-ERROR" => Ok(UiBridgeErrorCode::UbNavigationError),
            "UB-NET-ERROR" => Ok(UiBridgeErrorCode::UbNetError),
            "UB-PAGE-LOAD-ERROR" => Ok(UiBridgeErrorCode::UbPageLoadError),
            "UB-PARSE-ERROR" => Ok(UiBridgeErrorCode::UbParseError),
            "UB-STALE-ELEMENT" => Ok(UiBridgeErrorCode::UbStaleElement),
            "UB-STATE-NOT-REACHED" => Ok(UiBridgeErrorCode::UbStateNotReached),
            "UB-UNEXPECTED-STATE" => Ok(UiBridgeErrorCode::UbUnexpectedState),
            "UB-UNKNOWN-ERROR" => Ok(UiBridgeErrorCode::UbUnknownError),
            "UB-UNSUPPORTED-ACTION" => Ok(UiBridgeErrorCode::UbUnsupportedAction),
            "UB-VALIDATION-ERROR" => Ok(UiBridgeErrorCode::UbValidationError),
            "UB-VLM-STRUCTURED-PARSE-FAIL" => Ok(UiBridgeErrorCode::UbVlmStructuredParseFail),
            other => Err(ParseUiBridgeErrorCodeError(other.to_string())),
        }
    }
}

impl<'a> TryFrom<&'a str> for UiBridgeErrorCode {
    type Error = ParseUiBridgeErrorCodeError;
    fn try_from(s: &'a str) -> Result<Self, Self::Error> {
        s.parse()
    }
}