Giter VIP home page Giter VIP logo

uapi's Introduction

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.

uapi's People

Contributors

mahkoh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.