#uapi #freebsd #linux #proc #unix #openbsd #macros #macos #ci

macro uapi-proc

Internal macros for the uapi crate. DO NOT USE!

5 releases

0.0.5 Feb 15, 2022
0.0.4 Feb 15, 2022
0.0.3 Dec 29, 2021
0.0.2 Jan 6, 2021
0.0.1 May 29, 2020

#11 in #openbsd

Download history 10/week @ 2022-04-21 66/week @ 2022-04-28 90/week @ 2022-05-05 106/week @ 2022-05-12 61/week @ 2022-05-19 70/week @ 2022-05-26 92/week @ 2022-06-02 7/week @ 2022-06-09 18/week @ 2022-06-16 20/week @ 2022-06-23 20/week @ 2022-06-30 27/week @ 2022-07-07 23/week @ 2022-07-14 45/week @ 2022-07-21 37/week @ 2022-07-28 30/week @ 2022-08-04

142 downloads per month
Used in 2 crates (via uapi)

MIT/Apache

11KB
288 lines

Unix API

crates.io docs.rs

This crate contains safe wrappers around Unix APIs.

Supported Targets

A target is supported if and only if the crate is tested against it via CI.

The following targets are supported:

  • x86_64-unknown-linux-gnu (glibc >= 2.23)
  • x86_64-unknown-linux-musl (musl >= 1.1.19)
  • x86_64-unknown-freebsd (12)
  • x86_64-unknown-openbsd (6.7)
  • x86_64-apple-darwin (10.15)

This crate contains little architecture-specific code. Therefore, other architectures (arm, aarch64, etc.) will probably also work.

Future changes

This crate fully supports reading into uninitialized buffers but the API will most likely change when the same functionality becomes stable in libstd.

Comparison with other crates

libc

This crate builds on the libc crate and uses its declarations of the raw OS APIs if possible. This crate considers itself to be the next step up from libc: It safely wraps the raw OS functions but does little beyond that. Integer parameters are still integer parameters, functions operating on sockets accept the socket file descriptor as a raw integer, there is no socket wrapper type, etc.

At the same time, this crate provides the necessary tools to make it as easy to use from Rust as the raw APIs are to use from C. For example, all of the following just work:

open("./file", c::O_RDWR, 0);
open(b"./file", c::O_RDWR, 0);
open(CStr::from_ptr(p), c::O_RDWR, 0);
open(Path::new("./file"), c::O_RDWR, 0);

See the crate documentation for more details.

nix

  • nix uses a nested module structure. uapi exports all APIs in the crate root.
  • nix I/O works on [u8]. uapi I/O works on [MaybeUninit<u8>].
  • nix uses enums and bitflags for integer/flag parameters. uapi uses plain integers.
  • nix uses methods declared on wrapper types to expose APIs. uapi uses free functions unless doing so would be unsafe.
  • nix uses enums for the values produced and consumed by certain generic OS APIs (e.g. control messages.) uapi uses generic functions that do not restrict the types that can be used.

License

This project is licensed under either of

  • Apache License, Version 2.0
  • MIT License

at your option.

Dependencies

~1.1–2MB
~53K SLoC