Skip to main content

ExpectationFailure

Struct ExpectationFailure 

Source
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: False

Always false for failures. Round-trip discriminator for Result<T, ExpectationFailure> wire.

§code: FailureCode

Failure code discriminator.

§message: String

Human-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: String

The 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

Source

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).

Source

pub fn to_prompt(&self) -> String

AI-facing rendering. Designed so the output can be pasted back as a user message into a coding agent.

Trait Implementations§

Source§

impl Clone for ExpectationFailure

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExpectationFailure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ExpectationFailure

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ExpectationFailure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ExpectationFailure

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl Serialize for ExpectationFailure

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.