7 unstable releases

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

#212 in Unix APIs

Download history 102/week @ 2024-07-31 75/week @ 2024-08-07 91/week @ 2024-08-14 64/week @ 2024-08-21 65/week @ 2024-08-28 54/week @ 2024-09-04 138/week @ 2024-09-11 96/week @ 2024-09-18 339/week @ 2024-09-25 162/week @ 2024-10-02 124/week @ 2024-10-09 55/week @ 2024-10-16 40/week @ 2024-10-23 64/week @ 2024-10-30 130/week @ 2024-11-06 123/week @ 2024-11-13

377 downloads per month
Used in 2 crates

MIT license

25KB
447 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.6–2.3MB
~41K SLoC