Expand description
The macros
module contains functions for generating macros.
Macros for the hsh
crate.
This module contains macros that simplify working with Hash structs.
These macros can greatly simplify code that uses the Hash struct, making it easier to read and maintain.
Generic macros for the hsh crate.
This crate provides the following macros:
Macro | Description |
---|---|
hsh | Calls the parse method on the Hash struct from the hsh crate. |
hsh_assert | Asserts that a given condition is true. If the condition is false, the macro will cause the program to panic with the message “Assertion failed!”. |
hsh_contains | Checks if a given string contains a specified substring. |
hsh_in_range | Checks if a given value is within a specified range (inclusive). |
hsh_join | Joins multiple strings together using a specified separator. |
hsh_max | Returns the maximum value from a set of given values. |
hsh_min | Returns the minimum value from a set of given values. |
hsh_print | Prints the given arguments to the console, similar to the println! macro. |
hsh_print_vec | Prints the elements of a given vector to the console, each on a new line. |
hsh_split | Splits a given string into a vector of words, dividing at each occurrence of whitespace. |
hsh_vec | Creates a new vector containing the given elements. |
hsh_parse | Attempts to parse a given input into a u64 value, returning a Result. |
HSH Macros
The library also provides several macros for common operations on the Hash
struct:
to_str_error
: Abstracts away the error handling for theto_string
method.random_string
: Generates a random string of a specified length, consisting of alphanumeric characters.match_algo
: Matches given hash algorithm strings to their corresponding enum variants.generate_hash
: Generates a new hash for a given password, salt, and algorithm.new_hash
: Creates a new instance of theHash
struct with a given password, salt, and algorithm.hash_length
: Returns the length of the hash for a givenHash
struct instance.