| Crates.io | structfromdir |
| lib.rs | structfromdir |
| version | 0.1.0 |
| created_at | 2023-04-22 02:36:15.402481+00 |
| updated_at | 2023-04-22 02:36:15.402481+00 |
| description | Derive macro to read from a directory into a Rust struct |
| homepage | |
| repository | https://github.com/cdown/structfromdir |
| max_upload_size | |
| id | 845784 |
| size | 5,076 |
A Rust derive macro which permits reading struct values from a directory.
Not ready for production use, still in heavy development and many things are not yet implemented or will unexpectedly blow up.
use structfromdir::FromDir;
#[derive(FromDir, Debug)]
struct Files {
capacity: u8,
energy_now: u64,
}
fn main() {
let files = Files::from_dir("/sys/class/power_supply/BAT0");
println!("{:?}", files);
}
Results in:
Ok(Files { capacity: 68, energy_now: 38780000 })