Skip to main content

Module rate_limit

Module rate_limit 

Source
Expand description

Rate-limit segment family. Renders the 5-hour and 7-day usage windows from ctx.usage() per docs/specs/rate-limit-segments.md.

See format for the shared render helpers, and the per-window files (five_hour, five_hour_reset, seven_day, seven_day_reset) for the four Segment impls. The dispatcher in segments::mod.rs wires the user-facing [segments.rate_limit_*] config keys to the segment structs re-exported below.

Re-exports§

pub use five_hour::RateLimit5hResetSegment;
pub use five_hour::RateLimit5hSegment;
pub use seven_day::RateLimit7dResetSegment;
pub use seven_day::RateLimit7dSegment;

Modules§

config
Config types and TOML-extras parsers for the rate-limit segment family. The CommonRateLimitConfig struct, family-shared format enums, and apply_common_extras / parse_*_format helpers all live here. Render-time helpers (format_percent, format_duration, render_error, etc.) live in format.
five_hour
5-hour rate-limit segments: utilization (RateLimit5hSegment) and reset countdown (RateLimit5hResetSegment). Both read ctx.usage() (Arc<Result<UsageData, UsageError>>) and route through the UsageWindow::FiveHour seam in super::window.
format
Render helpers for the rate-limit segment family. TOML-parsing, the CommonRateLimitConfig struct, and the format enums live in the config sibling.
seven_day
7-day rate-limit segments: utilization (RateLimit7dSegment) and reset countdown (RateLimit7dResetSegment). Both mirror the five_hour segments but read data.seven_day.
window
[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.