Skip to main content

Module profile

Module profile 

Source
Expand description

Saved ballistic profile data model.

ProfileData is the schema of ~/.ballistics/profiles/<name>.json — the CLI’s saved profiles — and, since the bridge grew profile.validate/profile.normalize/ profile.import_a7p, also the profile document the JSON command bridge exchanges with embedding apps. It lived in main.rs from its introduction; it moved here VERBATIM so the bridge and the CLI share one definition. The serde wire shape is a compatibility contract: every stored profile on disk and every fixture in the test suite must keep loading, so field names, defaults, skip_serializing_if decisions, and the ABSENCE of deny_unknown_fields (unknown keys are tolerated and dropped, the documented forward-compat behavior) are all deliberately unchanged. See the round-trip test at the bottom of this file before touching any attribute.

fs-free by design: this module must compile for wasm32, so file persistence (save_profile/load_profile) and unit conversion of loaded profiles (converted_to, which rides on the CLI’s UnitConverter) stay in main.rs.

Structs§

ProfileBcSegment
One velocity-banded BC breakpoint (profile schema v2, MBA-1323 Phase 2). Stored as a raw breakpoint, NOT a pre-computed velocity_min/velocity_max band — banding into the engine’s crate::BCSegmentData shape happens at solve time (bc_segments_from_profile), so the stored JSON stays a simple, order-independent list that round-trips cleanly.
ProfileData
Saved ballistic profile for quick recall
ProfileDragPoint
One Mach/Cd point of a saved custom drag curve (profile schema v2, MBA-1323 Phase 2). Both fields are unit-invariant (Mach is dimensionless; Cd is dimensionless), so ProfileData::converted_to (in main.rs) leaves drag_curve untouched too.
ProfileZeroSet
One named zero condition / per-load dial correction (MBA-1360).

Functions§

require_angular_pair
Assembles an all-or-nothing pair of angular profile fields — OpticProfile’s TravelLimits/TurretState axes — from two independently-Option values (MBA-1348). None only when NEITHER is set; Some only when BOTH are; a named-field Err when exactly one is. A silently-defaulted 0.0 for the missing half would assert a specific, likely-false physical fact (e.g. “zero down travel from zero”) rather than “not recorded” — exactly the silent fabrication OpticProfile’s own doc comments warn against — so an incomplete pair is rejected by name instead of guessed at.
require_hold_bounds
The require_angular_pair all-or-nothing rule extended to HoldBounds’ four fields (MBA-1348): all four or none, any other combination is a named-field Err (same no-silent-fabrication rationale — see require_angular_pair). Names the four CLI FLAGS in any error, not the internal struct fields (MBA-1348 review fix I2) — see require_angular_pair’s own doc comment for why that distinction matters.
validate_tracking_cf
MBA-1358: a scope tracking correction factor must be strictly between 0.5 and 1.5. Values outside that band mean the tall-target test (or a hand edit) went wrong — a real scope does not mistrack by 50% — so they are a hard error naming the offending field/flag rather than a silently applied scale. The band itself lives in the shared crate::adjustment::tracking_cf_in_range so the WASM terminal enforces the identical bound.