Skip to main content

Module window

Module window 

Source
Expand description

[UsageWindow] and the per-window resolve_*_reset functions collapse the (Endpoint vs JSONL) match dance for the four rate-limit segments into typed calls. Without this seam, each segment open-codes the same nested match against UsageData, differing only in window selector (five_hour vs seven_day) and hide-reason wording.

Reset resolution is split per-window because the return types are asymmetric: 5h has two sources (endpoint resets_at or the JSONL block’s derived ends_at()), while 7d has only the endpoint source. A unified return shape would force an unreachable!() arm at the 7d caller; per-window functions express the asymmetry in the type system instead.

Returns Result<_, &'static str> for every resolution path: the Err arm carries the body of the segment’s lsm_debug! line so the hide-reason wording sits at one site (here), while the segment-name prefix stays at the segment’s call site (preserves per-segment ops grep).