#group #native #passwd

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 106/week @ 2024-07-22 127/week @ 2024-07-29 147/week @ 2024-08-05 67/week @ 2024-08-12 76/week @ 2024-08-19 43/week @ 2024-08-26 65/week @ 2024-09-02 74/week @ 2024-09-09 64/week @ 2024-09-16 86/week @ 2024-09-23 23/week @ 2024-09-30 57/week @ 2024-10-07 55/week @ 2024-10-14 54/week @ 2024-10-21 58/week @ 2024-10-28 59/week @ 2024-11-04

227 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

~245KB