#passwd #group #native #parser #pw-ent #grp-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 99/week @ 2024-03-31 85/week @ 2024-04-07 88/week @ 2024-04-14 111/week @ 2024-04-21 132/week @ 2024-04-28 106/week @ 2024-05-05 156/week @ 2024-05-12 143/week @ 2024-05-19 113/week @ 2024-05-26 116/week @ 2024-06-02 106/week @ 2024-06-09 102/week @ 2024-06-16 123/week @ 2024-06-23 95/week @ 2024-06-30 108/week @ 2024-07-07 112/week @ 2024-07-14

454 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

~150KB