Module access

Module access 

Source
Expand description

Reading and writing one taxonomy axis on a canonical request.

with_axis produces a full SolveRequestV1 via the Phase 0 reverse conversion (request_roundtrip.rs) and then overwrites exactly one field, so every other input is carried across unchanged.

Two axes are enum-valued rather than scalar or boolean (DragModel: G1/G2/G5/G6/G7/G8/GI/GS/RA4; TwistDirection: left/right), so AxisValue carries a dedicated variant for each instead of round-tripping through a string – a string round-trip would turn a typo into a runtime KernelError::TypeMismatch instead of a compile error.

with_axis also refuses two axis/request combinations that would otherwise silently build a physically WRONG counterfactual, because the reverse conversion (see request_roundtrip.rs’s module doc) always emits absolute station pressure and shooter-relative wind regardless of how the original request entered them:

  • Altitude when the original request declared a QNH pressure: perturbing altitude would change air density-by-altitude without moving the QNH-referenced station pressure the way the caller means – the opposite of the intended counterfactual.
  • ShotAzimuth when the original request declared compass-referenced wind: perturbing the shot azimuth would rotate the wind WITH the rifle instead of keeping it earth-fixed – physically inverted.

Both are detected from the ORIGINAL resolved request’s echoed reference mode (added in Task 1 precisely so this is detectable) and rejected with KernelError::AxisUnsupportedForRequest rather than producing a silently-wrong request. See taxonomy.rs’s “KNOWN LIMITATIONS” comment, items (a) and (b).

A third check keeps with_axis consistent with read_axis rather than physics-aware: the three wind axes have no single scalar to write when the resolved wind is ResolvedWindV1::Segmented (taxonomy.rs Known Limitation (c)). read_axis already returns None for that combination; with_axis now returns KernelError::AxisAbsent for the same combination instead of silently writing a constant-wind field (speed_mps etc.) alongside the still-present wind.segments, which solve_v1’s resolve_wind would otherwise reject downstream as an opaque $.wind “segments cannot be combined with constant-wind fields” error.

The zero-affecting-axis rezero clear (see with_axis’s body) is evaluated from req.shot.zero_distance_m after the axis has been written, not before: for the ZeroDistance axis itself, the value that matters is the NEW distance being written, not whatever zero_distance_m was on the original request (which may have been absent). Gating on the pre-write value would let a request originally specified purely by muzzle_angle_rad silently keep that stale angle after a ZeroDistance write, so solve_v1 would skip the elevation search entirely (it takes an explicit angle over a zero distance whenever both are present) and the new zero distance would have no effect on elevation at all.

Enums§

AxisValue
One taxonomy axis’s value, read from or written to a request.
KernelError

Functions§

read_axis
Read the current value of one taxonomy axis off a resolved request.
with_axis
Rebuild r as a solvable SolveRequestV1 with exactly one axis overwritten to v.