Skip to content

Derive macro to read from a directory into a Rust struct

License

Notifications You must be signed in to change notification settings

abint7/structfromdir

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

structfromdir

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.

Usage

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 })

About

Derive macro to read from a directory into a Rust struct

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%