Expand description
hyperlane-utils
A library providing utils for hyperlane.
Re-exports§
pub use ahash;
pub use futures;
pub use log;
pub use num_cpus;
pub use once_cell;
pub use serde;
pub use serde_json;
pub use serde_urlencoded;
pub use serde_xml_rs;
pub use simd_json;
pub use twox_hash;
pub use urlencoding;
pub use utoipa;
pub use utoipa_rapidoc;
pub use utoipa_swagger_ui;
Modules§
Macros§
- __
print_ message_ common - Internal macro for handling common message printing logic.
- arc
- Creates a new atomic reference counted pointer.
- b_
tree_ map - Creates a new BTreeMap instance.
- b_
tree_ set - Creates a new BTreeSet instance.
- binary_
heap - Creates a new
BinaryHeap<T>
. - boxed
- Creates a new
Box
instance. - cell
- Creates a new
Cell
instance. - cin
- Read a line from standard input as a
String
. - cin_
parse - Parse input string into a value or a vector of values of a specified type.
- clone
- A helper macro to clone variables into closures or async blocks easily.
- cout
- Print formatted output to standard output using
print!
. - cout_
endl - Print formatted output with a newline and flush the standard output buffer.
- endl
- Print a newline character and flush the standard output buffer.
- execute
- Execute a synchronous function with given arguments.
- execute_
async - Execute an asynchronous function and return a future.
- future_
fn - Generates an asynchronous closure that clones specified external variables and executes the given closure body asynchronously.
- hash_
map - Creates a new hash map instance.
- hash_
set - Creates a new
HashSet
instance. - join_
paths - Combines multiple paths into a single valid path, handling overlapping slashes.
- linked_
list - Creates a new
LinkedList
instance. - mutex
- Creates a new
Mutex
instance. - output_
macro - Macro for outputting colored text to the terminal.
- println_
error - Prints an error message with red background and white text.
- println_
success - Prints a success message with green background and white text.
- println_
warning - Prints a warning message with yellow background and white text.
- rc
- Creates a new
Rc
(Reference Counted) instance. - refcell
- Creates a new
RefCell
instance. - rw_lock
- Creates a new
RwLock
instance. - string
- Creates a new string instance.
- vector
- Creates a new vector instance.
- vector_
deque - Creates a new
VecDeque
instance.
Structs§
- Broadcast
- Represents a broadcast mechanism for sending messages to multiple receivers.
- Broadcast
Map - Represents a concurrent, thread-safe map of broadcast channels, keyed by string.
- Charset
- Handles string encoding and decoding operations.
- Chunk
Strategy - Configuration for chunking operations.
- Compare
Version - Utility for comparing version strings.
- Decode
- Handles the decoding operations for the application.
- Encode
- Handles the encoding operations for the application.
- File
Data String - A wrapper struct for file data in string format.
- Log
- Main configuration structure for log file output.
- Output
- Represents a colored text output with formatting options.
- Output
Builder - Builder pattern for constructing Output configurations.
- Output
List - Represents a list of Output configurations for sequential execution.
- Output
List Builder - Builder pattern for constructing OutputList configurations.
- Server
Manager - Main structure for managing server processes.
- Thread
Pool - A thread pool that can execute tasks concurrently.
- WebSocket
- Represents a WebSocket instance.
- WebSocket
Config - Configuration for a WebSocket connection.
- Worker
- A worker thread in the thread pool.
Enums§
- Broadcast
Type - Represents the type of broadcast for WebSocket messages.
- Chunk
Strategy Error - Errors that can occur during chunking operations.
- Color
- Predefined color constants for easy text formatting.
- Color
Type - Represents different types of colors that can be used for text formatting.
- Decode
Error - Represents errors that can occur during decoding.
- Encode
Error - Represents errors that can occur during encoding.
- HotRestart
Error - Errors that can occur during hot restart process.
- Version
Comparison - Result of comparing two versions.
- Version
Error - Errors that can occur during version parsing and comparison.
Constants§
- CHUNKIFY_
CHUNK_ INDEX_ HEADER - HTTP header name for chunk index in chunking operations.
- CHUNKIFY_
FILE_ ID_ HEADER - HTTP header name for file ID in chunking operations.
- CHUNKIFY_
FILE_ NAME_ HEADER - HTTP header name for original file name in chunking operations.
- CHUNKIFY_
TOTAL_ CHUNKS_ HEADER - HTTP header name for total chunks count in chunking operations.
- COMMON_
YEAR - Common Year
- DAYS
- Days
- DEBUG_
DIR - Subdirectory name for debug logs.
- DEFAULT_
BROADCAST_ SENDER_ CAPACITY - Defines the default capacity for a broadcast sender.
- DEFAULT_
LOG_ DIR - Default directory path for storing log files.
- DEFAULT_
LOG_ FILE_ SIZE - Default maximum size limit for log files in bytes.
- DEFAULT_
LOG_ FILE_ START_ IDX - Default starting index number for log files.
- DISABLE_
LOG_ FILE_ SIZE - Special value indicating no size limit for log files.
- ERROR_
DIR - Subdirectory name for error logs.
- INFO_
DIR - Subdirectory name for info logs.
- LEAP_
YEAR - Leap Year
- LOG_
EXTENSION - File extension for log files.
- MONTHS
- Months
Traits§
- Async
Error Handler Function - Trait alias for asynchronous error-handling functions used in a recoverable context.
- Async
Recoverable Function - Trait alias for asynchronous functions that can be executed in a recoverable context.
- Broadcast
MapTrait - Defines the essential traits required for types that can be used as values in a
BroadcastMap
. - Broadcast
Trait - Defines the essential traits required for types that can be broadcast.
- Chunk
Naming - Trait for generating chunk file names.
- Error
Handler Function - Trait alias for error-handling functions used in a recoverable context.
- Function
MutTrait - Trait alias for functions that can be executed in a recoverable context.
- Function
Once Trait - Trait alias for functions that can be executed in a recoverable context.
- Function
Trait - Trait alias for functions that can be executed in a recoverable context.
- Handle
Strategy - Trait for handling chunk operations.
- LogFunc
Trait - Trait for log formatting functions.
- Recoverable
Function - Trait alias for functions that can be executed in a recoverable context.
Functions§
- append_
to_ file - Appends content to a file.
- async_
append_ to_ file - Appends content to a file asynchronously.
- async_
copy_ dir_ files - Asynchronously copies all files from the source directory to the destination directory.
- async_
copy_ file - Asynchronously copies a file from the source path to the destination path.
- async_
delete_ dir - Asynchronously deletes a directory and all its contents.
- async_
delete_ file - Asynchronously deletes a file at the given path.
- async_
get_ file_ size - Gets the size of a file in bytes.
- async_
move_ dir - Moves a directory and all its contents to another location asynchronously.
- async_
move_ file - Moves a file from the source path to the destination path asynchronously.
- async_
read_ from_ file - Reads the content of a file and converts it to the specified type.
- async_
write_ to_ file - Writes content to a file asynchronously.
- calculate_
time - Calculates the current year, month, day, hour, minute, second, millisecond and microsecond.
- common_
log - Formats log data with timestamp for each line.
- compute_
date - Computes the year, month, and day from days since Unix epoch (1970-01-01).
- copy_
dir_ files - Copies all files from the source directory to the destination directory.
- copy_
file - Copies a file from the source path to the destination path.
- date
- Gets the current day, without the time.
- day
- Gets the current day.
- delete_
dir - Deletes a directory and all its contents.
- delete_
file - Deletes a file at the given path.
- get_
file_ size - Gets the size of a file in bytes.
- gmt
- Gets the current date and time in GMT format.
- hot_
restart - Starts hot restart process without waiting for completion.
- hot_
restart_ wait - Starts hot restart process and waits for completion.
- hour
- Gets the current hour.
- is_
leap_ year - Determines if a year is a leap year.
- log_
handler - Handles log data formatting by delegating to common_log.
- micros
- Gets the current timestamp in microseconds.
- millis
- Gets the current timestamp in milliseconds.
- minute
- Gets the current minute.
- month
- Gets the current month.
- move_
dir - Moves a directory and all its contents to another location.
- move_
file - Moves a file from the source path to the destination path.
- output
- Executes the output operation with the given formatting.
- read_
from_ file - Reads the content of a file and converts it to the specified type.
- second
- Gets the current second.
- time
- Gets the current time, including the date and time.
- time_
micros - Gets the current time with microseconds, including the date and time.
- time_
millis - Gets the current time with milliseconds, including the date and time.
- timestamp
- Gets the current timestamp in seconds since Unix epoch.
- timestamp_
micros - Gets the current timestamp in microseconds since Unix epoch.
- timestamp_
millis - Gets the current timestamp in milliseconds since Unix epoch.
- write_
to_ file - Writes content to a file.
- year
- Gets the current year.
Type Aliases§
- ArcAsync
Error Handler Function - Arc-wrapped asynchronous error handler function.
- ArcAsync
Recoverable Function - Arc-wrapped asynchronous recoverable function.
- ArcLog
- Thread-safe shared reference to a Log configuration.
- ArcLog
Func - Thread-safe shared reference to a log formatting function.
- Async
Spawn Result - Result type for asynchronous spawn operations.
- Broadcast
MapReceiver - Represents a receiver endpoint for a broadcast channel within a map, allowing consumption of broadcasted messages.
- Broadcast
MapSend Error - Represents an error that occurs when attempting to send a message via a broadcast channel within a map.
- Broadcast
MapSend Result - Represents the result of a broadcast map send operation, indicating either success with an optional receiver count or an error.
- Broadcast
MapSender - Represents a sender endpoint for a broadcast channel within a map, used to dispatch messages.
- Broadcast
Receiver - Represents a receiver endpoint for a broadcast channel, allowing consumption of broadcasted messages.
- Broadcast
Send Error - Represents an error that occurs when attempting to send a message via broadcast.
- Broadcast
Send Result - Represents the result of a broadcast send operation, indicating either success with the number of receivers or an error.
- Broadcast
Sender - Represents a sender endpoint for a broadcast channel, used to dispatch messages to all subscribed receivers.
- Capacity
- Represents the maximum capacity or buffer size of a broadcast channel.
- Chunk
Strategy Result - Result type for chunk strategy operations.
- Dash
MapString Broadcast - A concurrent, thread-safe map where keys are strings and values are broadcast channels.
- ListLog
- A collection of named log formatting functions.
- LogArc
Lock - Thread-safe shared reference to a Log configuration instance.
- LogFunc
- Trait object representing a log formatting function.
- LogList
ArcLock - Thread-safe shared reference to a collection of log functions.
- NewChunk
Strategy Result - Result type for creating new chunk strategies.
- Option
Broadcast - Represents an optional broadcast channel.
- Option
Broadcast MapReceiver - Represents an optional receiver endpoint for a broadcast channel within a map.
- Option
Broadcast MapSender - Represents an optional sender endpoint for a broadcast channel within a map.
- Option
Receiver Count - Represents an optional count of active receivers.
- Receiver
Count - Represents the number of active receivers subscribed to a broadcast channel.
- Result
HotRestart Error - Result type alias for hot restart operations.
- Send
Error Box - Error type for failed job submissions.
- Send
Result - Result type for job submission operations.
- Server
Manager Error - Error type for server management operations.
- Server
Manager Hook - Type alias for the hook functions.
- Server
Manager Result - Result type for server management operations.
- Spawn
Error - Error type for spawn operations.
- Sync
Spawn Result - Result type for synchronous spawn operations.
- Thread
Pool Job - A job that can be executed by the thread pool.
Attribute Macros§
- aborted
- Handles aborted request scenarios.
- attribute
- Extracts a specific attribute value into a variable.
- attributes
- Extracts all attributes into a HashMap variable.
- closed
- Handles closed connection scenarios.
- connect
- Restricts function execution to HTTP CONNECT requests only.
- delete
- Restricts function execution to HTTP DELETE requests only.
- filter_
unknown - Handles requests with any unknown characteristics.
- filter_
unknown_ method - Handles requests with unknown or non-standard HTTP methods.
- filter_
unknown_ upgrade - Handles requests with unknown or non-standard upgrade protocols.
- filter_
unknown_ version - Handles requests with unknown or non-standard HTTP versions.
- flush
- Flushes the response stream after function execution.
- get
- Restricts function execution to HTTP GET requests only.
- h2c
- Restricts function execution to HTTP/2 Cleartext (h2c) requests only.
- head
- Restricts function execution to HTTP HEAD requests only.
- host
- Restricts function execution to requests with a specific host.
- host_
filter - Filters requests that have no host header.
- http
- Restricts function execution to standard HTTP requests only.
- http0_9
- Restricts function execution to HTTP/0.9 requests only.
- http2
- Restricts function execution to HTTP/2 requests only.
- http3
- Restricts function execution to HTTP/3 requests only.
- http1_0
- Restricts function execution to HTTP/1.0 requests only.
- http1_1
- Restricts function execution to HTTP/1.1 requests only.
- http1_
1_ or_ higher - Restricts function execution to HTTP/1.1 or higher protocol versions.
- hyperlane
- Creates a new instance of a specified type with a given variable name.
- methods
- Allows function to handle multiple HTTP methods.
- options
- Restricts function execution to HTTP OPTIONS requests only.
- patch
- Restricts function execution to HTTP PATCH requests only.
- post
- Restricts function execution to HTTP POST requests only.
- post_
hook - Executes a specified function after the main handler function.
- pre_
hook - Executes a specified function before the main handler function.
- put
- Restricts function execution to HTTP PUT requests only.
- referer
- Restricts function execution to requests with a specific referer.
- referer_
filter - Filters requests that have a specific referer header.
- request_
body - Extracts the raw request body into a specified variable.
- request_
body_ json - Parses the request body as JSON into a specified variable and type.
- request_
cookie - Extracts a specific cookie value or all cookies into a variable.
- request_
cookies - Extracts all cookies as a raw string into a variable.
- request_
header - Extracts a specific HTTP request header into a variable.
- request_
headers - Extracts all HTTP request headers into a collection variable.
- request_
path - Extracts the HTTP request path into a variable.
- request_
query - Extracts a specific request query parameter into a variable.
- request_
querys - Extracts all request query parameters into a collection variable.
- request_
version - Extracts the HTTP request version into a variable.
- response_
body - Sets the HTTP response body.
- response_
header - Sets or replaces a specific HTTP response header.
- response_
reason_ phrase - Sets the HTTP reason phrase for the response.
- response_
status_ code - Sets the HTTP status code for the response.
- response_
version - Sets the HTTP response version.
- route_
param - Extracts a specific route parameter into a variable.
- route_
params - Extracts all route parameters into a collection variable.
- send
- Automatically sends the complete response after function execution.
- send_
body - Automatically sends only the response body after function execution.
- send_
once - Sends the complete response exactly once after function execution.
- send_
once_ body - Sends only the response body exactly once after function execution.
- tls
- Restricts function execution to TLS-encrypted requests only.
- trace
- Restricts function execution to HTTP TRACE requests only.
- ws
- Restricts function execution to WebSocket upgrade requests only.
Derive Macros§
- Custom
Debug - A procedural macro that implements the
std::fmt::Debug
trait for a type, with support for the#[debug(skip)]
attribute to skip specific fields. - Data
- This is an example of how to use the
Lombok
procedural macro withget
,get_mut
, andset
attributes. - Display
Debug - A procedural macro that implements the
std::fmt::Display
trait for a type, using the standard debug format ({:?}
) for formatting. - Display
Debug Format - A procedural macro that implements the
std::fmt::Display
trait for a type, using the detailed debug format ({:#?}
) for formatting. - Getter
- This is an example of how to use the
Lombok
procedural macro withget
attributes. - Getter
Mut - This is an example of how to use the
Lombok
procedural macro withget_mut
attributes. - Setter
- This is an example of how to use the
Lombok
procedural macro withset
attributes.