2 releases

0.4.1 Aug 2, 2024
0.4.0 Sep 7, 2023

#325 in Unix APIs

Download history 419/week @ 2024-10-19 372/week @ 2024-10-26 378/week @ 2024-11-02 151/week @ 2024-11-09 142/week @ 2024-11-16 218/week @ 2024-11-23 248/week @ 2024-11-30 336/week @ 2024-12-07 308/week @ 2024-12-14 248/week @ 2024-12-21 260/week @ 2024-12-28 203/week @ 2025-01-04 162/week @ 2025-01-11 170/week @ 2025-01-18 178/week @ 2025-01-25 186/week @ 2025-02-01

722 downloads per month

MIT license

16KB
268 lines

utwt

Crates.io Docs

A Rust crate for parsing utmp files like /var/run/utmp and /var/log/wtmp.

Note: This project has been forked from utmp-rs since September of 2023, but a lot has changed.

Usage

Simplest way is to use parse_from_* functions, which returns a Vec<UtmpEntry> on success:

let entries = utwt::parse_utmp()?;
// or specify a path explicitly
let entries = utwt::parse_from_path("/var/run/utmp")?;
//

If you don't need to collect them all, UtmpParser can be used as an iterator:

use utwt::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.

Dependencies

~0.9–1.5MB
~27K SLoC