pub struct DsfTable { /* private fields */ }Expand description
A validated, Mach-sorted table of up to DSF_MAX_POINTS DsfPoints.
Construct via DsfTable::from_points (bulk, e.g. loading a saved profile) or by
starting from an empty table (DsfTable::from_points(Vec::new()), infallible) and
growing it with DsfTable::upsert (the dsf CLI verb’s one-observation-at-a-time
path in a later task).
Implementations§
Source§impl DsfTable
impl DsfTable
Sourcepub fn from_points(points: Vec<DsfPoint>) -> Result<DsfTable, String>
pub fn from_points(points: Vec<DsfPoint>) -> Result<DsfTable, String>
Validate, cap-check, and sort a bulk set of points (e.g. deserialized from a saved
profile). Rejects any point failing validation (see DsfPoint bounds) and rejects more than
DSF_MAX_POINTS points outright. Does NOT dedupe near-Mach points against each
other — that supersede behavior is DsfTable::upsert’s job; a caller assembling
points one at a time should use upsert, not construct a Vec with near-duplicates
and pass it here.
Sourcepub fn upsert(&mut self, point: DsfPoint) -> Result<UpsertOutcome, String>
pub fn upsert(&mut self, point: DsfPoint) -> Result<UpsertOutcome, String>
Insert or supersede a point. A new point within DSF_SUPERSEDE_TOLERANCE_MACH
Mach of an existing one replaces it (returning UpsertOutcome::Replaced with the
overwritten point); otherwise it is appended (returning
UpsertOutcome::Appended), unless the table is already at DSF_MAX_POINTS
distinct points, in which case this errors naming the cap.
Sourcepub fn factor_at(&self, mach: f64) -> f64
pub fn factor_at(&self, mach: f64) -> f64
The drop-scale-factor at mach.
- Identity (
1.0) at or aboveDSF_MACH_CEILING, and for an empty table at any Mach — there is nothing to scale by. - Flat-clamped to the lowest point’s
dsfat or below the lowest point’s Mach. - Piecewise-linear between successive points.
- Piecewise-linear between the highest point and the implicit anchor
(DSF_MACH_CEILING, DSF_ANCHOR_VALUE)for Mach between the highest point and the ceiling (this includes single-point tables, where “highest” and “lowest” are the same point).
Trait Implementations§
impl StructuralPartialEq for DsfTable
Auto Trait Implementations§
impl Freeze for DsfTable
impl RefUnwindSafe for DsfTable
impl Send for DsfTable
impl Sync for DsfTable
impl Unpin for DsfTable
impl UnwindSafe for DsfTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.