Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/upsuper/utmp-rs
Rust crate to parse utmp file
https://github.com/upsuper/utmp-rs
rust-crate utmp
Last synced: 8 days ago
JSON representation
Rust crate to parse utmp file
- Host: GitHub
- URL: https://github.com/upsuper/utmp-rs
- Owner: upsuper
- License: mit
- Created: 2020-02-09T03:11:44.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-27T13:07:26.000Z (4 months ago)
- Last Synced: 2025-01-03T00:11:25.916Z (18 days ago)
- Topics: rust-crate, utmp
- Language: Rust
- Size: 25.4 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# utmp-rs
[![Crates.io](https://img.shields.io/crates/v/utmp-rs.svg)](https://crates.io/crates/utmp-rs)
[![Docs](https://docs.rs/utmp-rs/badge.svg)](https://docs.rs/utmp-rs)A Rust crate for parsing `utmp` files like `/var/run/utmp` and `/var/log/wtmp`.
## Usage
Simplest way is to use `parse_from_*` functions,
which returns a `Vec` on success:
```rust
let entries = utmp_rs::parse_from_path("/var/run/utmp")?;
// ...
```If you don't need to collect them all,
`UtmpParser` can be used as an iterator:
```rust
use utmp_rs::UtmpParser;
for entry in UtmpParser::from_path("/var/run/utmp")? {
let entry = entry?;
// ...
}
```All the `parse_from_*` functions as well as `UtmpParser` parse `utmp` file
based on the native format for the target platform.
If cross-platform parsing is needed,
`Utmp32Parser` or `Utmp64Parser` can be used instead of `UtmpParser`.