Skip to main content

WatchpointObserver

Struct WatchpointObserver 

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

A WriteObserver that watches a fixed set of global slot indices and records a hit whenever one is written — the entire watchpoint implementation. Reuses the existing production WriteObserver/ ObservedContext seam (state.rs) rather than a second observer mechanism, per the issue’s own instruction: this struct is the only piece of new plumbing watchpoints need.

Composes with crate::Story::debug_run_watching for pausing mid-step-loop on a hit, or with the existing Story::continue_single_observed (unaffected by this feature) for production-path logging without pausing — the observer doesn’t care which loop drives it.

Implementations§

Source§

impl WatchpointObserver

Source

pub fn new(watched_globals: Vec<u32>) -> Self

Source

pub fn watches(&self, global_idx: u32) -> bool

Source

pub fn hits(&self) -> &[WatchHit]

Every hit recorded since the last take_hits/take_hit call.

Source

pub fn take_hits(&mut self) -> Vec<WatchHit>

Drain every hit recorded since the last take_hits/clear call, in the order they were recorded. The public counterpart to take_hit — for a consumer that composes this observer with Story::continue_single_observed/continue_maximally_observed (non-pausing logging, per this module’s doc), take_hit’s pub(crate) FIFO pop is not reachable from outside the crate, so without this method pending would accumulate for the observer’s entire lifetime with no way for a consumer to clear it — the unbounded-growth guard this method (and clear) close.

Source

pub fn clear(&mut self)

Discard every pending hit without returning them — the other half of the unbounded-growth guard take_hits provides.

Trait Implementations§

Source§

impl Clone for WatchpointObserver

Source§

fn clone(&self) -> WatchpointObserver

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WatchpointObserver

Source§

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

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

impl Default for WatchpointObserver

Source§

fn default() -> WatchpointObserver

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

impl WriteObserver for WatchpointObserver

Source§

fn on_set_global(&mut self, idx: u32, _value: &Value)

Source§

fn on_increment_visit(&mut self, id: DefinitionId, new_count: u32)

Source§

fn on_set_visit_count(&mut self, id: DefinitionId, count: u32)

Source§

fn on_set_turn_count(&mut self, id: DefinitionId, turn: u32)

Source§

fn on_increment_turn_index(&mut self, new_value: u32)

Source§

fn on_set_turn_index(&mut self, index: u32)

Source§

fn on_set_rng_seed(&mut self, new_seed: i32)

Source§

fn on_set_previous_random(&mut self, new_val: i32)

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.