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
//! The envelope microschemas, as authored `.saiv` source.
//!
//! Two tiny schemas compose around every method's own data schema:
//!
//! ```text
//! .!schema:kaivrpc/response-head ::status — the verdict first
//! .!schema:<method data schema> fields under /data
//! .!schema:kaivrpc/response-tail ::error? + ::n — marker last
//! ```
//!
//! Composition order is composed field order, so the ordered scan
//! enforces the layout: `status` cannot arrive after the data, and
//! the tail cannot be missing. That last property is the useful
//! one — a truncated stream fails validation with no protocol
//! machinery, because `::n` is schema-required and last.
//!
//! Publish these under the names in [`HEAD_NAME`] / [`TAIL_NAME`]
//! (or your own namespace — pass the names to
//! [`Envelope::with_schemas`](crate::Envelope::with_schemas)) so
//! clients can resolve what a response declares.
/// The registry name a response's head schema is declared under.
pub const HEAD_NAME: &str = "kaivrpc/response-head";
/// The registry name a response's tail schema is declared under.
pub const TAIL_NAME: &str = "kaivrpc/response-tail";
/// The registry name of the generic request envelope.
pub const REQUEST_NAME: &str = "kaivrpc/request";
/// The response head: the verdict, before any data flows.
pub const HEAD_SAIV: &str = include_str!;
/// The response tail: why it died (null on success) and the
/// element count that doubles as the end-of-stream marker.
pub const TAIL_SAIV: &str = include_str!;
/// The generic request envelope: a method name. `/params` is
/// typed by the method's own request schema, which composes this.
pub const REQUEST_SAIV: &str = include_str!;