#user-group #user #group #passwd

async_user_lookup

A library to lookup user and groups on Unix/Linux. NOTE: This has been renamed to user_lookup to allow for both sync and async versions

4 releases

0.1.3 Oct 4, 2023
0.1.2 Oct 4, 2023
0.1.1 Jun 17, 2022
0.1.0 Jun 17, 2022

#95 in Caching

MIT/Apache

15KB
234 lines

Async User Lookup

Crates.io Docs.rs

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

use async_user_lookup::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:

async_user_lookup provides an easy way to lookup Linux/Unix user and group information from /etc/passwd and /etc/group. It uses tokio async and 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 async_user_lookup::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

~2–3MB
~46K SLoC