pub struct InterstitialRouter { /* private fields */ }Expand description
Dedicated acquisition router for classified interstitials.
InterstitialRouter is constructed once with an
InterstitialPolicy and is safe to share across
threads (the policy is immutable; the classifier is
stateless).
§Example
use stygian_browser::interstitial_router::{
InterstitialKind, InterstitialRouter, PageSignature,
};
let router = InterstitialRouter::with_defaults();
let sig = PageSignature::new("https://example.com/redirect", Some(302));
let decision = router.route(&sig, InterstitialKind::Transient);
assert!(!decision.is_classified());
assert!(decision.is_retryable());Implementations§
Source§impl InterstitialRouter
impl InterstitialRouter
Sourcepub const fn new(policy: InterstitialPolicy) -> Self
pub const fn new(policy: InterstitialPolicy) -> Self
Build a router with the supplied policy.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Build a router with the default policy.
Sourcepub const fn policy(&self) -> &InterstitialPolicy
pub const fn policy(&self) -> &InterstitialPolicy
Borrow the configured policy.
Sourcepub const fn with_policy(self, policy: InterstitialPolicy) -> Self
pub const fn with_policy(self, policy: InterstitialPolicy) -> Self
Replace the policy.
Sourcepub fn classify_and_route(&self, signature: &PageSignature) -> RouterDecision
pub fn classify_and_route(&self, signature: &PageSignature) -> RouterDecision
Classify signature via the router’s classifier
and route the result. This is the one-shot helper
most callers want.
§Example
use stygian_browser::interstitial_router::{
InterstitialKind, InterstitialRouter, PageSignature,
};
let router = InterstitialRouter::with_defaults();
let sig = PageSignature::new("https://example.com", Some(302));
let decision = router.classify_and_route(&sig);
assert_eq!(decision.kind(), InterstitialKind::Transient);Sourcepub fn route(
&self,
signature: &PageSignature,
kind: InterstitialKind,
) -> RouterDecision
pub fn route( &self, signature: &PageSignature, kind: InterstitialKind, ) -> RouterDecision
Route a pre-classified signature. The decision is
built from the supplied kind plus the
signature’s evidence.
§Example
use stygian_browser::interstitial_router::{
InterstitialKind, InterstitialRouter, InterstitialSeverity, PageSignature,
};
let router = InterstitialRouter::with_defaults();
let sig = PageSignature::new("https://example.com", Some(202))
.with_body_marker("please wait");
let decision = router.route(&sig, InterstitialKind::Queue);
assert_eq!(decision.severity(), InterstitialSeverity::Retryable);Sourcepub const fn should_short_circuit(&self, kind: InterstitialKind) -> bool
pub const fn should_short_circuit(&self, kind: InterstitialKind) -> bool
true when the router’s policy
(short_circuit_on_classified) is set and the
kind is a classified (non-Transient) decision.
The runner calls this helper to decide whether to
short-circuit on the decision.
Trait Implementations§
Source§impl Clone for InterstitialRouter
impl Clone for InterstitialRouter
Source§fn clone(&self) -> InterstitialRouter
fn clone(&self) -> InterstitialRouter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more