pub struct ExpectationFailure {
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 screenshot: Option<String>,
pub device_log: Vec<String>,
}Expand description
Structured failure thrown by SDK matchers and driver calls. Shape is AI-feed-back-ready (跟 TS ExpectationFailure 1:1).
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 with TS-shape (ok:false, code, message, selector, suggestions, visibleElements, hint, screenshot, deviceLog) — the
Ok = false discriminant matches mailrs serializedFailureSchema.
Fields§
§ok: FalseAlways false for failures (跟 TS line 107 z.literal(false)).
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”).
screenshot: Option<String>base64-encoded PNG; omitted from default rendering to keep logs lean.
device_log: Vec<String>v1.4 C5 — last-N-lines of captured device log, folded into AI-readable output for failure-window system context.
Implementations§
Source§impl ExpectationFailure
impl ExpectationFailure
Sourcepub fn new(init: FailureInit) -> Self
pub fn new(init: FailureInit) -> Self
Construct from an init struct (跟 TS new ExpectationFailure(init)
1:1). 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§fn clone(&self) -> ExpectationFailure
fn clone(&self) -> ExpectationFailure
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§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()