Skip to content

Add StepLower and StepUpper marker strategies with enum wiring and legacy alias compatibility - #25

Merged
kylecarow merged 3 commits into
mainfrom
step-markers
Aug 4, 2026
Merged

Add StepLower and StepUpper marker strategies with enum wiring and legacy alias compatibility#25
kylecarow merged 3 commits into
mainfrom
step-markers

Conversation

@kylecarow

Copy link
Copy Markdown
Collaborator

Resolves #23

Summary

This PR adds zero-sized StepLower and StepUpper marker strategies for fixed-direction step interpolation across 1D/2D/3D/ND.

When direction is known at compile time, these markers avoid:

  • Step direction-vector allocation
  • per-call direction matching in interpolate()

Step remains available and unchanged for:

  • mixed per-dimension direction behavior
  • direction chosen at runtime

Motivation

Step::from(StepDirection::Lower|Upper) is convenient, but still carries runtime machinery intended for flexible direction handling.
For hot paths with fixed direction, StepLower/StepUpper provide a leaner path.

Changes

  • Added marker structs:
    • strategy::StepLower
    • strategy::StepUpper
  • Implemented strategy traits directly for both markers:
    • Strategy1D
    • Strategy2D
    • Strategy3D
    • StrategyND
  • Kept impl From<StepDirection> for Step intact.
  • Added marker variants to all strategy enums:
    • Strategy1DEnum
    • Strategy2DEnum
    • Strategy3DEnum
    • StrategyNDEnum
  • Added all manual enum wiring (per dimension):
    • variant declarations
    • From impls
    • init / interpolate / allow_extrapolate dispatch arms
  • Updated docs/readme guidance:
    • Step is called out first for mixed per-dimension directionality
    • runtime-selected direction is secondary
    • fixed-direction hot loops are steered to StepLower/StepUpper
  • Added backward-compat serde aliases:
    • "LeftNearest" -> StepLower
    • "RightNearest" -> StepUpper

Serde Behavior

  • StepLower/StepUpper use unit-struct style serialization (consistent with other marker strategies).
  • Legacy aliases are accepted only when deserializing StepLower/StepUpper.
  • Alias scope is intentionally not applied to StepDirection, so Step payload format is not broadened.

Compatibility

  • No breaking API changes.
  • Step and From<StepDirection> for Step are preserved.
  • Existing Step wire format remains unchanged.
  • Legacy serialized names are supported through marker deserialization aliases.

Testing

Added/updated tests for:

  • StepLower/StepUpper behavior in 1D/2D/3D/ND
  • enum serde round-trips with new variants
  • legacy alias deserialization
  • guard that {"Step":[...]} does not accept alias names

Validation run:

  • cargo fmt
  • cargo test --features serde

All tests and doc-tests pass.

@kylecarow
kylecarow merged commit 56640bd into main Aug 4, 2026
1 check passed
@kylecarow
kylecarow deleted the step-markers branch August 4, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Step improvements

1 participant