macro_rules! register {
($var:ident) => { ... };
($var:ident | $err:expr ) => { ... };
($($var:ident),* $(,)?) => { ... };
($($var:ident | $err:expr),* $(,)?) => { ... };
($var:ident = $default:expr) => { ... };
($($var:ident = $default:expr),* $(,)?) => { ... };
($var:ident = $default:expr; $priority:ident) => { ... };
($($var:ident = $default:expr),* $(,)?; $priority:ident) => { ... };
}Expand description
Registers one or more environment variables for tracking and validation.
This macro simplifies the process of registering environment variables that
your application depends on. Once registered, you can utilize
env-inventory’s utilities to load, validate, and manage these environment
variables.
§Examples
register!("DATABASE_URL", "REDIS_URL", "API_KEY");
register!("LOG_LEVEL" => "debug", "CACHE_SIZE" => 1024);The first call registers three environment variables: DATABASE_URL,
REDIS_URL, and API_KEY. The second call registers two environment variables
with default values: LOG_LEVEL with a default of "debug", and CACHE_SIZE
with a default of 1024.
§Parameters
$($var:expr),*: A comma-separated list of string literals, each representing an environment variable to register.$($var:expr => $default:expr),*: A comma-separated list of pairs, where each pair consists of a string literal representing an environment variable and its default value.
§Panics
This macro will panic at compile-time if any of the provided arguments are not string literals or if the pairs don’t have the appropriate structure.