23 releases (6 breaking)

0.6.9 May 23, 2021
0.6.5 Apr 30, 2021
0.6.2 Mar 2, 2021

#26 in Operating systems

Download history 2213/week @ 2021-02-23 2900/week @ 2021-03-02 2129/week @ 2021-03-09 2635/week @ 2021-03-16 2573/week @ 2021-03-23 1572/week @ 2021-03-30 1495/week @ 2021-04-06 2356/week @ 2021-04-13 1097/week @ 2021-04-20 1360/week @ 2021-04-27 1998/week @ 2021-05-04 2208/week @ 2021-05-11 3233/week @ 2021-05-18 1663/week @ 2021-05-25 2403/week @ 2021-06-01 2366/week @ 2021-06-08

9,044 downloads per month
Used in 34 crates (19 directly)

Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT

2.5K SLoC


Non-owning unsafe I/O

Github Actions CI Status crates.io page docs.rs docs

Have you ever found yourself writing essentially the same code twice, once for RawFd for Posix-ish platforms and once for RawHandle or RawSocket for Windows platforms? This crate abstracts over those platform differences.

Being non-owning, these handles operate much like raw pointers in Rust. They are considered safe to construct, but unsafe to use in any way that depends on the resource they point to.

This library is meant to be a building block for higher-level libraries, such as the io-streams crate.

Brief Overview

The central type of this library is UnsafeHandle. On Posix-ish platforms it just contains a RawFd. On Windows, it contains an enum of either a RawHandle (for files and pipes), a RawSocket (for sockets), or a stdio handle (for stdin, stdout, stderr), allowing it to abstract over different types of I/O in a similar manner.

UnsafeFile and UnsafeSocket are similar non-owning types, but which only contain one type, instead of an enum, which allow them to be used in contexts that only support one type.

The crate documentation has a complete overview and examples.


~45K SLoC