Skip to main content

TemporalField

Struct TemporalField 

Source
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

Source

pub fn new(config: FieldConfig) -> Self

Create a new temporal field.

After creation, configure the field:

  1. Add monitored regions with monitor_region()
  2. Subscribe observers with subscribe()
  3. Writers write with write_region(), readers receive events
Source

pub fn monitor_region(&mut self, region: MonitoredRegion)

Add a monitored region after construction.

Source

pub fn set_convergence_threshold(&mut self, threshold: usize)

Set convergence threshold.

Source

pub fn subscribe(&mut self, observer: Arc<dyn FieldObserver>)

Subscribe an observer to receive field events.

Source

pub fn clear_observers(&mut self)

Remove all observers.

Source

pub fn tick(&mut self)

Advance time by one tick - decay all frames, may fire RegionQuiet events.

Source

pub fn tick_n(&mut self, n: usize)

Advance multiple ticks.

Source

pub fn advance_write_head(&mut self)

Advance write head to next frame.

Source

pub fn write_region(&mut self, signals: &[Signal], range: Range<usize>)

Write Signals to a region of the current frame (additive) - may fire events.

Source

pub fn set_region(&mut self, signals: &[Signal], range: Range<usize>)

Set Signals in a region of the current frame (replace) - may fire events.

Source

pub fn write_full(&mut self, vector: &FieldVector)

Add a full vector to current frame - may fire events.

Source

pub fn clear_current(&mut self)

Clear the current frame.

Source

pub fn read_current(&self) -> &FieldVector

Read the current frame.

Source

pub fn read_region(&self, range: Range<usize>) -> Vec<Signal>

Read a specific region from current frame.

Source

pub fn region_energy(&self, range: Range<usize>) -> u64

Get energy in a region of current frame.

Source

pub fn region_active(&self, range: Range<usize>, threshold: u64) -> bool

Check if region is active (energy above threshold).

Source

pub fn read_window(&self, n: usize) -> Vec<&FieldVector>

Read the last N frames in chronological order (oldest first).

Source

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.

Source

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.

Source

pub fn config(&self) -> &FieldConfig

Get configuration.

Source

pub fn triggers(&self) -> &TriggerConfig

Get trigger configuration.

Source

pub fn regions(&self) -> &[MonitoredRegion]

Get monitored regions.

Source

pub fn tick_count(&self) -> u64

Get current tick count.

Source

pub fn write_head(&self) -> usize

Get write head position.

Source

pub fn dims(&self) -> usize

Get total dimensions.

Source

pub fn frame_count(&self) -> usize

Get frame count.

Source

pub fn max_magnitude(&self) -> u16

Get maximum effective magnitude in field.

Source

pub fn total_activity(&self) -> usize

Get total non-zero count.

Source

pub fn clear(&mut self)

Clear entire field.

Source

pub fn ticks_to_ms(&self, ticks: u64) -> u32

Convert tick difference to milliseconds.

Source

pub fn ms_to_ticks(&self, ms: u32) -> u64

Convert milliseconds to ticks.

Trait Implementations§

Source§

impl Clone for TemporalField

Source§

fn clone(&self) -> Self

Clone the field state but NOT the observers. The clone starts with no subscribers.

1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TemporalField

Source§

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

Formats the value using the given formatter. 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> 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 = 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.