#[derive(Properties)]
{
// Attributes available to this derive:
#[prop]
}
Expand description
Derive macro for automatically implementing properties parsing functionality.
This macro generates implementations for:
from_file: Load properties from a filefrom: Create instance from a type that implements Into<HashMap<String, String>>default: Create instance with default values
ยงExample
use props_util::Properties;
use std::io::Result;
#[derive(Properties, Debug)]
struct Config {
#[prop(key = "server.host", default = "localhost")]
host: String,
#[prop(key = "server.port", default = "8080")]
port: u16,
}
fn main() -> Result<()> {
let config = Config::default()?;
println!("Host: {}", config.host);
println!("Port: {}", config.port);
Ok(())
}