DsfTable

Struct DsfTable 

Source
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

Source

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.

Source

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.

Source

pub fn factor_at(&self, mach: f64) -> f64

The drop-scale-factor at mach.

  • Identity (1.0) at or above DSF_MACH_CEILING, and for an empty table at any Mach — there is nothing to scale by.
  • Flat-clamped to the lowest point’s dsf at 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).
Source

pub fn points(&self) -> &[DsfPoint]

The table’s points, sorted ascending by Mach.

Trait Implementations§

Source§

impl Clone for DsfTable

Source§

fn clone(&self) -> DsfTable

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DsfTable

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DsfTable

Source§

fn eq(&self, other: &DsfTable) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DsfTable

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,