#[non_exhaustive]pub struct ScanContext {
pub target: Url,
pub client: Arc<Client>,
pub discovered_endpoints: Arc<DashMap<String, Vec<String>>>,
pub visited_urls: Arc<DashSet<String>>,
pub telemetry_tx: UnboundedSender<String>,
pub logger: Arc<Logger>,
pub phase_timeout_secs: u64,
pub cancel_token: CancellationToken,
pub event_bus: Arc<EventBus>,
/* private fields */
}Expand description
Zero-copy shared state across all scan phases.
Construct contexts through ScanContext::new or one of the policy-aware
constructors. Additional runtime state may be introduced without requiring
extension authors to initialize internal fields.
§Examples
use reqwest::Client;
use url::Url;
use termivar_scanner::ScanContext;
let (telemetry_tx, _telemetry_rx) = tokio::sync::mpsc::unbounded_channel();
let context = ScanContext::new(
Url::parse("https://example.test")?,
Client::new(),
telemetry_tx,
);
assert_eq!(context.knowledge().stats().evidence, 0);Direct construction is intentionally unsupported so new runtime state does not break extension code:
use reqwest::Client;
use url::Url;
use termivar_scanner::ScanContext;
let (telemetry_tx, _telemetry_rx) = tokio::sync::mpsc::unbounded_channel();
let context = ScanContext::new(
Url::parse("https://example.test").unwrap(),
Client::new(),
telemetry_tx,
);
let _modified = ScanContext {
phase_timeout_secs: 30,
..context
};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.target: UrlCompatibility view of the root URL whose scope is being scanned.
Mutating this pre-1.0 public field does not change the immutable target captured by built-in authorities or the runner’s provenance envelope.
client: Arc<Client>Raw HTTP client retained for phase one and custom phases that explicitly accept the legacy direct-I/O contract.
Built-in phases two through nine ignore this client. Discovery and verification use distinct private exact-origin bounded authorities.
discovered_endpoints: Arc<DashMap<String, Vec<String>>>Discovered endpoints mapped to their observed parameter names.
visited_urls: Arc<DashSet<String>>URLs already visited by discovery phases.
telemetry_tx: UnboundedSender<String>Asynchronous telemetry channel for logging and analysis.
logger: Arc<Logger>Structured logger shared by scan phases.
phase_timeout_secs: u64Maximum runtime of an individual phase, in seconds.
cancel_token: CancellationTokenToken used to propagate graceful scan cancellation.
Calling [CancellationToken::cancel] affects the immutable shared token
captured by the runner and built-in authorities. Replacing this public
compatibility field does not replace that runtime authority.
event_bus: Arc<EventBus>Event bus used to publish scan lifecycle and progress events.
Implementations§
Source§impl ScanContext
impl ScanContext
Sourcepub fn new(
target: Url,
client: Client,
telemetry_tx: UnboundedSender<String>,
) -> Self
pub fn new( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, ) -> Self
Creates a context with a five-minute phase timeout, a fresh cancellation token, and a fresh event bus.
Sourcepub fn new_with_discovery_limits(
target: Url,
client: Client,
telemetry_tx: UnboundedSender<String>,
discovery_limits: DiscoveryLimits,
) -> Self
pub fn new_with_discovery_limits( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, discovery_limits: DiscoveryLimits, ) -> Self
Creates a context with a host-selected finite discovery envelope and otherwise default runtime services.
Sourcepub fn new_with_verification_limits(
target: Url,
client: Client,
telemetry_tx: UnboundedSender<String>,
verification_limits: VerificationLimits,
) -> Self
pub fn new_with_verification_limits( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, verification_limits: VerificationLimits, ) -> Self
Creates a context with a host-selected finite verification envelope and otherwise default runtime services.
Sourcepub fn with_timeout(
target: Url,
client: Client,
telemetry_tx: UnboundedSender<String>,
phase_timeout_secs: u64,
) -> Self
pub fn with_timeout( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, phase_timeout_secs: u64, ) -> Self
Creates a context with an explicit per-phase timeout in seconds.
A fresh cancellation token and event bus are installed for the scan.
Sourcepub fn with_cancellation(
target: Url,
client: Client,
telemetry_tx: UnboundedSender<String>,
phase_timeout_secs: u64,
cancel_token: CancellationToken,
) -> Self
pub fn with_cancellation( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, phase_timeout_secs: u64, cancel_token: CancellationToken, ) -> Self
Creates a context with explicit timeout and cancellation policy.
A fresh event bus is installed for the scan.
Sourcepub fn with_event_bus(
target: Url,
client: Client,
telemetry_tx: UnboundedSender<String>,
phase_timeout_secs: u64,
cancel_token: CancellationToken,
event_bus: Arc<EventBus>,
) -> Self
pub fn with_event_bus( target: Url, client: Client, telemetry_tx: UnboundedSender<String>, phase_timeout_secs: u64, cancel_token: CancellationToken, event_bus: Arc<EventBus>, ) -> Self
Creates a context with all externally configurable runtime services.
The authorized root endpoint is registered immediately; the visited set, typed forms, logger, and knowledge base start empty. The supplied raw HTTP client is promoted into shared ownership for unmigrated and custom legacy phases.
Sourcepub const fn discovery_limits(&self) -> DiscoveryLimits
pub const fn discovery_limits(&self) -> DiscoveryLimits
Returns the configured discovery envelope.
Sourcepub const fn verification_limits(&self) -> VerificationLimits
pub const fn verification_limits(&self) -> VerificationLimits
Returns the finite envelope shared by built-in legacy verification phases five through nine.
Sourcepub fn discovery_forms(&self) -> Vec<DiscoveryForm>
pub fn discovery_forms(&self) -> Vec<DiscoveryForm>
Returns stable typed form observations from bounded discovery.
Ownership is parser-tree-descendant based; malformed HTML form-owner associations are not inferred.
Sourcepub fn log(&self, msg: String)
pub fn log(&self, msg: String)
Sends a plain-text message to the telemetry channel.
Messages are dropped when the receiving side has closed.
Sourcepub fn add_endpoint(&self, url: String, params: Vec<String>)
pub fn add_endpoint(&self, url: String, params: Vec<String>)
Records a discovered endpoint and its observed parameter names.
Recording the same URL again replaces its prior parameter list.
Sourcepub fn mark_visited(&self, url: String)
pub fn mark_visited(&self, url: String)
Marks a URL as visited for duplicate-scan prevention.
Sourcepub fn is_visited(&self, url: &str) -> bool
pub fn is_visited(&self, url: &str) -> bool
Returns whether a URL has already been marked as visited.
Sourcepub fn endpoint_count(&self) -> usize
pub fn endpoint_count(&self) -> usize
Returns the number of distinct discovered endpoint URLs.
Sourcepub fn knowledge(&self) -> &KnowledgeBase
pub fn knowledge(&self) -> &KnowledgeBase
Returns the evidence-driven knowledge base shared by this scan.
The context retains ownership so the runtime can preserve one knowledge identity across phases and cloned contexts.
Trait Implementations§
Source§impl Clone for ScanContext
impl Clone for ScanContext
Source§fn clone(&self) -> ScanContext
fn clone(&self) -> ScanContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more