types/moment
A Moment is a finite window of time with a start and an end. The helpers here compare a moment with a transaction validity range.
The comparisons ignore the is_inclusive flag of the validity range
bounds, and every infinite bound fails the check. That is stricter than
stdlib’s interval.includes, interval.is_entirely_after, and
interval.is_entirely_before, which honour inclusivity and infinities.
Use those when you need exact interval semantics.
Types
A finite moment of time represented as simple start and end integers.
Constructors
-
Moment { start: Int, end: Int }
A finite list of moments of time.
Alias
Moments = List<Moment>
Functions
Shifts a moment by some integer amount. This is great for incrementing a fixed moment of time, maybe like an epoch boundary by five days.
moment.shift(this_moment, a_day)
Check if a moment data structure is logical: it does not end before it starts and neither end is negative.
moment.is_logical(datum.moment)
Check if a validity range is contained within some moment. This assumes inclusivity.
|start–|lower––upper|–end|
moment.is_contained(datum.moment, this_tx.validity_range)
Check if a validity range of a tx is after a moment. This assumes exclusivity.
|start––end|–|lower––upper|
moment.is_after(datum.moment, this_tx.validity_range)