Module speed

Source
Expand description

§Speed Enum with Static Configuration

This module implements a Speed enum that uses static pre-configured values to avoid repeated match expressions and improve performance. The configuration for each speed level is defined once in static constants, which are accessed through accessor methods.

§Design Choice

This implements the “enum with static data” pattern where:

  • The enum is kept simple for Clap integration
  • Associated data is stored in static constants (optional, can be plain after match, but it is less structured)
  • Accessor methods avoid repeated match statements by using a config() method (optional)
  • Provide an easy way to get all parameters at once, using config()

A variant will look like: same enum, in get_name fn matches self and returns “fast” for fast variant etc. => (no const or associated struct, but less structured (no named variant of parameters))

§Example

use rsnaker::controls::speed::Speed;

let fast_speed = Speed::Fast;
println!("Speed value: {}", fast_speed.ms_value());
assert_eq!("Fast", fast_speed.name());

Structs§

SpeedConfig
Contains all configuration data for a speed level

Enums§

Speed
Represents speed levels with embedded properties

Constants§

FAST_CONFIG 🔒
NORMAL_CONFIG 🔒
SLOW_CONFIG 🔒
TREMENDOUS_CONFIG 🔒