Skip to main content

PageSignature

Struct PageSignature 

Source
pub struct PageSignature {
    pub url: String,
    pub status_code: Option<u16>,
    pub body_markers: Vec<String>,
    pub header_set: Vec<String>,
    pub redirect_url: Option<String>,
    pub queue_position_hint: Option<u32>,
    pub vendor_hint: Option<String>,
}
Expand description

Page signature consumed by the InterstitialClassifier.

The signature is the observation that a previous acquisition attempt produced. Callers attach the signature to an AcquisitionRequest via the AcquisitionRequest::interstitial field (see mod.rs for the runner integration).

§Example

use stygian_browser::interstitial_router::PageSignature;

let signature = PageSignature::new(
    "https://example.com/cdn-cgi/challenge-platform/h/b",
    Some(403),
)
.with_body_marker("cf-chl-bypass")
.with_header("cf-mitigated");
assert_eq!(signature.body_markers.len(), 1);
assert_eq!(signature.header_set.len(), 1);

Fields§

§url: String

Target URL of the page.

§status_code: Option<u16>

HTTP status code, when known.

§body_markers: Vec<String>

Body substrings (case-insensitive) observed in the page. Markers are normalised to lower-case ASCII.

§header_set: Vec<String>

Lower-case ASCII header names observed in the response.

§redirect_url: Option<String>

Optional redirect target for a 3xx response.

§queue_position_hint: Option<u32>

Optional queue position hint (1-based).

§vendor_hint: Option<String>

Optional vendor hint (e.g. cloudflare, akamai).

Implementations§

Source§

impl PageSignature

Source

pub fn new(url: impl Into<String>, status_code: Option<u16>) -> Self

Build a signature with the supplied url and status_code and no other fields set.

Source

pub fn with_body_marker(self, marker: impl Into<String>) -> Self

Builder: add a body marker (case-insensitive). The marker is trimmed and lower-cased; empty markers are ignored.

Source

pub fn with_header(self, header: impl Into<String>) -> Self

Builder: add a header name (case-insensitive). The name is trimmed and lower-cased; empty names are ignored.

Source

pub fn with_redirect_url(self, redirect_url: impl Into<String>) -> Self

Builder: set the redirect target.

Source

pub const fn with_queue_position(self, position: u32) -> Self

Builder: set the queue position hint.

Source

pub fn with_vendor_hint(self, vendor: impl Into<String>) -> Self

Builder: set the vendor hint.

Source

pub fn with_body_markers(self, markers: Vec<String>) -> Self

Builder: replace the body marker set.

Source

pub fn with_header_set(self, headers: Vec<String>) -> Self

Builder: replace the header set.

Source

pub fn host(&self) -> Option<String>

Lower-case ASCII view of the URL host, when parseable. Returns None when the URL is empty or malformed.

Source

pub fn url_contains(&self, needle_lower: &str) -> bool

true when the URL path (or query) contains the given lower-case substring.

Source

pub fn body_contains(&self, needle_lower: &str) -> bool

true when any of the body markers contain the given lower-case substring.

Source

pub fn has_header(&self, name_lower: &str) -> bool

true when the header set contains the given lower-case header name.

Source

pub fn unique_headers(&self) -> BTreeSet<String>

Lower-case unique header set (for diagnostics).

Trait Implementations§

Source§

impl Clone for PageSignature

Source§

fn clone(&self) -> PageSignature

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PageSignature

Source§

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

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

impl Default for PageSignature

Source§

fn default() -> PageSignature

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PageSignature

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 PartialEq for PageSignature

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PageSignature

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
Source§

impl Eq for PageSignature

Source§

impl StructuralPartialEq for PageSignature

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

§

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

Source§

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

§

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