| Crates.io | envcast_derive |
| lib.rs | envcast_derive |
| version | 1.0.0 |
| created_at | 2025-12-28 06:05:30.575508+00 |
| updated_at | 2025-12-28 06:05:30.575508+00 |
| description | Short, clear description of what the project does |
| homepage | https://github.com/neamaddin/envcast |
| repository | https://github.com/neamaddin/envcast |
| max_upload_size | |
| id | 2008287 |
| size | 10,009 |
envcast_derive provides the FromEnv procedural macro for Rust structs.
It generates a get() method that resolves struct fields using the following order:
.env files (default .env, then DOTENV_CONFIG_FILE), lowercase and uppercase keys#[default = "..."] attributeDefault::default()Each field type must implement:
std::str::FromStrDefaultuse envcast::FromEnv;
#[derive(FromEnv)]
pub struct Config {
#[default = 50]
pub int_field: i32,
#[default = 50.0]
pub float_field: f32,
#[default = "Rust"]
pub string_field: String,
#[default = true]
pub bool_field: bool,
}
Then:
let cfg = Config::get();
Config::get() returns a struct with all fields resolved according to the priority rules above.
MIT