Skip to main content

Module read_mode

Module read_mode 

Source
Expand description

Type-safe ctx_read modes (#528 / #509 Phase 2).

Historically the read mode travelled through the whole pipeline as a bare &str ("full", "map", "lines:5-10", "density:0.40", …) and the knowledge of which modes exist — and how each one is classified (cacheable? lossy summary? counts as compressed?) — was duplicated across the registered handler, the read core and render.rs. That stringly-typed design let invalid states slip through (silently falling back to full) and let the duplicated classifications drift.

ReadMode is the single source of truth for the mode vocabulary:

  • ReadMode::from_str parses (and validates) the canonical strings.
  • Display round-trips byte-identically to those same strings, so the type can be threaded through the typed decision points without touching the string-mode MCP boundary or render.rs (back-compat).
  • the classification methods (ReadMode::is_compressed_cacheable, ReadMode::allows_raw_cap, ReadMode::is_lossy_summary, ReadMode::counts_as_compressed) replace the scattered matches!(mode, …) predicates, and the test module locks each one to the legacy predicate it replaces so behaviour can never silently change.

Structs§

LineRange
A 1-based, inclusive line window (lines:start-end).

Enums§

ParseModeError
Error returned when a string is not a recognised ReadMode.
ReadMode
The mode a ctx_read call resolves to.

Functions§

canonicalize_tail_mode
Rewrite the documented bare tail spelling -N to its canonical lines:-N form (#1813).