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
/// Canonical gRPC `Content-Type` header value.
pub const GRPC_CONTENT_TYPE: &str = "application/grpc";
/// Response header carrying the numeric gRPC status code.
pub const GRPC_STATUS_HEADER: &str = "grpc-status";
/// Response header carrying the percent-encoded gRPC error message.
pub const GRPC_MESSAGE_HEADER: &str = "grpc-message";
/// Request/response header identifying the gRPC payload compression coding.
pub const GRPC_ENCODING_HEADER: &str = "grpc-encoding";
/// Request header carrying the client-supplied RPC timeout budget.
pub const GRPC_TIMEOUT_HEADER: &str = "grpc-timeout";
/// Default maximum decoded gRPC message size (4 MiB).
pub const DEFAULT_GRPC_MAX_MESSAGE_SIZE: usize = 4 * 1024 * 1024;
/// Length of the 5-byte gRPC Length-Prefixed-Message header.
pub const GRPC_FRAME_HEADER_LEN: usize = 5;
/// Default decompression scratch buffer size.
pub const GRPC_DECOMPRESS_BUF_SIZE: usize = 4096;
/// Fast-path stack buffer capacity for direct HTTP/1.1 gRPC wire assembly of small messages.
pub const GRPC_WIRE_FAST_STACK_CAP: usize = 512;
/// Stack buffer capacity for direct HTTP/1.1 gRPC wire assembly without heap allocation.
pub const GRPC_WIRE_STACK_CAP: usize = 4096;
/// Maximum registered method count scanned linearly in [`GrpcRouter`] before hashing.
pub const GRPC_SMALL_METHODS_LIMIT: usize = 4;
/// SWAR high-bit mask for testing 8 ASCII bytes simultaneously.
pub const SWAR_HIGH_BITS: u64 = 0x8080_8080_8080_8080;
/// SWAR broadcast of `0x20` (ASCII space) for `< 0x20` range check.
pub const SWAR_SPACE_BROADCAST: u64 = 0x2020_2020_2020_2020;
/// SWAR broadcast of `0x01` for `0x7f` and byte-equality tests.
pub const SWAR_ONES_BROADCAST: u64 = 0x0101_0101_0101_0101;
/// SWAR broadcast of `b'%'` (`0x25`) for percent-sign detection.
pub const SWAR_PERCENT_BROADCAST: u64 = 0x2525_2525_2525_2525;
/// Stack buffer capacity for formatting `usize` content-length values.
pub const GRPC_LEN_STACK_BUF: usize = 20;
/// Prebuilt HTTP/1.1 gRPC response wire prefix up to the `grpc-status` code.
pub const GRPC_WIRE_PREFIX: & =
b"HTTP/1.1 200 OK\r\nconnection: keep-alive\r\ncontent-type: application/grpc\r\ngrpc-status: ";
/// Prebuilt HTTP/1.1 header segment introducing `content-length`.
pub const GRPC_WIRE_CL: & = b"\r\ncontent-length: ";
/// HTTP/1.1 double-CRLF header terminator preceding the framed gRPC payload.
pub const GRPC_WIRE_END: & = b"\r\n\r\n";
/// Uppercase hexadecimal digits for RFC 3986 percent-encoding of `grpc-message`.
pub const GRPC_HEX_UPPER: & = b"0123456789ABCDEF";
/// Pre-formatted numeric strings for canonical gRPC status codes `0..=16`.
pub const GRPC_STATUS_CODE_STRS: = ;
/// Identity encoding token indicating uncompressed gRPC frames.
pub const GRPC_IDENTITY_ENCODING: &str = "identity";
/// Error text when a gRPC payload is truncated before the 5-byte frame header.
pub const ERR_GRPC_TRUNCATED_HEADER: &str = "Truncated gRPC frame header";
/// Error text when a gRPC payload has an invalid compression flag (`> 1`).
pub const ERR_GRPC_INVALID_FLAG: &str = "Invalid gRPC compression flag";
/// Error text when a gRPC payload declares a length exceeding the configured cap.
pub const ERR_GRPC_MSG_TOO_LARGE: &str = "gRPC message exceeds max_message_size";
/// Error text when a gRPC payload ends before the declared frame length.
pub const ERR_GRPC_TRUNCATED_BODY: &str = "Truncated gRPC frame payload";
/// Error text when a frame is flagged compressed without a supported `grpc-encoding`.
pub const ERR_GRPC_UNSUPPORTED_ENCODING: &str = "Unsupported or missing grpc-encoding";
/// Error text when a gRPC method path is not registered in [`GrpcRouter`].
pub const ERR_GRPC_UNIMPLEMENTED: &str = "gRPC method not implemented";
/// Error text when a gRPC handler exceeds the caller's `grpc-timeout` deadline.
pub const ERR_GRPC_DEADLINE_EXCEEDED: &str = "gRPC deadline exceeded";
/// ASCII digit zero byte (`0`).
pub const ASCII_ZERO: u8 = b'0';
/// ASCII percent byte (`%`).
pub const ASCII_PERCENT: u8 = b'%';
/// ASCII plus byte (`+`).
pub const ASCII_PLUS: u8 = b'+';
/// ASCII semicolon byte (`;`).
pub const ASCII_SEMICOLON: u8 = b';';
/// gRPC timeout unit byte for hours (`H`).
pub const TIMEOUT_UNIT_HOURS: u8 = b'H';
/// gRPC timeout unit byte for minutes (`M`).
pub const TIMEOUT_UNIT_MINUTES: u8 = b'M';
/// gRPC timeout unit byte for seconds (`S`).
pub const TIMEOUT_UNIT_SECONDS: u8 = b'S';
/// gRPC timeout unit byte for milliseconds (`m`).
pub const TIMEOUT_UNIT_MILLIS: u8 = b'm';
/// gRPC timeout unit byte for microseconds (`u`).
pub const TIMEOUT_UNIT_MICROS: u8 = b'u';
/// gRPC timeout unit byte for nanoseconds (`n`).
pub const TIMEOUT_UNIT_NANOS: u8 = b'n';