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