Skip to main content

ComputeBlock

Trait ComputeBlock 

Source
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§

Source

type Input

Input type for this compute block

Source

type Output

Output type produced by this compute block

Required Methods§

Source

fn compute(&mut self, input: &Self::Input) -> Self::Output

Process input data and produce output

Implementations should use SIMD where available for optimal performance. The simd_instruction_set() method indicates which instruction set is being used.

Provided Methods§

Source

fn simd_supported(&self) -> bool

Query if this block supports SIMD on the current CPU

Source

fn simd_instruction_set(&self) -> SimdInstructionSet

Get the SIMD instruction set used by this block

Source

fn latency_budget_us(&self) -> u64

Get the compute latency budget in microseconds

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§