pub struct TemporalField { /* private fields */ }Expand description
The temporal field - ring buffer with decay and pub/sub events.
Every write and tick checks thresholds and fires events to observers. The brain does not poll - one spark cascades.
See crate-level documentation for full architecture explanation and examples.
§Clone behavior
Cloning a TemporalField copies the field state (frames, config, triggers) but NOT the observers. The clone starts with no subscribers.
Implementations§
Source§impl TemporalField
impl TemporalField
Sourcepub fn new(config: FieldConfig) -> Self
pub fn new(config: FieldConfig) -> Self
Create a new temporal field.
After creation, configure the field:
- Add monitored regions with
monitor_region() - Subscribe observers with
subscribe() - Writers write with
write_region(), readers receive events
Sourcepub fn monitor_region(&mut self, region: MonitoredRegion)
pub fn monitor_region(&mut self, region: MonitoredRegion)
Add a monitored region after construction.
Sourcepub fn set_convergence_threshold(&mut self, threshold: usize)
pub fn set_convergence_threshold(&mut self, threshold: usize)
Set convergence threshold.
Sourcepub fn subscribe(&mut self, observer: Arc<dyn FieldObserver>)
pub fn subscribe(&mut self, observer: Arc<dyn FieldObserver>)
Subscribe an observer to receive field events.
Sourcepub fn clear_observers(&mut self)
pub fn clear_observers(&mut self)
Remove all observers.
Sourcepub fn tick(&mut self)
pub fn tick(&mut self)
Advance time by one tick - decay all frames, may fire RegionQuiet events.
Sourcepub fn advance_write_head(&mut self)
pub fn advance_write_head(&mut self)
Advance write head to next frame.
Sourcepub fn write_region(&mut self, signals: &[Signal], range: Range<usize>)
pub fn write_region(&mut self, signals: &[Signal], range: Range<usize>)
Write Signals to a region of the current frame (additive) - may fire events.
Sourcepub fn set_region(&mut self, signals: &[Signal], range: Range<usize>)
pub fn set_region(&mut self, signals: &[Signal], range: Range<usize>)
Set Signals in a region of the current frame (replace) - may fire events.
Sourcepub fn write_full(&mut self, vector: &FieldVector)
pub fn write_full(&mut self, vector: &FieldVector)
Add a full vector to current frame - may fire events.
Sourcepub fn clear_current(&mut self)
pub fn clear_current(&mut self)
Clear the current frame.
Sourcepub fn read_current(&self) -> &FieldVector
pub fn read_current(&self) -> &FieldVector
Read the current frame.
Sourcepub fn read_region(&self, range: Range<usize>) -> Vec<Signal>
pub fn read_region(&self, range: Range<usize>) -> Vec<Signal>
Read a specific region from current frame.
Sourcepub fn region_energy(&self, range: Range<usize>) -> u64
pub fn region_energy(&self, range: Range<usize>) -> u64
Get energy in a region of current frame.
Sourcepub fn region_active(&self, range: Range<usize>, threshold: u64) -> bool
pub fn region_active(&self, range: Range<usize>, threshold: u64) -> bool
Check if region is active (energy above threshold).
Sourcepub fn read_window(&self, n: usize) -> Vec<&FieldVector>
pub fn read_window(&self, n: usize) -> Vec<&FieldVector>
Read the last N frames in chronological order (oldest first).
Sourcepub fn region_peak(&self, range: Range<usize>, window: usize) -> Vec<Signal>
pub fn region_peak(&self, range: Range<usize>, window: usize) -> Vec<Signal>
Get peak values in a region over the last N frames. Returns the frame with highest energy.
Sourcepub fn region_mean(&self, range: Range<usize>, window: usize) -> Vec<Signal>
pub fn region_mean(&self, range: Range<usize>, window: usize) -> Vec<Signal>
Get mean values in a region over the last N frames. Returns averaged Signal values using the full p×m×k range.
Sourcepub fn config(&self) -> &FieldConfig
pub fn config(&self) -> &FieldConfig
Get configuration.
Sourcepub fn triggers(&self) -> &TriggerConfig
pub fn triggers(&self) -> &TriggerConfig
Get trigger configuration.
Sourcepub fn regions(&self) -> &[MonitoredRegion]
pub fn regions(&self) -> &[MonitoredRegion]
Get monitored regions.
Sourcepub fn tick_count(&self) -> u64
pub fn tick_count(&self) -> u64
Get current tick count.
Sourcepub fn write_head(&self) -> usize
pub fn write_head(&self) -> usize
Get write head position.
Sourcepub fn frame_count(&self) -> usize
pub fn frame_count(&self) -> usize
Get frame count.
Sourcepub fn max_magnitude(&self) -> u16
pub fn max_magnitude(&self) -> u16
Get maximum effective magnitude in field.
Sourcepub fn total_activity(&self) -> usize
pub fn total_activity(&self) -> usize
Get total non-zero count.
Sourcepub fn ticks_to_ms(&self, ticks: u64) -> u32
pub fn ticks_to_ms(&self, ticks: u64) -> u32
Convert tick difference to milliseconds.
Sourcepub fn ms_to_ticks(&self, ms: u32) -> u64
pub fn ms_to_ticks(&self, ms: u32) -> u64
Convert milliseconds to ticks.