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