1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// SPDX-License-Identifier: MIT-0
//! The one set of replacement-block shape rules, shared by both layers.
//!
//! A caller's [`StaticSessionExceptions`](crate::StaticSessionExceptions) record
//! and a built-in [`HolidayKind::ReplacementBlocks`](crate::HolidayKind::ReplacementBlocks)
//! row state the same thing — a complete ordered set of [`ExceptionBlock`]s
//! replacing one venue-local trade date — so one function validates both rather
//! than two that have to be kept in step by hand. The caller's layer reports the
//! violation as a
//! [`StaticSessionExceptionsError`](crate::StaticSessionExceptionsError); the
//! built-in fence turns it into a build failure. Neither layer states a rule of
//! its own, so a rule added here reaches both, and the caller-facing tests that
//! fence these rules fence the built-in rows' rules as well.
use ExceptionBlock;
/// The upper bound of a venue-local seconds-since-midnight close.
///
/// `86_400` is the end-exclusive close of a complete local day and is a legal
/// close; the matching open bound is one second lower, exactly as
/// [`StaticDayPolicy`](crate::StaticDayPolicy) validates a caller's scalar
/// records.
const SECONDS_PER_DAY: u32 = 86_400;
/// Why a replacement block set is not well formed.
///
/// The variants carry the offending block's position so both callers can name
/// it: the error a caller sees and the message a build failure prints both point
/// at the block that broke the rule.
pub
/// Returns the first reason `blocks` is not a well-formed replacement set.
///
/// Blocks are visited in order and, within one block, in the order the rules are
/// written here, so a set with several faults always reports the same one: the
/// earliest block, and within it the earliest rule. Both callers depend on that
/// being deterministic — a caller reads it as a validation error and a build
/// reads it as the reason the constant evaluation stopped.
///
/// The rules are the ones a replacement set has always been held to. They are
/// stated once, here, so the built-in table cannot drift from the caller's
/// records: the ordering rule is the order every replacement scan relies on, the
/// instant ranges are the `DayPolicy` ranges, and the no-wrap rule at offset `0`
/// is what keeps a trade date from closing after its own name.
///
/// The ordering rule is **non-decreasing**, deliberately: it rejects a block
/// that starts before its predecessor and accepts one that starts at the same
/// `(open_day_offset, open_ssm)`. Two blocks may legitimately share an opening
/// instant when they state different kinds — an order-entry phase and the
/// tradeable session that begins with it — so equality is not a duplicate. See
/// [`DateException::ReplaceSessions`](crate::DateException::ReplaceSessions),
/// which states the same contract to callers.
pub const