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§
- Profile
BcSegment - One velocity-banded BC breakpoint (profile schema v2, MBA-1323 Phase 2). Stored as a raw
breakpoint, NOT a pre-computed
velocity_min/velocity_maxband — banding into the engine’scrate::BCSegmentDatashape happens at solve time (bc_segments_from_profile), so the stored JSON stays a simple, order-independent list that round-trips cleanly. - Profile
Data - Saved ballistic profile for quick recall
- Profile
Drag Point - 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(inmain.rs) leavesdrag_curveuntouched too. - Profile
Zero Set - 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’sTravelLimits/TurretStateaxes — from two independently-Optionvalues (MBA-1348).Noneonly when NEITHER is set;Someonly when BOTH are; a named-fieldErrwhen exactly one is. A silently-defaulted0.0for 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 fabricationOpticProfile’s own doc comments warn against — so an incomplete pair is rejected by name instead of guessed at. - require_
hold_ bounds - The
require_angular_pairall-or-nothing rule extended toHoldBounds’ four fields (MBA-1348): all four or none, any other combination is a named-fieldErr(same no-silent-fabrication rationale — seerequire_angular_pair). Names the four CLI FLAGS in any error, not the internal struct fields (MBA-1348 review fix I2) — seerequire_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_rangeso the WASM terminal enforces the identical bound.