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
/// Default SSE `Content-Type` header value with UTF-8 charset.
pub const SSE_CONTENT_TYPE: &str = "text/event-stream; charset=utf-8";
/// Default `Cache-Control` directive for SSE streams.
pub const SSE_CACHE_CONTROL: &str = "no-cache";
/// Reverse-proxy buffering disable header name for SSE streams.
pub const SSE_ACCEL_BUFFERING_HEADER: &str = "x-accel-buffering";
/// Reverse-proxy buffering disable header value for SSE streams.
pub const SSE_ACCEL_BUFFERING_VALUE: &str = "no";
/// Default heartbeat interval in milliseconds.
pub const DEFAULT_SSE_HEARTBEAT_MS: u64 = 15_000;
/// Default client reconnect retry hint in milliseconds.
pub const DEFAULT_SSE_RETRY_MS: u64 = 3_000;
/// Default bounded replay history retained per topic for `Last-Event-ID` resume.
pub const DEFAULT_SSE_REPLAY_CAPACITY: usize = 64;
/// Default broadcast channel capacity per topic.
pub const DEFAULT_SSE_CHANNEL_CAPACITY: usize = 256;
/// Default maximum number of active topics allowed in one [`SseHub`](crate::SseHub).
pub const DEFAULT_SSE_MAX_TOPICS: usize = 1024;
/// Number of lock-striped topic shards inside [`crate::SseHub`].
pub const SSE_SHARD_COUNT: usize = 64;
/// SSE `id` field prefix.
pub const SSE_FIELD_ID: &str = "id: ";
/// SSE `event` field prefix.
pub const SSE_FIELD_EVENT: &str = "event: ";
/// SSE `retry` field prefix.
pub const SSE_FIELD_RETRY: &str = "retry: ";
/// SSE `data` field prefix.
pub const SSE_FIELD_DATA: &str = "data: ";
/// SSE comment line prefix.
pub const SSE_COMMENT_PREFIX: &str = ": ";
/// Default heartbeat comment payload.
pub const SSE_HEARTBEAT_COMMENT: &str = "keep-alive";
/// Pre-encoded static SSE keep-alive heartbeat wire frame.
pub const SSE_HEARTBEAT_FRAME: & = b": keep-alive\n\n";
/// Maximum decimal digit length of an unsigned 64-bit integer.
pub const U64_DECIMAL_BUF_LEN: usize = 20;
/// Error display text when an [`SseHub`](crate::SseHub) reaches its topic limit.
pub const ERR_TOPIC_LIMIT: &str = "SSE topic limit reached";
/// Error display text when a topic broadcast channel has closed.
pub const ERR_CHANNEL_CLOSED: &str = "SSE topic channel closed";
/// Multiplicative 64-bit mixing constant for zero-allocation [`FxHasher`].
pub const FX_HASH_K: u64 = 0x517c_c1b7_2722_0a95;
/// SWAR per-byte low-bit mask (`0x01` replicated across 8 bytes).
pub const SWAR_LO_ONES: u64 = 0x0101_0101_0101_0101;
/// SWAR per-byte high-bit mask (`0x80` replicated across 8 bytes).
pub const SWAR_HI_BITS: u64 = 0x8080_8080_8080_8080;
/// SWAR replicated `\r` byte (`0x0D`) across 8 lanes.
pub const SWAR_CR_MASK: u64 = 0x0D0D_0D0D_0D0D_0D0D;
/// SWAR replicated `\n` byte (`0x0A`) across 8 lanes.
pub const SWAR_LF_MASK: u64 = 0x0A0A_0A0A_0A0A_0A0A;
/// ASCII line-feed byte (`\n`).
pub const BYTE_LF: u8 = b'\n';
/// ASCII carriage-return byte (`\r`).
pub const BYTE_CR: u8 = b'\r';
/// ASCII zero digit byte (`'0'`).
pub const BYTE_ZERO: u8 = b'0';
/// Stack buffer capacity in bytes for zero-allocation [`SseStream::send_event`].
pub const SSE_EVENT_STACK_CAP: usize = 512;
/// Stack buffer capacity in bytes for zero-allocation [`SseStream::send_comment`].
pub const SSE_COMMENT_STACK_CAP: usize = 256;
/// Stack buffer capacity in bytes for the initial SSE reconnect retry hint frame.
pub const SSE_RETRY_HINT_STACK_CAP: usize = 64;
/// Maximum bytes coalesced per single wire send in [`SseStream::serve_subscription`].
pub const SSE_COALESCE_MAX_BYTES: usize = 32 * 1024;
/// Two-digit ASCII decimal lookup pairs for `00..=99`.
pub const DEC_DIGITS_LUT: & = b"00010203040506070809\
10111213141516171819\
20212223242526272829\
30313233343536373839\
40414243444546474849\
50515253545556575859\
60616263646566676869\
70717273747576777879\
80818283848586878889\
90919293949596979899";
/// Static zero string for decimal formatting fast path.
pub const ZERO_STR: &str = "0";