pub struct ExpectationFailure {Show 13 fields
pub ok: False,
pub code: FailureCode,
pub message: String,
pub selector: Option<Selector>,
pub suggestions: Vec<String>,
pub visible_elements: Vec<ElementSummary>,
pub hint: Option<String>,
pub smix_version: String,
pub screenshot: Option<String>,
pub device_log: Vec<String>,
pub visible_total: Option<usize>,
pub windows: Vec<WindowInfo>,
pub unreadable_windows: Option<u32>,
}Expand description
Structured failure thrown by SDK matchers and driver calls. Shape is AI-feed-back-ready.
selector is the typed Selector rather than the wire
serde_json::Value — callers raising failures from the driver / SDK
side already have the typed selector, and to_prompt invokes
describe_selector for stable rendering.
Serializes as { ok: false, code, message, selector, suggestions, visibleElements, hint, screenshot, deviceLog }; the ok = false
discriminant identifies the failure branch of a Result wire.
Fields§
§ok: FalseAlways false for failures. Round-trip discriminator for
Result<T, ExpectationFailure> wire.
code: FailureCodeFailure code discriminator.
message: StringHuman-readable summary (and AI-readable when fed into to_prompt).
selector: Option<Selector>Originating selector, when one is available.
suggestions: Vec<String>Ranked near-miss suggestions (edit-distance to label / id / etc.).
visible_elements: Vec<ElementSummary>Snapshot of visible+enabled elements at failure time.
hint: Option<String>Optional one-line hint (e.g. “try app.wait_for(...) first”).
smix_version: StringThe smix that produced this failure.
Not decoration. A consumer wrote up two defects against smix behaviour that had been fixed hours earlier, quoting an error message the current build no longer emits — they had no way to tell whether the smix in front of them contained the fix for the thing they had just hit. A failure that names its version makes that answerable from the failure itself.
Set by ExpectationFailure::new from the crate version, so no
call site can forget it.
screenshot: Option<String>base64-encoded PNG; omitted from default rendering to keep logs lean.
device_log: Vec<String>Last-N-lines of captured device log, folded into AI-readable output for failure-window system context.
visible_total: Option<usize>How many elements visible_elements was cut from.
A list of ten read as the whole screen: a consumer built a detector on it that called every Android failure blind, because the ten were always the status bar. The total says it is a sample.
windows: Vec<WindowInfo>The windows the screen held when this failed, focused app first.
unreadable_windows: Option<u32>Windows the reader could not read. “The app is not in the tree” and “the app’s window could not be read” are different failures.
Implementations§
Source§impl ExpectationFailure
impl ExpectationFailure
Sourcepub fn new(init: FailureInit) -> Self
pub fn new(init: FailureInit) -> Self
Construct from an init struct. code defaults to DriverError
if init.code was None (defensive; SDK callers should always
set it).
Trait Implementations§
Source§impl Clone for ExpectationFailure
impl Clone for ExpectationFailure
Source§impl Debug for ExpectationFailure
impl Debug for ExpectationFailure
Source§impl<'de> Deserialize<'de> for ExpectationFailure
impl<'de> Deserialize<'de> for ExpectationFailure
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ExpectationFailure
impl Display for ExpectationFailure
Source§impl Error for ExpectationFailure
impl Error for ExpectationFailure
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()