Skip to main content

SettleState

Struct SettleState 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§outcome: SettleOutcome

What the browser concluded.

§elapsed_ms: f64

Milliseconds 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: u32

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

The browser’s own free-form explanation, or this client’s when it fell back. Match on it defensively; the set grows.

§via: SettleVia

Which signal produced this answer.

Implementations§

Source§

impl SettleState

Source

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());
Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for SettleState

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 SettleState

Source§

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

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

impl PartialEq for SettleState

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SettleState

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSendSync for T

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more