#[non_exhaustive]pub struct SettleState {
pub outcome: SettleOutcome,
pub elapsed_ms: f64,
pub text_length: Option<u64>,
pub navigations: u32,
pub http_status: Option<u16>,
pub reason: String,
pub via: SettleVia,
}Expand description
The result of a wait.
Built by SettleWatch::wait and by SettleState::from_reply; the
fields a fallback cannot know (text_length, http_status) are None
there rather than zero, because “0 characters” and “we never asked” are
different answers and only one of them is a reason to retry.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.outcome: SettleOutcomeWhat the browser concluded.
elapsed_ms: f64Milliseconds the navigation took, from the browser’s own clock when the browser answered, and from the main frame’s lifecycle timestamps when the fallback did.
text_length: Option<u64>Rendered-text length at settle. None on a fallback, which never
sampled the text.
Navigations the watch saw — a redirect chain counts more than one.
http_status: Option<u16>The committed document’s HTTP status. None on a fallback.
reason: StringThe browser’s own free-form explanation, or this client’s when it fell back. Match on it defensively; the set grows.
via: SettleViaWhich signal produced this answer.
Implementations§
Source§impl SettleState
impl SettleState
Sourcepub fn blocked(&self) -> bool
pub fn blocked(&self) -> bool
The classification callers need: a bot wall, or a status that is one.
Two ways to meet the same wall, and a caller that checks only the first
misses the short ones: a challenge page shorter than
--page-settle-min-chars reports SettleOutcome::Timeout, and only
SettleState::http_status gives it away.
let short_wall = SettleState::from_reply(
&json!({"outcome": "timeout", "httpStatus": 403, "elapsedMs": 30000.0}),
).unwrap();
assert!(short_wall.blocked());Sourcepub fn is_settled(&self) -> bool
pub fn is_settled(&self) -> bool
Some signal reported completion, and it was not a wall.
A challenge page settles beautifully — that is what makes it a good
challenge page — so SettleState::blocked is folded in here rather
than left for the caller to remember. The sibling clients spell this
settled.
Sourcepub fn from_reply(reply: &Value) -> Option<SettleState>
pub fn from_reply(reply: &Value) -> Option<SettleState>
Parse a Chromeleon.waitForSettle reply.
Takes the command’s result object, and also the whole CDP envelope
— a raw WebSocket hands you the latter, and looking one level down for
the outcome is cheaper than making every caller unwrap it. None when
there is no outcome at all, which is what an error envelope and an
unrelated reply both look like.
Unknown members are ignored and missing ones read as absent, the same
tolerance CaptchaEvent::parse
applies: a client that hard-fails on payload drift turns a working
navigation into a crash.