Skip to main content

Signal

Struct Signal 

Source
#[repr(C)]
pub struct Signal { pub polarity: i8, pub magnitude: u8, pub multiplier: u8, }
Expand description

Signal: polarity × magnitude × multiplier (s = p × m × k)

The fundamental unit of neural communication. Compact 3-byte #[repr(C)] representation:

  • polarity: -1 (inhibited), 0 (neutral), +1 (excited)
  • magnitude: 0–255 (base intensity — intrinsic neuron drive)
  • multiplier: 0–255 (contextual scaling — metabolic state, arousal, burst energy)

Effective magnitude = magnitude × multiplier (range 0–65,025).

Fields§

§polarity: i8

Polarity: -1 (inhibited), 0 (neutral), +1 (excited)

§magnitude: u8

Magnitude: 0–255 (base intensity — intrinsic neuron drive)

§multiplier: u8

Multiplier: 0–255 (contextual scaling — metabolic state, arousal, burst energy)

Default: 1 (neutral — effective magnitude equals base magnitude). 0 = silenced (effective magnitude is zero regardless of base magnitude).

Implementations§

Source§

impl Signal

Source

pub const ZERO: Signal

Zero signal (no activity)

Source

pub const MAX_POSITIVE: Signal

Maximum positive signal

Source

pub const MAX_NEGATIVE: Signal

Maximum negative signal

Source

pub const BASELINE_MULTIPLIER: u8 = 1

Baseline multiplier constant — use when k=1 is intentional.

Source

pub const fn effective_magnitude(&self) -> u16

Compute effective magnitude: magnitude × multiplier (0–65,025)

Source

pub const fn current(&self) -> i32

Compute signed effective current: polarity × magnitude × multiplier

Source

pub const fn zero() -> Signal

Create a zero / neutral signal

Source

pub const fn positive(magnitude: u8) -> Signal

👎Deprecated:

use Signal::positive_amplified(mag, mul) — s = p × m × k requires all three values

Create a positive (excitatory) signal with multiplier = 1

Source

pub const fn negative(magnitude: u8) -> Signal

👎Deprecated:

use Signal::negative_amplified(mag, mul) — s = p × m × k requires all three values

Create a negative (inhibitory) signal with multiplier = 1

Source

pub const fn positive_amplified(magnitude: u8, multiplier: u8) -> Signal

Create a positive signal with explicit multiplier

Source

pub const fn negative_amplified(magnitude: u8, multiplier: u8) -> Signal

Create a negative signal with explicit multiplier

Source

pub const fn with_polarity(polarity: Polarity, magnitude: u8) -> Signal

👎Deprecated:

use Signal::with_polarity_amplified(pol, mag, mul) — s = p × m × k requires all three values

Create from Polarity enum and magnitude (type-safe, multiplier = 1)

Source

pub const fn with_polarity_amplified( polarity: Polarity, magnitude: u8, multiplier: u8, ) -> Signal

Create from Polarity enum, magnitude, and multiplier (type-safe)

Source

pub const fn new(polarity: i8, magnitude: u8) -> Signal

👎Deprecated:

use Signal::new_raw(pol, mag, mul) — s = p × m × k requires all three values

Create from raw i8 polarity and magnitude (unchecked, multiplier = 1)

Source

pub const fn new_raw(polarity: i8, magnitude: u8, multiplier: u8) -> Signal

Create from raw components (unchecked)

Source

pub const fn new_checked(polarity: i8, magnitude: u8) -> Option<Signal>

👎Deprecated:

use Signal::new_checked_full(pol, mag, mul) — s = p × m × k requires all three values

Create from raw i8 polarity with validation (multiplier = 1)

Source

pub const fn new_checked_full( polarity: i8, magnitude: u8, multiplier: u8, ) -> Option<Signal>

Create from raw i8 polarity, magnitude, and multiplier with validation

Source

pub fn from_floats(polarity_f: f32, magnitude_f: f32) -> Signal

👎Deprecated:

defaults multiplier to 1 — construct with explicit multiplier instead

Create from separate float components (multiplier = 1)

polarity_f: quantised to {-1, 0, +1} (dead-zone ±0.1) magnitude_f: clamped to 0.0–1.0, scaled to 0–255

Source

pub fn from_signed(value: f32) -> Signal

👎Deprecated:

defaults multiplier to 1 — construct with explicit multiplier instead

Create from a single signed float (-1.0 to 1.0), multiplier = 1

Sign → polarity, absolute value → magnitude.

Source

pub fn from_signed_i32(value: i32) -> Signal

👎Deprecated:

defaults multiplier to 1 — use Signal::from_current(val) for full p × m × k range

Create from a signed i32 (multiplier = 1, clamps magnitude to 255).

Warning: This discards values above ±255. For the full ±65,025 range, use [from_current] instead.

Source

pub fn from_current(value: i32) -> Signal

Create from a signed i32 using the full p × m × k range (±65,025).

Decomposes the absolute value into magnitude × multiplier where both are 0–255. Values above 65,025 are clamped. Values ≤ 255 get multiplier=1. Values > 255 use magnitude=255 and multiplier=ceil(abs/255).

Source

pub fn from_i16(value: i16) -> Signal

👎Deprecated:

defaults multiplier to 1 — use Signal::from_signed_i32(val) for large ranges or construct with explicit multiplier

Create from a signed i16 (multiplier = 1)

Source

pub fn from_u8_bipolar(level: u8) -> Signal

👎Deprecated:

defaults multiplier to 1 — construct Signal with explicit multiplier instead

Create from u8 bipolar representation (128 = baseline)

Source

pub fn from_spike_rate(rate_hz: f32, max_rate_hz: f32) -> Signal

👎Deprecated:

defaults multiplier to 1 — construct Signal with explicit multiplier instead

Create from spike rate (Hz)

Source

pub fn from_spike_count(count: u32, window_ms: f32, max_rate_hz: f32) -> Signal

👎Deprecated:

defaults multiplier to 1 — construct Signal with explicit multiplier instead

Create from spike count in a time window

Source

pub fn as_signed_i32(&self) -> i32

Get as signed i32 using effective magnitude (polarity × magnitude × multiplier)

Source

pub fn magnitude_f32(&self) -> f32

Get base magnitude as float (0.0–1.0)

Source

pub fn effective_magnitude_f32(&self) -> f32

Get effective magnitude as float (0.0–1.0, normalized to max 65025)

Source

pub fn as_signed_f32(&self) -> f32

Get as signed float using effective magnitude (-1.0 to 1.0)

Source

pub fn to_u8_bipolar(&self) -> u8

Convert to u8 bipolar (128 = baseline), using base magnitude only

Source

pub fn to_spike_rate(&self, max_rate_hz: f32) -> f32

Convert to spike rate (Hz), using base magnitude

Source

pub fn get_polarity(&self) -> Polarity

Get polarity as Polarity enum (type-safe)

Source

pub fn is_active(&self) -> bool

Is this signal active (non-zero)?

Source

pub fn is_positive(&self) -> bool

Is this a positive / excitatory signal?

Source

pub fn is_negative(&self) -> bool

Is this a negative / inhibitory signal?

Source

pub const fn with_multiplier(self, multiplier: u8) -> Signal

Set the multiplier (contextual scaling)

Source

pub const fn amplify(self, delta: u8) -> Signal

Amplify: increase multiplier by delta (saturating)

Source

pub const fn attenuate(self, delta: u8) -> Signal

Attenuate: decrease multiplier by delta (saturating)

Source

pub fn add(&self, other: &Signal) -> Signal

Add two signals (same polarity adds, opposite cancels). Operates on base magnitude. Result gets multiplier = 1.

Source

pub fn scale(&self, factor: f32) -> Signal

Scale base magnitude by a factor (multiplier unchanged)

Source

pub fn decay(&mut self, retention: f32)

Apply decay to base magnitude (in-place, for temporal fields)

Source

pub fn decayed(&self, retention: f32) -> Signal

Return a decayed copy

Source

pub fn step_toward(&self, target: &Signal) -> Signal

Step toward target by one unit (base magnitude)

Source

pub fn step_toward_by(&self, target: &Signal, delta: u8) -> Signal

Step toward target by specified delta (base magnitude)

Source

pub fn step_toward_ratio(&self, target: &Signal, ratio: f32) -> Signal

Step toward target by fractional amount (0.0–1.0)

Source

pub fn reached(&self, target: &Signal, tolerance: u8) -> bool

Check if this signal has reached the target (within tolerance, base magnitude)

Trait Implementations§

Source§

impl Clone for Signal

Source§

fn clone(&self) -> Signal

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Signal

Source§

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

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

impl Default for Signal

Source§

fn default() -> Signal

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

impl<'de> Deserialize<'de> for Signal

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Signal, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Signal

Source§

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

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

impl From<PackedSignal> for Signal

Source§

fn from(p: PackedSignal) -> Signal

Converts to this type from the input type.
Source§

impl Hash for Signal

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Signal

Source§

fn eq(&self, other: &Signal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Signal

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Signal

Source§

impl Eq for Signal

Source§

impl StructuralPartialEq for Signal

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,