7 releases (stable)

1.4.0 Jul 25, 2022
1.3.1 Mar 25, 2021
1.3.0 Mar 23, 2018
1.2.0 Sep 26, 2017
0.1.0 Sep 25, 2017

#109 in Filesystem

Download history 2704/week @ 2022-11-27 2149/week @ 2022-12-04 2188/week @ 2022-12-11 2360/week @ 2022-12-18 1595/week @ 2022-12-25 1816/week @ 2023-01-01 2493/week @ 2023-01-08 1852/week @ 2023-01-15 2243/week @ 2023-01-22 2811/week @ 2023-01-29 2856/week @ 2023-02-05 2976/week @ 2023-02-12 3917/week @ 2023-02-19 3532/week @ 2023-02-26 2772/week @ 2023-03-05 2615/week @ 2023-03-12

13,138 downloads per month
Used in 52 crates (5 directly)

CC-PDDC license

9KB
130 lines

pwd module for unix-y systems

image::https://img.shields.io/crates/v/pwd.svg?style=flat-square[link="https://crates.io/crates/pwd",alt="crates.io"] image::https://deps.rs/repo/gitlab/pwoolcoc/pwd/status.svg[link="https://deps.rs/repo/gitlab/pwoolcoc/pwd",alt="dependency status"]

This is a small veneer over pwd.h, mostly just hides away the unsafe parts.

Installation

In the [dependencies] section of your Cargo.toml, add the following line:

[source="rust"]

[dependencies]
pwd = "1"

Usage

[source="rust"]

use pwd::Passwd;

fn main() {
    let me = Passwd::current_user();
    println!("my username is {}, home directory is {}, and my shell is {}. My uid/gid are {}/{}",
             me.name, me.dir, me.shell, me.uid, me.gid);
}

lib.rs:

Safe interface to <pwd.h>

This module, named after the python module with the same function, is a safe interafce to pwd.h on unix-y systems. Currently nothing from this module compiles on Windows, or attempts to make any kind of similar interface for Windows.

Dependencies

~0.7–1.1MB
~28K SLoC