EnvMode
EnvMode is a simple Rust crate designed to help manage environment modes (development, production, staging) in your Rust applications. It provides utilities to check and validate the environment mode, making it easy to perform various actions based on the current environment mode.
Features
-
Supports 3 environment modes,
- Development (
dev) - Production (
prd) - Staging (
stg)
- Development (
-
Provides helper methods to check and validate environment modes.
Installation
To use the EnvMode crate in your Rust application, add the following dependency to your Cargo.toml file:
[]
= "0.1.0"
Usage
Given below is an example of how to use the EnvMode crate in your application:
use Deserialize;
use Arc;
use EnvMode;
Methods
EnvMode::is_dev(mode: &str) -> bool
Checks if the provided mode is the development mode.
assert_eq!;
EnvMode::is_prd(mode: &str) -> bool
Checks if the provided mode is the production mode.
assert_eq!;
EnvMode::is_stg(mode: &str) -> bool
Cheks if the provided mode is the staging mode.
assert_eq!;
EnvMode::is_valid(mode: &str) -> bool
Checks if the mode is one of the valid environment modes (dev, prd, stg).
assert_eq!;
assert_eq!; // Invalid mode
Enum variants
EnvMode::Dev- Development modeEnvMode::Prd- Production modeEnvMode::Stg- Staging mode