pub struct ScanTimer { /* private fields */ }Expand description
Manages the loop lifecycle and operational boundaries for network scanning operations.
ScanTimer tracks hard deadlines, enforces minimum runtimes, and aborts loops
early if a period of network “silence” (time since the last relevant packet)
exceeds a configured maximum.
Implementations§
Source§impl ScanTimer
impl ScanTimer
Sourcepub fn new(
max_total_duration: Duration,
min_runtime_duration: Duration,
max_silence: Duration,
) -> Self
pub fn new( max_total_duration: Duration, min_runtime_duration: Duration, max_silence: Duration, ) -> Self
Constructs a new ScanTimer with the specified operational limits.
§Arguments
max_total_duration- The absolute maximum time the scan is allowed to run.min_runtime_duration- The absolute minimum time the scan must run before it can abort due to silence.max_silence- The maximum duration of network silence allowed after the minimum runtime is reached.
Sourcepub fn mark_activity(&mut self)
pub fn mark_activity(&mut self)
Resets the internal “silence” tracker.
This should be called whenever a relevant packet or activity is observed on the network.
Sourcepub fn time_until_next_tick(&self) -> Duration
pub fn time_until_next_tick(&self) -> Duration
Calculates how long to wait for the next timeout event.
Returns a fallback duration (e.g., 100ms) if the maximum silence period has already been exceeded.
Sourcepub fn has_expired(&self) -> bool
pub fn has_expired(&self) -> bool
Checks if the entire operation should abort due to hard limits or excessive silence.
Returns true if:
- The current time has exceeded the
hard_deadline. - The
min_runtimehas elapsed AND the time since the last recorded activity exceedsmax_silence.
Sourcepub fn should_break_on_timeout(&self) -> bool
pub fn should_break_on_timeout(&self) -> bool
Helper to decide if a socket timeout is fatal or if the scan should continue.
Returns true if the minimum runtime has been met, indicating that a timeout
could be a valid reason to break the loop.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ScanTimer
impl RefUnwindSafe for ScanTimer
impl Send for ScanTimer
impl Sync for ScanTimer
impl Unpin for ScanTimer
impl UnsafeUnpin for ScanTimer
impl UnwindSafe for ScanTimer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more