Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kstep/parsswd
A native Rust passwd and group files parser
https://github.com/kstep/parsswd
Last synced: about 2 months ago
JSON representation
A native Rust passwd and group files parser
- Host: GitHub
- URL: https://github.com/kstep/parsswd
- Owner: kstep
- License: apache-2.0
- Created: 2016-04-19T08:23:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-01-30T15:54:36.000Z (11 months ago)
- Last Synced: 2024-10-11T23:47:05.003Z (2 months ago)
- Language: Rust
- Size: 12.7 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# parsswd
A native Rust passwd and group files parser.
Cargo.toml:
```toml
[dependencies]
parsswd = "0.1.0"
```Usage:
```rust
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
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)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.