#user-group #group #user #passwd

user_lookup

A library to lookup user and groups on Unix/Linux

2 unstable releases

0.3.0 Oct 4, 2023
0.2.0 Oct 4, 2023

#6 in #passwd

Download history 42/week @ 2024-07-20 58/week @ 2024-07-27 4/week @ 2024-08-03 9/week @ 2024-08-10 3/week @ 2024-08-17 17/week @ 2024-08-24 16/week @ 2024-08-31 9/week @ 2024-09-14 30/week @ 2024-09-21 7/week @ 2024-09-28 9/week @ 2024-10-05 4/week @ 2024-10-12

51 downloads per month

MIT/Apache

24KB
392 lines

User Lookup

Crates.io Docs.rs

An easy way to lookup Linux/Unix user and group information from /etc/passwd and /etc/group. It will cache the information for a duration specified by the user.

use user_lookup::async_reader::PasswdReader;
use std::time::Duration;

#[tokio::main]
async fn main() {
   let mut reader = PasswdReader::new(Duration::new(0,0));

   println!("User with uid 1000 is: {}", reader.get_username_by_uid(1000).await.unwrap().unwrap());
}


lib.rs:

user_lookup provides an easy way to lookup Linux/Unix user and group information from /etc/passwd and /etc/group. It will cache the information for a duration specified by the user. If no caching is desired, a Duration of 0.0 can be used.

use user_lookup::async_reader::PasswdReader;
use std::time::Duration;

#[tokio::main]
async fn main() {
   let mut reader = PasswdReader::new(Duration::new(0,0));

   println!("User with uid 1000 is: {}",
   reader.get_username_by_uid(1000).await.unwrap().unwrap());
}

Dependencies

~0–5.5MB
~19K SLoC