pub struct Window<P: Profile> { /* private fields */ }Expand description
A closed interval in absolute time, lo <= hi.
Rule U: window arithmetic is interval arithmetic with outward rounding.
Windows are never silently collapsed — Window::midpoint must be called
explicitly and takes a Rounding.
Implementations§
Source§impl<P: Profile> Window<P>
impl<P: Profile> Window<P>
Sourcepub fn new(lo: Instant<P>, hi: Instant<P>) -> Result<Self>
pub fn new(lo: Instant<P>, hi: Instant<P>) -> Result<Self>
Construct from bounds, rejecting inversion with UCAL-E0022.
Sourcepub fn width(&self) -> Delta
pub fn width(&self) -> Delta
Width in ticks. A degenerate window has width zero, not one: it spans one tick, and the width is the difference between its bounds.
Sourcepub fn contains(&self, t: &Instant<P>) -> bool
pub fn contains(&self, t: &Instant<P>) -> bool
Whether an instant lies within the closed interval.
Sourcepub fn compare(&self, other: &Self) -> IntervalOrdering
pub fn compare(&self, other: &Self) -> IntervalOrdering
Interval-aware comparison, which may be indeterminate (Rule T).
Sourcepub fn try_compare(&self, other: &Self) -> Result<Ordering>
pub fn try_compare(&self, other: &Self) -> Result<Ordering>
Interval-aware comparison as a Result, so that indeterminacy surfaces as
UCAL-E0023 at call sites that require a total order.
Sourcepub fn checked_add(&self, d: &Delta) -> Result<Self>
pub fn checked_add(&self, d: &Delta) -> Result<Self>
Shift the whole window by a magnitude. Outward rounding is trivial here because a translation preserves width exactly (Rule U).
Sourcepub fn checked_sub(&self, d: &Delta) -> Result<Self>
pub fn checked_sub(&self, d: &Delta) -> Result<Self>
Shift the window back by a magnitude.
Sourcepub fn widen(&self, d: &Delta) -> Result<(Self, bool)>
pub fn widen(&self, d: &Delta) -> Result<(Self, bool)>
Widen outward by a magnitude on both sides. The lower bound saturates at the datum rather than failing, because a window clipped by Rule Z is still a sound enclosure; the clipping is reported by the returned flag.
Sourcepub fn checked_add_span(&self, s: &Span) -> Result<Self>
pub fn checked_add_span(&self, s: &Span) -> Result<Self>
Shift by an uncertain magnitude: lo with lo, hi with hi (Rule U).
The result is at least as wide as either input, which is the point — an uncertain instant displaced by an uncertain duration cannot be known better than either. This is the operation Rule J.2 needs when an anchor window is carried forward into a derived field.
Sourcepub fn checked_sub_span(&self, s: &Span) -> Result<Self>
pub fn checked_sub_span(&self, s: &Span) -> Result<Self>
Shift back by an uncertain magnitude: [lo - s.hi, hi - s.lo], outward.
Strict at the datum — UCAL-E0020 rather than a clamp — because a window
that has been silently clipped is no longer the interval the caller asked
for. Use Window::widen where clipping is acceptable and reported.
Sourcepub fn since_window(&self, earlier: &Self) -> Result<(Span, bool)>
pub fn since_window(&self, earlier: &Self) -> Result<(Span, bool)>
Elapsed time from an earlier window to this one, as an uncertain magnitude.
[max(0, self.lo - earlier.hi), self.hi - earlier.lo]. The lower bound
clamps at zero because overlapping windows genuinely admit zero elapsed
time; the flag reports whether that happened. UCAL-E0020 when this window
lies wholly before earlier, which is Rule Z applied to intervals.
Sourcepub fn hull(&self, other: &Self) -> Self
pub fn hull(&self, other: &Self) -> Self
The union enclosure of two windows — the smallest window containing both.
Trait Implementations§
impl<P: Profile> Copy for Window<P>
u512 only.