6 releases

0.3.0 Jul 24, 2022
0.2.1 Nov 27, 2021
0.1.2 Nov 21, 2021
0.1.1 Feb 9, 2020

#448 in Unix APIs

Download history 119/week @ 2023-12-18 36/week @ 2023-12-25 94/week @ 2024-01-01 136/week @ 2024-01-08 234/week @ 2024-01-15 141/week @ 2024-01-22 308/week @ 2024-01-29 344/week @ 2024-02-05 194/week @ 2024-02-12 349/week @ 2024-02-19 232/week @ 2024-02-26 88/week @ 2024-03-04 92/week @ 2024-03-11 154/week @ 2024-03-18 108/week @ 2024-03-25 220/week @ 2024-04-01

581 downloads per month
Used in 2 crates

MIT license

24KB
442 lines

utmp-rs

Crates.io Docs

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<UtmpEntry> on success:

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:

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.


lib.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<UtmpEntry> on success:

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:

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.

Dependencies

~1.7–2.3MB
~42K SLoC