http_constant/common/
const.rs

1use crate::*;
2
3/// A single space character.
4///
5/// This constant is used to represent a space character in string
6/// or byte operations.
7pub const SPACE: &str = " ";
8
9/// The byte representation of a single space character.
10///
11/// This constant provides the byte equivalent of the space character
12/// for use in low-level operations.
13pub const SPACE_U8: u8 = SPACE.as_bytes()[0];
14
15/// A tab character.
16///
17/// This constant is used to represent a tab character in string
18/// or byte operations.
19pub const TAB: &str = "\t";
20
21/// The byte representation of a tab character.
22///
23/// This constant provides the byte equivalent of the tab character
24/// for use in low-level operations.
25pub const TAB_U8: u8 = TAB.as_bytes()[0];
26
27/// A line break character (newline).
28///
29/// This constant is used to represent a line break character in
30/// string or byte operations.
31pub const BR: &str = "\n";
32
33/// A const byte slice representation of the string `BR`.
34pub const BR_BYTES: &[u8] = BR.as_bytes();
35
36/// A colon followed by a space (`: `).
37///
38/// This constant is commonly used in formatted strings, such as
39/// headers or key-value pairs, where a colon and a space are needed.
40pub const COLON_SPACE: &str = ": ";
41
42/// The byte representation of the first character in the `COLON_SPACE`.
43///
44/// This constant provides the byte equivalent of the colon character
45/// from the `COLON_SPACE` string.
46pub const COLON_SPACE_BYTES: &[u8] = COLON_SPACE.as_bytes();
47
48/// A colon followed by a space symbol (`:`).
49///
50/// This constant is commonly used in formatted strings, such as
51/// headers or key-value pairs, where a colon and a space are needed.
52pub const COLON_SPACE_SYMBOL: &str = ":";
53
54/// A query symbol (`?`).
55///
56/// This constant represents the question mark character, which is
57/// commonly used to denote the beginning of a query string in a URL.
58pub const QUERY_SYMBOL: &str = "?";
59
60/// A hash symbol (`#`).
61///
62/// This constant represents the hash character, which is used to
63/// identify a fragment or anchor in a URL.
64pub const HASH_SYMBOL: &str = "#";
65
66/// An empty string.
67///
68/// This constant represents an empty string, which can be used as a
69/// default or placeholder value.
70pub const EMPTY_STR: &str = "";
71
72/// The default host address.
73///
74/// This constant represents the default host address, which is typically
75/// used to bind a server to all available network interfaces.
76pub const DEFAULT_HOST: &str = "0.0.0.0";
77
78/// The default web port.
79///
80/// This constant represents the default port for HTTP traffic.
81pub const DEFAULT_WEB_PORT: usize = 80;
82
83/// An HTTP line break (`\r\n`).
84///
85/// This constant represents the standard line break sequence used in
86/// the HTTP protocol.
87pub const HTTP_BR: &str = "\r\n";
88
89/// The byte representation of an HTTP line break.
90///
91/// This constant provides the byte equivalent of the HTTP line break
92/// for use in low-level network operations.
93pub const HTTP_BR_BYTES: &[u8] = HTTP_BR.as_bytes();
94
95/// A double HTTP line break (`\r\n\r\n`).
96///
97/// This constant represents the sequence used to separate headers
98/// from the body in an HTTP message.
99pub const HTTP_DOUBLE_BR: &str = "\r\n\r\n";
100
101/// The byte representation of a double HTTP line break.
102///
103/// This constant provides the byte equivalent of the double HTTP line
104/// break for use in parsing and constructing HTTP messages.
105pub const HTTP_DOUBLE_BR_BYTES: &[u8] = HTTP_DOUBLE_BR.as_bytes();
106
107/// The default HTTP path.
108///
109/// This constant represents the root path of a URL, which is used
110/// when no specific path is provided.
111pub const DEFAULT_HTTP_PATH: &str = "/";
112
113/// The byte representation of the default HTTP path.
114///
115/// This constant provides the byte equivalent of the default HTTP path
116/// for use in low-level operations.
117pub const DEFAULT_HTTP_PATH_BYTES: &[u8] = DEFAULT_HTTP_PATH.as_bytes();
118
119/// An ampersand character (`&`).
120///
121/// This constant represents the ampersand character, which is used
122/// to separate query parameters in a URL.
123pub const AND: &str = "&";
124
125/// The byte representation of an ampersand character.
126///
127/// This constant provides the byte equivalent of the ampersand character
128/// for use in URL parsing and construction.
129pub const AND_BYTES: &[u8] = AND.as_bytes();
130
131/// An equal sign (`=`).
132///
133/// This constant represents the equal sign, which is used to separate
134/// keys and values in query parameters.
135pub const EQUAL: &str = "=";
136
137/// The byte representation of an equal sign.
138///
139/// This constant provides the byte equivalent of the equal sign for
140/// use in URL parsing and construction.
141pub const EQUAL_BYTES: &[u8] = EQUAL.as_bytes();
142
143/// The string representation of the number zero.
144///
145/// This constant represents the character '0' as a string.
146pub const ZERO_STR: &str = "0";
147
148/// The byte representation of the number zero.
149///
150/// This constant provides the byte equivalent of the character '0'.
151pub const ZERO_STR_BYTES: &[u8] = ZERO_STR.as_bytes();
152
153/// The default buffer size.
154///
155/// This constant defines the default size for buffers used in I/O
156/// operations, such as reading from a network stream.
157pub const DEFAULT_BUFFER_SIZE: usize = 4096;
158
159/// The default maximum number of redirect times.
160///
161/// This constant specifies the default limit for the number of times
162/// an HTTP client should follow a redirect.
163pub const DEFAULT_MAX_REDIRECT_TIMES: usize = 8;
164
165/// The default timeout value.
166///
167/// This constant represents the default timeout for operations, which
168/// is set to the maximum value of `u64` to indicate no timeout.
169pub const DEFAULT_TIMEOUT: u64 = u64::MAX;
170
171/// A point character (`.`).
172///
173/// This constant represents the period or dot character, which is
174/// often used as a separator in file names or domain names.
175pub const POINT: &str = ".";
176
177/// The root path.
178///
179/// This constant represents the root path in a file system or URL.
180pub const ROOT_PATH: &str = "/";
181
182/// A semicolon character (`;`).
183///
184/// This constant represents the semicolon character, which is used
185/// as a separator in various contexts.
186pub const SEMICOLON: &str = ";";
187
188/// A semicolon followed by a space (`; `).
189///
190/// This constant represents a semicolon followed by a space, which is
191/// commonly used as a separator in formatted text.
192pub const SEMICOLON_SPACE: &str = "; ";
193
194/// A globally unique identifier (GUID) for WebSocket connections.
195///
196/// This constant is used in the WebSocket handshake process to create
197/// the `Sec-WebSocket-Accept` header.
198pub const GUID: &[u8; 36] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
199
200/// The initial hash state for SHA-1.
201///
202/// This constant represents the initial values used in the SHA-1
203/// hashing algorithm.
204pub const HASH_STATE: [u32; 5] = [
205    0x67452301u32,
206    0xEFCDAB89,
207    0x98BADCFE,
208    0x10325476,
209    0xC3D2E1F0,
210];
211
212/// The Base64 character set table.
213///
214/// This constant contains the characters used for Base64 encoding.
215pub const BASE64_CHARSET_TABLE: &[u8] =
216    b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
217
218/// The maximum frame size for WebSockets.
219///
220/// This constant defines the maximum size of a WebSocket frame that
221/// can be processed.
222pub const MAX_FRAME_SIZE: usize = 65535;
223
224/// The maximum number of attempts to decode a UTF-8 character.
225///
226/// This constant specifies the maximum number of bytes that can be
227/// part of a single UTF-8 character.
228pub const MAX_UTF8_ATTEMPTS: usize = 4;
229
230/// The default socket address.
231///
232/// This constant represents a default, unspecified socket address.
233pub const DEFAULT_SOCKET_ADDR: SocketAddr =
234    SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), 0));
235
236/// The loopback socket address (127.0.0.1).
237///
238/// This constant represents the loopback address, which is used for
239/// local network communication.
240pub const SOCKET_ADDR_127_0_0_1: SocketAddr =
241    SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 0));
242
243/// The string "hyperlane".
244///
245/// This constant is used for identification or naming purposes.
246pub const HYPERLANE: &str = "hyperlane";
247
248/// The string "Hyperlane" in PascalCase.
249///
250/// This constant is a PascalCase version of the "hyperlane" string.
251pub const HYPERLANE_PASCAL_CASE: &str = "Hyperlane";
252
253/// The string "Hyperlane" in UpperCase.
254///
255/// This constant is a UpperCase version of the "hyperlane" string.
256pub const HYPERLANE_UPPERCASE: &str = "HYPERLANE";
257
258/// The default setting for inner printing.
259///
260/// This constant determines whether internal printing is enabled by
261/// default.
262pub const DEFAULT_INNER_PRINT: bool = true;
263
264/// The default setting for inner logging.
265///
266/// This constant determines whether internal logging is enabled by
267/// default.
268pub const DEFAULT_INNER_LOG: bool = true;
269
270/// The default setting for TCP_NODELAY.
271///
272/// This constant specifies the default value for the `TCP_NODELAY`
273/// socket option.
274pub const DEFAULT_NODELAY: Option<bool> = None;
275
276/// The default setting for socket linger.
277///
278/// This constant specifies the default value for the `SO_LINGER`
279/// socket option.
280pub const DEFAULT_LINGER: Option<Duration> = None;
281
282/// The default time-to-live (TTL) setting.
283///
284/// This constant specifies the default value for the IP_TTL socket
285/// option.
286pub const DEFAULT_TTI: Option<u32> = None;
287
288/// The string "warning".
289///
290/// This constant is used to represent a warning message type.
291pub const WARNING: &str = "warning";
292
293/// The string "success".
294///
295/// This constant is used to represent a success message type.
296pub const SUCCESS: &str = "success";
297
298/// The string "fail".
299///
300/// This constant is used to represent a failure message type.
301pub const FAIL: &str = "fail";
302
303/// The string "error".
304///
305/// This constant is used to represent an error message type.
306pub const ERROR: &str = "error";
307
308/// The string "info".
309///
310/// This constant is used to represent an informational message type.
311pub const INFO: &str = "info";
312
313/// The string "debug".
314///
315/// This constant is used to represent a debug message type.
316pub const DEBUG: &str = "debug";
317
318/// The string "plain".
319///
320/// This constant is used to represent plain text content.
321pub const PLAIN: &str = "plain";
322
323/// The string "binary".
324///
325/// This constant is used to represent binary content.
326pub const BINARY: &str = "binary";