#passwd #native #group #parser #grp-ent #pw-ent

parsswd

Native Rust passwd and group files parser

1 unstable release

Uses old Rust 2015

0.1.0 Apr 19, 2016

#10 in #passwd

Download history 38/week @ 2024-01-02 38/week @ 2024-01-09 28/week @ 2024-01-16 26/week @ 2024-01-23 57/week @ 2024-01-30 28/week @ 2024-02-06 56/week @ 2024-02-13 60/week @ 2024-02-20 86/week @ 2024-02-27 70/week @ 2024-03-05 101/week @ 2024-03-12 91/week @ 2024-03-19 89/week @ 2024-03-26 95/week @ 2024-04-02 85/week @ 2024-04-09 76/week @ 2024-04-16

360 downloads per month
Used in appc

MIT/Apache

7KB
75 lines

parsswd

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

License

Licensed under either of

at your option.

Contribution

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.

No runtime deps

~115KB