#![allow(clippy::all)]
use std::fmt;
use std::str::FromStr;
#[rustfmt::skip]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum UiBridgeErrorCode {
UbActionFailed,
UbActionRejected,
UbActionTimeout,
UbAmbiguousMatch,
UbAssertContrast,
UbAssertElementMissing,
UbAssertLayout,
UbAssertTextMismatch,
UbAssertTimeout,
UbAssertVisibility,
UbElemBlocked,
UbElemDisabled,
UbElemNotEnabled,
UbElemNotFound,
UbElemNotInteractable,
UbElemNotVisible,
UbHealthEmptyContentArea,
UbHealthEmptyTextSignal,
UbHealthErrorTextSignal,
UbHealthLoadingClassSignal,
UbHealthLoadingTextSignal,
UbHealthLowElementDiversity,
UbHealthLowSpatialCoverage,
UbHealthManyDisabledInteractive,
UbHealthNoContentElements,
UbHealthOffScreenElement,
UbHealthSparseContent,
UbHealthZeroSizeElement,
UbLowConfidence,
UbMultipleElements,
UbNavigationError,
UbNetError,
UbPageLoadError,
UbParseError,
UbStaleElement,
UbStateNotReached,
UbUnexpectedState,
UbUnknownError,
UbUnsupportedAction,
UbValidationError,
UbVlmStructuredParseFail,
}
#[rustfmt::skip]
impl UiBridgeErrorCode {
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",
}
}
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())
}
}
#[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()
}
}