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/// A const byte slice representation of the string `SPACE`.
10pub const SPACE_BYTES: &[u8] = SPACE.as_bytes();
11
12/// The byte representation of a single space character.
13///
14/// This constant provides the byte equivalent of the space character
15/// for use in low-level operations.
16pub const SPACE_U8: u8 = SPACE_BYTES[0];
17
18/// A tab character.
19///
20/// This constant is used to represent a tab character in string
21/// or byte operations.
22pub const TAB: &str = "\t";
23
24/// A const byte slice representation of the string `TAB`.
25pub const TAB_BYTES: &[u8] = TAB.as_bytes();
26
27/// The byte representation of a tab character.
28///
29/// This constant provides the byte equivalent of the tab character
30/// for use in low-level operations.
31pub const TAB_U8: u8 = TAB_BYTES[0];
32
33/// A line break character (newline).
34///
35/// This constant is used to represent a line break character in
36/// string or byte operations.
37pub const BR: &str = "\n";
38
39/// A const byte slice representation of the string `BR`.
40pub const BR_BYTES: &[u8] = BR.as_bytes();
41
42/// The byte representation of a line break character.
43///
44/// This constant provides the byte equivalent of the line break character
45/// for use in low-level operations.
46pub const BR_U8: u8 = BR_BYTES[0];
47
48/// A double line break.
49pub const DOUBLE_BR: &str = "\n\n";
50
51/// A const byte slice representation of the string `DOUBLE_BR`.
52pub const DOUBLE_BR_BYTES: &[u8] = DOUBLE_BR.as_bytes();
53
54/// A colon followed by a space (`: `).
55///
56/// This constant is commonly used in formatted strings, such as
57/// headers or key-value pairs, where a colon and a space are needed.
58pub const COLON_SPACE: &str = ": ";
59
60/// The byte representation of the first character in the `COLON_SPACE`.
61///
62/// This constant provides the byte equivalent of the colon character
63/// from the `COLON_SPACE` string.
64pub const COLON_SPACE_BYTES: &[u8] = COLON_SPACE.as_bytes();
65
66/// A colon followed by a space symbol (`:`).
67///
68/// This constant is commonly used in formatted strings, such as
69/// headers or key-value pairs, where a colon and a space are needed.
70pub const COLON: &str = ":";
71
72/// A const byte slice representation of the string `COLON`.
73pub const COLON_BYTES: &[u8] = COLON.as_bytes();
74
75/// The byte representation of a colon character.
76///
77/// This constant provides the byte equivalent of the colon character
78/// for use in low-level operations.
79pub const COLON_U8: u8 = COLON_BYTES[0];
80
81/// A query symbol (`?`).
82///
83/// This constant represents the question mark character, which is
84/// commonly used to denote the beginning of a query string in a URL.
85pub const QUERY: &str = "?";
86
87/// A const byte slice representation of the string `QUERY`.
88pub const QUERY_BYTES: &[u8] = QUERY.as_bytes();
89
90/// The byte representation of a query symbol.
91///
92/// This constant provides the byte equivalent of the query character
93/// for use in low-level operations.
94pub const QUERY_U8: u8 = QUERY_BYTES[0];
95
96/// The string ",".
97///
98/// This constant is used to represent a comma.
99pub const COMMA: &str = ",";
100
101/// A const byte slice representation of the string `COMMA`.
102pub const COMMA_BYTES: &[u8] = COMMA.as_bytes();
103
104/// The byte representation of a comma character.
105///
106/// This constant provides the byte equivalent of the comma character
107/// for use in low-level operations.
108pub const COMMA_U8: u8 = COMMA_BYTES[0];
109
110/// A hash symbol (`#`).
111///
112/// This constant represents the hash character, which is used to
113/// identify a fragment or anchor in a URL.
114pub const HASH: &str = "#";
115
116/// A const byte slice representation of the string `HASH`.
117pub const HASH_BYTES: &[u8] = HASH.as_bytes();
118
119/// The byte representation of a hash symbol.
120///
121/// This constant provides the byte equivalent of the hash character
122/// for use in low-level operations.
123pub const HASH_U8: u8 = HASH_BYTES[0];
124
125/// An empty string.
126///
127/// This constant represents an empty string, which can be used as a
128/// default or placeholder value.
129pub const EMPTY_STR: &str = "";
130
131/// A const byte slice representation of the string `EMPTY_STR`.
132pub const EMPTY_STR_BYTES: &[u8] = EMPTY_STR.as_bytes();
133
134/// The default host address.
135///
136/// This constant represents the default host address, which is typically
137/// used to bind a server to all available network interfaces.
138pub const DEFAULT_HOST: &str = "0.0.0.0";
139
140/// A const byte slice representation of the string `DEFAULT_HOST`.
141pub const DEFAULT_HOST_BYTES: &[u8] = DEFAULT_HOST.as_bytes();
142
143/// The default web port.
144///
145/// This constant represents the default port for HTTP traffic.
146pub const DEFAULT_WEB_PORT: usize = 80;
147
148/// An HTTP line break (`\r\n`).
149///
150/// This constant represents the standard line break sequence used in
151/// the HTTP protocol.
152pub const HTTP_BR: &str = "\r\n";
153
154/// The byte representation of an HTTP line break.
155///
156/// This constant provides the byte equivalent of the HTTP line break
157/// for use in low-level network operations.
158pub const HTTP_BR_BYTES: &[u8] = HTTP_BR.as_bytes();
159
160/// A double HTTP line break (`\r\n\r\n`).
161///
162/// This constant represents the sequence used to separate headers
163/// from the body in an HTTP message.
164pub const HTTP_DOUBLE_BR: &str = "\r\n\r\n";
165
166/// The byte representation of a double HTTP line break.
167///
168/// This constant provides the byte equivalent of the double HTTP line
169/// break for use in parsing and constructing HTTP messages.
170pub const HTTP_DOUBLE_BR_BYTES: &[u8] = HTTP_DOUBLE_BR.as_bytes();
171
172/// The default HTTP path.
173///
174/// This constant represents the root path of a URL, which is used
175/// when no specific path is provided.
176pub const DEFAULT_HTTP_PATH: &str = "/";
177
178/// The byte representation of the default HTTP path.
179///
180/// This constant provides the byte equivalent of the default HTTP path
181/// for use in low-level operations.
182pub const DEFAULT_HTTP_PATH_BYTES: &[u8] = DEFAULT_HTTP_PATH.as_bytes();
183
184/// An ampersand character (`&`).
185///
186/// This constant represents the ampersand character, which is used
187/// to separate query parameters in a URL.
188pub const AND: &str = "&";
189
190/// The byte representation of an ampersand character.
191///
192/// This constant provides the byte equivalent of the ampersand character
193/// for use in URL parsing and construction.
194pub const AND_BYTES: &[u8] = AND.as_bytes();
195
196/// The byte representation of an ampersand character.
197///
198/// This constant provides the byte equivalent of the ampersand character
199/// for use in low-level operations.
200pub const AND_U8: u8 = AND_BYTES[0];
201
202/// An equal sign (`=`).
203///
204/// This constant represents the equal sign, which is used to separate
205/// keys and values in query parameters.
206pub const EQUAL: &str = "=";
207
208/// The byte representation of an equal sign.
209///
210/// This constant provides the byte equivalent of the equal sign for
211/// use in URL parsing and construction.
212pub const EQUAL_BYTES: &[u8] = EQUAL.as_bytes();
213
214/// The byte representation of an equal sign.
215///
216/// This constant provides the byte equivalent of the equal sign for
217/// use in low-level operations.
218pub const EQUAL_U8: u8 = EQUAL_BYTES[0];
219
220/// The string representation of the number zero.
221///
222/// This constant represents the character '0' as a string.
223pub const ZERO_STR: &str = "0";
224
225/// The byte representation of the number zero.
226///
227/// This constant provides the byte equivalent of the character '0'.
228pub const ZERO_STR_BYTES: &[u8] = ZERO_STR.as_bytes();
229
230/// The byte representation of the number zero.
231///
232/// This constant provides the byte equivalent of the character '0'
233/// for use in low-level operations.
234pub const ZERO_STR_U8: u8 = ZERO_STR_BYTES[0];
235
236/// The default buffer size.
237///
238/// This constant defines the default size for buffers used in I/O
239/// operations, such as reading from a network stream.
240pub const DEFAULT_BUFFER_SIZE: usize = 4096;
241
242/// The default maximum number of redirect times.
243///
244/// This constant specifies the default limit for the number of times
245/// an HTTP client should follow a redirect.
246pub const DEFAULT_MAX_REDIRECT_TIMES: usize = 8;
247
248/// The default timeout value.
249///
250/// This constant represents the default timeout for operations, which
251/// is set to the maximum value of `u64` to indicate no timeout.
252pub const DEFAULT_TIMEOUT: u64 = u64::MAX;
253
254/// A point character (`.`).
255///
256/// This constant represents the period or dot character, which is
257/// often used as a separator in file names or domain names.
258pub const POINT: &str = ".";
259
260/// A const byte slice representation of the string `POINT`.
261pub const POINT_BYTES: &[u8] = POINT.as_bytes();
262
263/// The byte representation of a point character.
264///
265/// This constant provides the byte equivalent of the point character
266/// for use in low-level operations.
267pub const POINT_U8: u8 = POINT_BYTES[0];
268
269/// The root path.
270///
271/// This constant represents the root path in a file system or URL.
272pub const ROOT_PATH: &str = "/";
273
274/// A const byte slice representation of the string `ROOT_PATH`.
275pub const ROOT_PATH_BYTES: &[u8] = ROOT_PATH.as_bytes();
276
277/// The byte representation of the root path character.
278///
279/// This constant provides the byte equivalent of the root path character
280/// for use in low-level operations.
281pub const ROOT_PATH_U8: u8 = ROOT_PATH_BYTES[0];
282
283/// A semicolon character (`;`).
284///
285/// This constant represents the semicolon character, which is used
286/// as a separator in various contexts.
287pub const SEMICOLON: &str = ";";
288
289/// A const byte slice representation of the string `SEMICOLON`.
290pub const SEMICOLON_BYTES: &[u8] = SEMICOLON.as_bytes();
291
292/// The byte representation of a semicolon character.
293///
294/// This constant provides the byte equivalent of the semicolon character
295/// for use in low-level operations.
296pub const SEMICOLON_U8: u8 = SEMICOLON_BYTES[0];
297
298/// A semicolon followed by a space (`; `).
299///
300/// This constant represents a semicolon followed by a space, which is
301/// commonly used as a separator in formatted text.
302pub const SEMICOLON_SPACE: &str = "; ";
303
304/// A const byte slice representation of the string `SEMICOLON_SPACE`.
305pub const SEMICOLON_SPACE_BYTES: &[u8] = SEMICOLON_SPACE.as_bytes();
306
307/// A globally unique identifier (GUID) for WebSocket connections.
308///
309/// This constant is used in the WebSocket handshake process to create
310/// the `Sec-WebSocket-Accept` header.
311pub const GUID: &[u8; 36] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
312
313/// The initial hash state for SHA-1.
314///
315/// This constant represents the initial values used in the SHA-1
316/// hashing algorithm.
317pub const HASH_STATE: [u32; 5] = [
318    0x67452301u32,
319    0xEFCDAB89,
320    0x98BADCFE,
321    0x10325476,
322    0xC3D2E1F0,
323];
324
325/// The Base64 character set table.
326///
327/// This constant contains the characters used for Base64 encoding.
328pub const BASE64_CHARSET_TABLE: &[u8] =
329    b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
330
331/// The maximum frame size for WebSockets.
332///
333/// This constant defines the maximum size of a WebSocket frame that
334/// can be processed.
335pub const MAX_FRAME_SIZE: usize = 65535;
336
337/// The maximum number of attempts to decode a UTF-8 character.
338///
339/// This constant specifies the maximum number of bytes that can be
340/// part of a single UTF-8 character.
341pub const MAX_UTF8_ATTEMPTS: usize = 4;
342
343/// The default socket address.
344///
345/// This constant represents a default, unspecified socket address.
346pub const DEFAULT_SOCKET_ADDR: SocketAddr =
347    SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(0, 0, 0, 0), 0));
348
349/// The loopback socket address (127.0.0.1).
350///
351/// This constant represents the loopback address, which is used for
352/// local network communication.
353pub const SOCKET_ADDR_127_0_0_1: SocketAddr =
354    SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), 0));
355
356/// The string "hyperlane".
357///
358/// This constant is used for identification or naming purposes.
359pub const HYPERLANE: &str = "hyperlane";
360
361/// A const byte slice representation of the string `HYPERLANE`.
362pub const HYPERLANE_BYTES: &[u8] = HYPERLANE.as_bytes();
363
364/// The string "Hyperlane" in PascalCase.
365///
366/// This constant is a PascalCase version of the "hyperlane" string.
367pub const HYPERLANE_PASCAL_CASE: &str = "Hyperlane";
368
369/// A const byte slice representation of the string `HYPERLANE_PASCAL_CASE`.
370pub const HYPERLANE_PASCAL_CASE_BYTES: &[u8] = HYPERLANE_PASCAL_CASE.as_bytes();
371
372/// The string "Hyperlane" in UpperCase.
373///
374/// This constant is a UpperCase version of the "hyperlane" string.
375pub const HYPERLANE_UPPERCASE: &str = "HYPERLANE";
376
377/// A const byte slice representation of the string `HYPERLANE_UPPERCASE`.
378pub const HYPERLANE_UPPERCASE_BYTES: &[u8] = HYPERLANE_UPPERCASE.as_bytes();
379
380/// The default setting for inner printing.
381///
382/// This constant determines whether internal printing is enabled by
383/// default.
384pub const DEFAULT_INNER_PRINT: bool = true;
385
386/// The default setting for inner logging.
387///
388/// This constant determines whether internal logging is enabled by
389/// default.
390pub const DEFAULT_INNER_LOG: bool = true;
391
392/// The default setting for TCP_NODELAY.
393///
394/// This constant specifies the default value for the `TCP_NODELAY`
395/// socket option.
396pub const DEFAULT_NODELAY: Option<bool> = None;
397
398/// The default setting for socket linger.
399///
400/// This constant specifies the default value for the `SO_LINGER`
401/// socket option.
402pub const DEFAULT_LINGER: Option<Duration> = None;
403
404/// The default time-to-live (TTL) setting.
405///
406/// This constant specifies the default value for the IP_TTL socket
407/// option.
408pub const DEFAULT_TTI: Option<u32> = None;
409
410/// The string "warning".
411///
412/// This constant is used to represent a warning message type.
413pub const WARNING: &str = "warning";
414
415/// A const byte slice representation of the string `WARNING`.
416pub const WARNING_BYTES: &[u8] = WARNING.as_bytes();
417
418/// The string "success".
419///
420/// This constant is used to represent a success message type.
421pub const SUCCESS: &str = "success";
422
423/// A const byte slice representation of the string `SUCCESS`.
424pub const SUCCESS_BYTES: &[u8] = SUCCESS.as_bytes();
425
426/// The string "fail".
427///
428/// This constant is used to represent a failure message type.
429pub const FAIL: &str = "fail";
430
431/// A const byte slice representation of the string `FAIL`.
432pub const FAIL_BYTES: &[u8] = FAIL.as_bytes();
433
434/// The string "error".
435///
436/// This constant is used to represent an error message type.
437pub const ERROR: &str = "error";
438
439/// A const byte slice representation of the string `ERROR`.
440pub const ERROR_BYTES: &[u8] = ERROR.as_bytes();
441
442/// The string "info".
443///
444/// This constant is used to represent an informational message type.
445pub const INFO: &str = "info";
446
447/// A const byte slice representation of the string `INFO`.
448pub const INFO_BYTES: &[u8] = INFO.as_bytes();
449
450/// The string "debug".
451///
452/// This constant is used to represent a debug message type.
453pub const DEBUG: &str = "debug";
454
455/// A const byte slice representation of the string `DEBUG`.
456pub const DEBUG_BYTES: &[u8] = DEBUG.as_bytes();
457
458/// The string "plain".
459///
460/// This constant is used to represent plain text content.
461pub const PLAIN: &str = "plain";
462
463/// A const byte slice representation of the string `PLAIN`.
464pub const PLAIN_BYTES: &[u8] = PLAIN.as_bytes();
465
466/// The string "binary".
467///
468/// This constant is used to represent binary content.
469pub const BINARY: &str = "binary";
470
471/// A const byte slice representation of the string `BINARY`.
472pub const BINARY_BYTES: &[u8] = BINARY.as_bytes();
473
474/// The string "{".
475///
476/// This constant is used to represent a left bracket.
477pub const LEFT_BRACKET: &str = "{";
478
479/// A const byte slice representation of the string `LEFT_BRACKET`.
480pub const LEFT_BRACKET_BYTES: &[u8] = LEFT_BRACKET.as_bytes();
481
482/// The byte representation of a left bracket character.
483///
484/// This constant provides the byte equivalent of the left bracket character
485/// for use in low-level operations.
486pub const LEFT_BRACKET_U8: u8 = LEFT_BRACKET_BYTES[0];
487
488/// The string "}".
489///
490/// This constant is used to represent a right bracket.
491pub const RIGHT_BRACKET: &str = "}";
492
493/// A const byte slice representation of the string `RIGHT_BRACKET`.
494pub const RIGHT_BRACKET_BYTES: &[u8] = RIGHT_BRACKET.as_bytes();
495
496/// The byte representation of a right bracket character.
497///
498/// This constant provides the byte equivalent of the right bracket character
499/// for use in low-level operations.
500pub const RIGHT_BRACKET_U8: u8 = RIGHT_BRACKET_BYTES[0];
501
502/// The string "(":
503///
504/// This constant is used to represent a left parenthesis.
505pub const LEFT_PAREN: &str = "(";
506
507/// A const byte slice representation of the string `LEFT_PAREN`.
508pub const LEFT_PAREN_BYTES: &[u8] = LEFT_PAREN.as_bytes();
509
510/// The byte representation of a left parenthesis character.
511///
512/// This constant provides the byte equivalent of the left parenthesis character
513/// for use in low-level operations.
514pub const LEFT_PAREN_U8: u8 = LEFT_PAREN_BYTES[0];
515
516/// The string ")".
517///
518/// This constant is used to represent a right parenthesis.
519pub const RIGHT_PAREN: &str = ")";
520
521/// A const byte slice representation of the string `RIGHT_PAREN`.
522pub const RIGHT_PAREN_BYTES: &[u8] = RIGHT_PAREN.as_bytes();
523
524/// The byte representation of a right parenthesis character.
525///
526/// This constant provides the byte equivalent of the right parenthesis character
527/// for use in low-level operations.
528pub const RIGHT_PAREN_U8: u8 = RIGHT_PAREN_BYTES[0];
529
530/// The string "[".
531///
532/// This constant is used to represent a left square bracket.
533pub const LEFT_SQUARE_BRACKET: &str = "[";
534
535/// A const byte slice representation of the string `LEFT_SQUARE_BRACKET`.
536pub const LEFT_SQUARE_BRACKET_BYTES: &[u8] = LEFT_SQUARE_BRACKET.as_bytes();
537
538/// The byte representation of a left square bracket character.
539///
540/// This constant provides the byte equivalent of the left square bracket character
541/// for use in low-level operations.
542pub const LEFT_SQUARE_BRACKET_U8: u8 = LEFT_SQUARE_BRACKET_BYTES[0];
543
544/// The string "]".
545///
546/// This constant is used to represent a right square bracket.
547pub const RIGHT_SQUARE_BRACKET: &str = "]";
548
549/// A const byte slice representation of the string `RIGHT_SQUARE_BRACKET`.
550pub const RIGHT_SQUARE_BRACKET_BYTES: &[u8] = RIGHT_SQUARE_BRACKET.as_bytes();
551
552/// The byte representation of a right square bracket character.
553///
554/// This constant provides the byte equivalent of the right square bracket character
555/// for use in low-level operations.
556pub const RIGHT_SQUARE_BRACKET_U8: u8 = RIGHT_SQUARE_BRACKET_BYTES[0];
557
558/// localhost
559///
560/// This constant is used to represent the localhost address.
561pub const LOCALHOST: &str = "localhost";
562
563/// A const byte slice representation of the string `LOCALHOST`.
564pub const LOCALHOST_BYTES: &[u8] = LOCALHOST.as_bytes();
565
566/// 127.0.0.1
567///
568/// This constant is used to represent the loopback address.
569pub const LOOPBACK: &str = "127.0.0.1";
570
571/// A const byte slice representation of the string `LOOPBACK`.
572pub const LOOPBACK_BYTES: &[u8] = LOOPBACK.as_bytes();