Skip to main content

TimerState

Struct TimerState 

Source
pub struct TimerState { /* private fields */ }
Expand description

Manages timer state for one execution context.

Implementations§

Source§

impl TimerState

Source

pub fn new() -> Self

Source

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.

Source

pub fn cancel(&mut self, id: u32)

Cancel a timer by ID.

Source

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

Source

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.

Source

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.

Source

pub fn reset_drained_tracking(&mut self)

Reset the drained callbacks tracking. CRITICAL FIX: Allows intentional re-draining in new analysis phases.

Source

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.

Source

pub fn pending_count(&self) -> usize

Number of pending (non-cancelled) timers.

Source

pub fn simulated_time_ms(&self) -> u64

Current simulated time in milliseconds.

Trait Implementations§

Source§

impl Debug for TimerState

Source§

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

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

impl Default for TimerState

Source§

fn default() -> TimerState

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.