Skip to main content

Module utils

Module utils 

Source
Expand description

Leaf helpers shared across the crate: directory walking, JSON/JSONL file IO, number/date formatting, git remote lookup, glibc heap tuning, path resolution, ISO timestamp parsing, and token-count extraction.

The most frequently used items are re-exported at this module’s root so callers can write utils::format_number instead of reaching into the per-concern submodules.

Re-exports§

pub use directory::COPILOT_SESSION_MAX_DEPTH;
pub use directory::GROK_SESSION_MAX_DEPTH;
pub use directory::collect_files_with_dates;
pub use directory::collect_files_with_max_depth;
pub use directory::is_claude_session_file;
pub use directory::is_codex_session_file;
pub use directory::is_copilot_session_file;
pub use directory::is_gemini_session_file;
pub use directory::is_grok_session_file;
pub use file::count_lines;
pub use file::read_json;
pub use file::read_jsonl;
pub use file::save_json_pretty;
pub use file::write_json_atomic;
pub use file::write_json_atomic_pretty;
pub use file::write_string_atomic;
pub use format::format_compact;
pub use format::format_cost;
pub use format::format_cost_compact;
pub use format::format_duration_until;
pub use format::format_number;
pub use format::get_current_date;
pub use git::get_git_remote_url;
pub use heap::release_freed_heap;
pub use heap::tune_system_allocator;
pub use paths::HelperPaths;
pub use paths::find_pricing_cache_for_date;
pub use paths::find_pricing_cache_for_date_in;
pub use paths::get_cache_dir;
pub use paths::get_claude_credentials_path;
pub use paths::get_claude_usage_cache_path;
pub use paths::get_codex_usage_cache_path;
pub use paths::get_config_path;
pub use paths::get_copilot_config_path;
pub use paths::get_copilot_usage_cache_path;
pub use paths::get_current_user;
pub use paths::get_cursor_auth_path;
pub use paths::get_cursor_usage_cache_path;
pub use paths::get_machine_id;
pub use paths::get_pricing_cache_path;
pub use paths::get_pricing_cache_path_in;
pub use paths::get_self_version_cache_path;
pub use paths::list_pricing_cache_files;
pub use paths::list_pricing_cache_files_in;
pub use paths::network_disabled;
pub use paths::resolve_paths;
pub use paths::resolve_paths_from_home;
pub use time::now_rfc3339_utc_nanos;
pub use time::parse_iso_timestamp;
pub use token_extractor::TokenCounts;
pub use token_extractor::extract_token_counts;
pub use token_merge::normalize_usage_value;
pub use usage_processor::CodexTokenTotals;
pub use usage_processor::accumulate_i64_fields;
pub use usage_processor::accumulate_nested_object;
pub use usage_processor::claude_request_context;
pub use usage_processor::process_claude_usage;
pub use usage_processor::process_codex_usage;
pub use usage_processor::process_gemini_usage;

Modules§

directory
file
format
git
heap
Allocator-level helpers.
paths
Filesystem path resolution: the per-provider session directories under the user’s home, the tool’s own cache directory, and the dated pricing-cache file naming scheme.
time
Timestamp parsing helpers for the ISO-8601 / RFC 3339 strings that the provider session logs embed in each record.
token_extractor
token_merge
Neutral token-bucket merge / normalization helpers.
usage_processor
Per-provider usage accumulation: merges the token fields of one session record into a running per-model map, normalising provider-specific shapes along the way.