52 lines
2.3 KiB
Rust
52 lines
2.3 KiB
Rust
//! # Top Drives Shared Library
|
|
//!
|
|
//! Shared types and logic used by the `records` binary.
|
|
//!
|
|
//! ## Re-exports
|
|
//!
|
|
//! - **`Car` struct** — core car information from the records database
|
|
//! - **`BestCarRecord` struct** — best performing car record for a specific track/RQ/condition
|
|
//! - **`TripletKey` type alias** — composite key `(track_id, rq, surface)`
|
|
//! - **`AnalysisContext` struct** — holds mutable analysis state (replaces global static)
|
|
//! - **`CarCounts` struct** — aggregated per-car win counts
|
|
//! - **`MyCarsData` struct** — parsed user data from `my_cars.json`
|
|
//! - **`AppError` enum** — unified error type for the application
|
|
//! - **`translate_track_name()`** — internal track code → human-readable name
|
|
//! - **`translate_track_type()`** — condition code → surface name
|
|
//! - **`get_file()`** — async file download utility
|
|
//! - **`load_my_cars_data()`** — loads and parses `my_cars.json`
|
|
//! - **`compare_cars()`** — sorting comparator for `Car`
|
|
//! - **`compute_car_counts()`** — aggregates per-car win counts from analysis context
|
|
//! - **`escape_csv_field()`** — CSV-safe field escaping
|
|
|
|
// Sub-modules
|
|
pub mod context;
|
|
pub mod csv_util;
|
|
pub mod http;
|
|
pub mod translate;
|
|
pub mod types;
|
|
pub mod user_data;
|
|
|
|
/// Shared test utilities.
|
|
///
|
|
/// Intended for use in unit and integration tests. Provides helper constructors
|
|
/// for [`BestCarRecord`] and [`Car`] to reduce boilerplate in test code.
|
|
///
|
|
/// Enabled by the `test-utils` feature flag. This keeps test helpers out of
|
|
/// the library's semver public API while remaining accessible to downstream
|
|
/// test crates via `top_drives = { features = ["test-utils"] }`.
|
|
#[cfg(feature = "test-utils")]
|
|
#[doc(hidden)]
|
|
pub mod test_utils;
|
|
|
|
// Re-export all public types and functions for backward compatibility.
|
|
// External code can use `top_drives::Car` etc. without knowing the internal module layout.
|
|
pub use context::{compute_car_counts, AnalysisContext, CarCounts};
|
|
pub use csv_util::{compare_cars, escape_csv_field};
|
|
pub use http::get_file;
|
|
pub use translate::{translate_track_name, translate_track_type};
|
|
pub use types::{is_final_build, normalize_to_final_build, AppError, BestCarRecord, Car, TripletKey};
|
|
pub use user_data::{load_my_cars_data, MyCarsData};
|
|
|
|
#[cfg(feature = "test-utils")]
|
|
pub use test_utils::empty_my_data;
|