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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
//! Response authority bound to `ClientRequest::Enrollment` (`0x0001`).
use alloc::boxed::Box;
use super::super::{
ConnectionConversationBindingOccupied, ConnectionConversationCapacityExceeded,
ConversationOrderExhausted, ConversationSequenceExhausted, EnrollBound, EnrollmentEnvelope,
EnrollmentKnown, EnrollmentReceiptCapacityScope, Generation, IdentityCapacityExceeded,
MarkerClosureCapacityExceeded, ObserverBackpressure, ObserverBackpressureState,
ReceiptCapacityExceeded, ReceiptExpired, ReceiptExpiryReason, ReceiptReplay, ResponseEnvelope,
Retired, ServerDiscriminant, ServerValue,
};
/// Server response bound to one enrollment request.
///
/// Constructors exist only for the outcomes the frozen R-D1 register admits
/// for enrollment; every other pairing is a compile error by construction.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct EnrollmentResponse {
value: ServerValue,
}
impl EnrollmentResponse {
/// First decoded semantic operation for an untracked conversation
/// exceeded the connection-conversation limit (register row 5641).
#[must_use]
pub const fn connection_conversation_capacity_exceeded(
request: EnrollmentEnvelope,
limit: u64,
) -> Self {
Self {
value: ServerValue::ConnectionConversationCapacityExceeded(
ConnectionConversationCapacityExceeded::SemanticRequest {
request: ResponseEnvelope::Enrollment(request),
limit,
},
),
}
}
/// Enrollment binding attempt found an occupied connection/conversation
/// slot (register row 5643).
#[must_use]
pub const fn connection_conversation_binding_occupied(request: &EnrollmentEnvelope) -> Self {
Self {
value: ServerValue::ConnectionConversationBindingOccupied(
ConnectionConversationBindingOccupied::Enrollment {
conversation_id: request.conversation_id,
enrollment_token: request.enrollment_token,
},
),
}
}
/// Enrollment required an unreserved `transaction_order` major and the
/// conversation order is exhausted (register row 5644).
///
/// The payload is minted only by the shared order allocator invoked with
/// this request's own envelope.
pub(crate) const fn from_conversation_order_exhausted(
value: Box<ConversationOrderExhausted>,
) -> Self {
Self {
value: ServerValue::ConversationOrderExhausted(value),
}
}
/// Enrollment token mapping resolved to a tombstone (register row 5653).
///
/// The payload is minted only by `lookup_enrollment` for this exact
/// request.
pub(crate) const fn from_retired(value: Retired) -> Self {
Self {
value: ServerValue::Retired(value),
}
}
/// Closure-checked enrollment admission exceeded marker-closure capacity
/// (register row 5649).
///
/// The payload is minted only by the shared remaining-closure selector
/// invoked with this request's own envelope.
pub(crate) const fn from_marker_closure_capacity_exceeded(
value: Box<MarkerClosureCapacityExceeded>,
) -> Self {
Self {
value: ServerValue::MarkerClosureCapacityExceeded(value),
}
}
/// Successful enrollment attach (register row 5650).
#[must_use]
pub const fn enroll_bound(value: EnrollBound) -> Self {
Self {
value: ServerValue::EnrollBound(value),
}
}
/// Post-provenance replay for a live non-retired mapped identity
/// (register row 5651).
#[must_use]
pub const fn enrollment_known(value: EnrollmentKnown) -> Self {
Self {
value: ServerValue::EnrollmentKnown(value),
}
}
/// Exact enrollment provenance window response (register row 5652).
///
/// The payload is minted only by `lookup_enrollment` for this exact
/// request.
pub(crate) const fn from_receipt_expired(value: ReceiptExpired) -> Self {
Self {
value: ServerValue::ReceiptExpired(value),
}
}
/// Exact enrollment provenance window response with the flattened
/// request-echo fields derived from the request's own envelope (register
/// row 5652) — the same public field-wise form as the credential-attach
/// authority's `receipt_expired`.
///
/// The participant id and both generations must come from the identity
/// resolved by the lifetime token mapping and its retained provenance
/// record; `presented_generation` is structurally `None` for enrollment
/// and the marker option is structurally absent.
#[must_use]
pub const fn receipt_expired(
request: &EnrollmentEnvelope,
participant_id: u64,
result_generation: Generation,
current_generation: Generation,
reason: ReceiptExpiryReason,
) -> Self {
Self {
value: ServerValue::ReceiptExpired(ReceiptExpired::Enrollment {
conversation_id: request.conversation_id,
token: request.enrollment_token,
participant_id,
result_generation,
current_generation,
reason,
}),
}
}
/// One of the three receipt/provenance scopes reachable before identity
/// mint is full (register row 5654).
#[must_use]
pub const fn receipt_capacity_exceeded(
request: EnrollmentEnvelope,
scope: EnrollmentReceiptCapacityScope,
limit: u64,
occupied: u64,
) -> Self {
Self {
value: ServerValue::ReceiptCapacityExceeded(ReceiptCapacityExceeded::Enrollment {
request,
scope,
limit,
occupied,
}),
}
}
/// Server or conversation identity capacity is full (register row 5655).
#[must_use]
pub const fn identity_capacity_exceeded(value: IdentityCapacityExceeded) -> Self {
Self {
value: ServerValue::IdentityCapacityExceeded(value),
}
}
/// Hard-observer retention refused the enrollment append (register row
/// 5656).
#[must_use]
pub const fn observer_backpressure(
request: EnrollmentEnvelope,
state: ObserverBackpressureState,
) -> Self {
Self {
value: ServerValue::ObserverBackpressure(ObserverBackpressure::Enrollment {
request,
state,
}),
}
}
/// Hard-observer retention refusal minted by the shared observer-floor
/// selector invoked with this request's own envelope (register row 5656).
pub(crate) const fn from_observer_backpressure(value: ObserverBackpressure) -> Self {
Self {
value: ServerValue::ObserverBackpressure(value),
}
}
/// Canonical resulting sequence-reserve check failed (register row 5657).
///
/// The payload is minted only by the shared sequence allocator invoked
/// with this request's own envelope.
pub(crate) const fn from_conversation_sequence_exhausted(
value: Box<ConversationSequenceExhausted>,
) -> Self {
Self {
value: ServerValue::ConversationSequenceExhausted(value),
}
}
/// Byte-identical receipt replay whose exact binding epoch still occupies
/// its origin slot (register row 5663).
#[must_use]
pub const fn bound(value: EnrollBound) -> Self {
Self {
value: ServerValue::Bound(ReceiptReplay::Enrollment(value)),
}
}
/// Byte-identical receipt replay whose origin slot is empty, replaced, or
/// at a later epoch (register row 5663).
#[must_use]
pub const fn unbound_receipt(value: EnrollBound) -> Self {
Self {
value: ServerValue::UnboundReceipt(ReceiptReplay::Enrollment(value)),
}
}
/// Byte-identical live-receipt replay minted by `lookup_enrollment`
/// (register row 5663).
pub(crate) const fn from_bound(value: ReceiptReplay) -> Self {
Self {
value: ServerValue::Bound(value),
}
}
/// Byte-identical unbound-receipt replay minted by `lookup_enrollment`
/// (register row 5663).
pub(crate) const fn from_unbound_receipt(value: ReceiptReplay) -> Self {
Self {
value: ServerValue::UnboundReceipt(value),
}
}
/// Borrows the bound wire value for encoding or inspection.
#[must_use]
pub const fn server_value(&self) -> &ServerValue {
&self.value
}
/// Returns the bound value's exact wire discriminant.
#[must_use]
pub const fn discriminant(&self) -> ServerDiscriminant {
self.value.discriminant()
}
/// Moves the bound wire value out for transmission.
#[must_use]
pub fn into_server_value(self) -> ServerValue {
self.value
}
}