pub struct TimerState { /* private fields */ }Expand description
Manages timer state for one execution context.
Implementations§
Source§impl TimerState
impl TimerState
pub fn new() -> Self
Sourcepub fn register(
&mut self,
delay_ms: u32,
is_interval: bool,
callback_source: String,
) -> Option<u32>
pub fn register( &mut self, delay_ms: u32, is_interval: bool, callback_source: String, ) -> Option<u32>
Register a new timer. Returns Some(timer_id) on success, or None
if the timer ID space is exhausted or the pending timer cap is reached.
Sourcepub fn drain_next(&mut self) -> Option<String>
pub fn drain_next(&mut self) -> Option<String>
Drain the next ready timer callback.
Returns the callback source code to eval, or None if no timers are ready. For “drain immediately” mode, all timers are considered ready.
CRITICAL FIX: Tracks unique callbacks to prevent fingerprinting via timer drain patterns. Returns None if this exact callback was already drained (prevents duplicate execution).
Sourcepub fn is_callback_drained(&self, callback_source: &str) -> bool
pub fn is_callback_drained(&self, callback_source: &str) -> bool
Check if a callback source has been drained before. CRITICAL FIX: Used to prevent fingerprinting via timer drain patterns.
Sourcepub fn unique_drained_count(&self) -> usize
pub fn unique_drained_count(&self) -> usize
Number of unique callbacks that have been drained. CRITICAL FIX: Use this instead of iteration count for drain limits.
Sourcepub fn reset_drained_tracking(&mut self)
pub fn reset_drained_tracking(&mut self)
Reset the drained callbacks tracking. CRITICAL FIX: Allows intentional re-draining in new analysis phases.
Sourcepub fn fast_forward(&mut self, advance_ms: u64) -> Vec<String>
pub fn fast_forward(&mut self, advance_ms: u64) -> Vec<String>
Advance simulated time and drain all timers that have elapsed. Returns callback source codes in firing order.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of pending (non-cancelled) timers.
Sourcepub fn simulated_time_ms(&self) -> u64
pub fn simulated_time_ms(&self) -> u64
Current simulated time in milliseconds.
Trait Implementations§
Source§impl Debug for TimerState
impl Debug for TimerState
Source§impl Default for TimerState
impl Default for TimerState
Source§fn default() -> TimerState
fn default() -> TimerState
Auto Trait Implementations§
impl Freeze for TimerState
impl RefUnwindSafe for TimerState
impl Send for TimerState
impl Sync for TimerState
impl Unpin for TimerState
impl UnsafeUnpin for TimerState
impl UnwindSafe for TimerState
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> 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