Skip to main content

StimulusBatch

Struct StimulusBatch 

Source
pub struct StimulusBatch {
    pub session_id: Option<String>,
    pub batch_id: u64,
    pub timestamp: u64,
    pub values: Vec<f32>,
    pub valid_mask: Option<Vec<bool>>,
    pub metadata: Option<BatchMetadata>,
}
Expand description

Canonical wire batch of continuous, domain-neutral runtime stimulus values.

This is the typed replacement for consumers’ ad-hoc stimulus payloads, such as a flat {"type":"Stimuli","values":[...]} UDP JSON message or a private ingress packet struct. corpus-ipc owns this schema; consumers should decode/encode through IpcMessage::Stimuli instead of a private struct or raw serde_json::Value field indexing.

§Channel width

values.len() is the channel count. It is not fixed by this crate — do not encode any particular network’s input width (such as one model’s current axon count) into this type. Consumers determine width at runtime from the batch itself.

§Invalid / missing channel semantics

valid_mask, when Some, must be the same length as values. valid_mask[i] == false means channel i has no valid reading this tick; the corresponding values[i] is a placeholder (0.0 by convention) and must not be interpreted as a real zero-valued reading. When valid_mask is None, every entry in values is valid.

This is a deliberate improvement over ad-hoc formats that silently coerce missing or non-numeric channels to 0.0 with no way to distinguish “sensor read zero” from “no data this tick.”

Fields are public (matching this crate’s other wire batches, e.g. SpikeBatch) for direct Rust construction, but deserialization enforces the valid_mask-length invariant: a JSON/wire payload with a valid_mask whose length differs from values.len() fails to deserialize (via StimulusBatch::validate through a TryFrom shadow type), rather than silently producing an inconsistent instance. Call Validate::validate explicitly after constructing one directly in Rust (which bypasses deserialization) to get the same check.

Fields§

§session_id: Option<String>

Optional session ID for concurrent experiment isolation.

§batch_id: u64

Unique batch identifier for correlation.

§timestamp: u64

Timestamp in nanoseconds (UTC or relative).

§values: Vec<f32>

Continuous stimulus values. Length is the channel count; not fixed by this crate.

§valid_mask: Option<Vec<bool>>

Optional per-channel validity mask, same length as values when present. false marks a channel as invalid/missing for this tick (see type docs).

§metadata: Option<BatchMetadata>

Optional batch-level metadata.

Trait Implementations§

Source§

impl Clone for StimulusBatch

Source§

fn clone(&self) -> Self

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 StimulusBatch

Source§

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

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

impl Default for StimulusBatch

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for StimulusBatch

Source§

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

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

impl PartialEq for StimulusBatch

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for StimulusBatch

Source§

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

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

impl StructuralPartialEq for StimulusBatch

Source§

impl Validate for StimulusBatch

Source§

fn validate_with(&self, limits: ProtocolLimits) -> Result<(), ValidationError>

Validate against an explicit policy.
Source§

fn validate(&self) -> Result<(), ValidationError>

Validate against ProtocolLimits::DEFAULT.

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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.