Debian Codegraph @

third_party/rust/nix/README.md

raw
1 # Rust bindings to *nix APIs
2
3 [![Cirrus Build Status](https://api.cirrus-ci.com/github/nix-rust/nix.svg)](https://cirrus-ci.com/github/nix-rust/nix)
4 [![crates.io](https://img.shields.io/crates/v/nix.svg)](https://crates.io/crates/nix)
5 [![docs.rs](https://img.shields.io/badge/docs.rs-nix-blue?style=flat-square&logo=docs.rs)](https://docs.rs/nix)
6 ![maintenance-status](https://img.shields.io/badge/maintenance-actively--developed-brightgreen.svg)
7 [![msrv](https://img.shields.io/badge/msrv-1.69-blue?style=flat-square&logo=rust)](https://www.rust-lang.org)
8
9 Nix seeks to provide friendly bindings to various *nix platform APIs (Linux, Darwin,
10 ...). The goal is to not provide a 100% unified interface, but to unify
11 what can be while still providing platform specific APIs.
12
13 For many system APIs, Nix provides a safe alternative to the unsafe APIs
14 exposed by the [libc crate](https://github.com/rust-lang/libc). This is done by
15 wrapping the libc functionality with types/abstractions that enforce legal/safe
16 usage.
17
18
19 As an example of what Nix provides, examine the differences between what is
20 exposed by libc and nix for the
21 [gethostname](https://man7.org/linux/man-pages/man2/gethostname.2.html) system
22 call:
23
24 ```rust,ignore
25 // libc api (unsafe, requires handling return code/errno)
26 pub unsafe extern fn gethostname(name: *mut c_char, len: size_t) -> c_int;
27
28 // nix api (returns a nix::Result<OsString>)
29 pub fn gethostname() -> Result<OsString>;
30 ```
31
32 ## Supported Platforms
33
34 nix target support consists of three tiers. While nix attempts to support all
35 platforms supported by [libc](https://github.com/rust-lang/libc), only some
36 platforms are actively supported due to either technical or manpower
37 limitations. Support for platforms is split into three tiers:
38
39 * Tier 1 - Builds and tests for this target are run in CI. Failures of either
40 block the inclusion of new code.
41 * Tier 2 - Builds for this target are run in CI. Failures during the build
42 blocks the inclusion of new code. Tests may be run, but failures
43 in tests don't block the inclusion of new code.
44 * Tier 3 - Builds for this target are run in CI. Failures during the build
45 *do not* necessarily block the inclusion of new code. That is, at
46 our discretion a Tier 3 target may be dropped at any time, if it
47 would otherwise block development.
48
49 Platforms not listed are supported on a best-effort basis, relying on our users
50 to report any problems.
51
52 The following targets are supported by `nix`:
53
54 <table>
55 <tr>
56 <th>Tier 1</th>
57 <th>Tier 2</th>
58 <th>Tier 3</th>
59 </tr>
60 <tr>
61 <td>
62 <ul>
63 <li>aarch64-apple-darwin</li>
64 <li>aarch64-unknown-linux-gnu</li>
65 <li>arm-unknown-linux-gnueabi</li>
66 <li>armv7-unknown-linux-gnueabihf</li>
67 <li>i686-unknown-freebsd</li>
68 <li>i686-unknown-linux-gnu</li>
69 <li>i686-unknown-linux-musl</li>
70 <li>mips-unknown-linux-gnu</li>
71 <li>mips64-unknown-linux-gnuabi64</li>
72 <li>mips64el-unknown-linux-gnuabi64</li>
73 <li>mipsel-unknown-linux-gnu</li>
74 <li>powerpc64le-unknown-linux-gnu</li>
75 <li>x86_64-unknown-freebsd</li>
76 <li>x86_64-unknown-linux-gnu</li>
77 <li>x86_64-unknown-linux-musl</li>
78 </ul>
79 </td>
80 <td>
81 <ul>
82 <li>aarch64-apple-ios</li>
83 <li>aarch64-linux-android</li>
84 <li>aarch64-unknown-linux-ohos</li>
85 <li>arm-linux-androideabi</li>
86 <li>arm-unknown-linux-musleabi</li>
87 <li>armv7-linux-androideabi</li>
88 <li>armv7-unknown-linux-ohos</li>
89 <li>i686-linux-android</li>
90 <li>loongarch64-unknown-linux-gnu</li>
91 <li>s390x-unknown-linux-gnu</li>
92 <li>x86_64-linux-android</li>
93 <li>x86_64-unknown-illumos</li>
94 <li>x86_64-unknown-linux-ohos</li>
95 <li>x86_64-unknown-netbsd</li>
96 </td>
97 <td>
98 <li>armv7-unknown-linux-uclibceabihf</li>
99 <li>powerpc64-unknown-linux-gnu</li>
100 <li>x86_64-unknown-fuchsia</li>
101 <li>x86_64-unknown-dragonfly</li>
102 <li>x86_64-unknown-haiku</li>
103 <li>x86_64-unknown-linux-gnux32</li>
104 <li>x86_64-unknown-openbsd</li>
105 <li>x86_64-unknown-redox</li>
106 <li>i686-unknown-hurd-gnu</li>
107 </td>
108 </tr>
109 </table>
110
111 ## Minimum Supported Rust Version (MSRV)
112
113 nix is supported on Rust 1.69 and higher. Its MSRV will not be
114 changed in the future without bumping the major or minor version.
115
116 ## Contributing
117
118 Contributions are very welcome. Please See [CONTRIBUTING](CONTRIBUTING.md) for
119 additional details.
120
121 Feel free to join us in [the nix-rust/nix](https://discord.com/invite/rkBeJUsmyd) channel on Discord to
122 discuss `nix` development.
123
124 ## License
125
126 Nix is licensed under the MIT license. See [LICENSE](LICENSE) for more details.