pub trait ComputeBlock {
type Input;
type Output;
// Required method
fn compute(&mut self, input: &Self::Input) -> Self::Output;
// Provided methods
fn simd_supported(&self) -> bool { ... }
fn simd_instruction_set(&self) -> SimdInstructionSet { ... }
fn latency_budget_us(&self) -> u64 { ... }
}Expand description
ComputeBlock trait for SIMD-optimized panel elements
All panel elements that benefit from SIMD optimization implement this trait. The trait provides a common interface for:
- Computing output from input data
- Querying SIMD support
- Measuring compute latency
§Example
ⓘ
struct SparklineBlock {
history: Vec<f32>,
}
impl ComputeBlock for SparklineBlock {
type Input = f32;
type Output = Vec<char>;
fn compute(&mut self, input: &Self::Input) -> Self::Output {
self.history.push(*input);
// SIMD-optimized normalization and character mapping
self.render_blocks()
}
}Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn simd_supported(&self) -> bool
fn simd_supported(&self) -> bool
Query if this block supports SIMD on the current CPU
Sourcefn simd_instruction_set(&self) -> SimdInstructionSet
fn simd_instruction_set(&self) -> SimdInstructionSet
Get the SIMD instruction set used by this block
Sourcefn latency_budget_us(&self) -> u64
fn latency_budget_us(&self) -> u64
Get the compute latency budget in microseconds