Crates.io | parsswd |
lib.rs | parsswd |
version | 0.1.0 |
source | src |
created_at | 2016-04-19 08:29:33.113733 |
updated_at | 2016-04-19 08:29:33.113733 |
description | Native Rust passwd and group files parser |
homepage | |
repository | https://github.com/kstep/parsswd |
max_upload_size | |
id | 4789 |
size | 16,207 |
A native Rust passwd and group files parser.
Cargo.toml:
[dependencies]
parsswd = "0.1.0"
Usage:
extern crate parsswd;
use parsswd::{PwEnt, GrpEnt};
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
fn main() {
let passwd = BufReader::new(File::open("/etc/passwd").unwrap());
for line in passwd.lines() {
let line = line.unwrap();
let entry = PwEnt::from_str(&*line).unwrap();
println!("User #{}: {} ", entry.uid, entry.name);
}
let group = BufReader::new(File::open("/etc/group").unwrap());
for line in group.lines() {
let line = line.unwrap();
let entry = GrpEnt::from_str(&*line).unwrap();
println!("Group #{}: {} ", entry.gid, entry.name);
}
}
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.