[−][src]Crate unsafe_io
Non-owning unsafe I/O
A brief explanation of the naming convention:
Raw is for platform-specific types and traits, such as std's RawFd,
AsRawFd, RawHandle, AsRawHandle, and similar, as well as
unsafe-io's RawHandleOrSocket, AsRawHandleOrSocket, and similar.
"Handle" in this context means a Windows HANDLE.
Unsafe is for minimal platform-independent abstractions on top of the
platform-specific types, such as UnsafeHandle (abstracts over RawFd
and RawHandleOrSocket), UnsafeFile (abstracts over RawFd and
RawHandle), and UnsafeSocket (abstracts over RawFd and RawSocket).
"Handle" in this context means any kind of I/O handle.
In table form, the main types are:
| Resource | Posix-ish type | Windows type | Platform-independent types | |
|---|---|---|---|---|
| File | RawFd | RawHandle | UnsafeHandle or UnsafeFile | |
| Pipe | RawFd | RawHandle | UnsafeHandle or UnsafeFile | |
| Socket | RawFd | RawSocket | UnsafeHandle or UnsafeSocket | |
| Any | RawFd | RawHandleOrSocket | UnsafeHandle |
and the main traits are:
* These types do not have From traits.
This crates also defines several additional utilities:
UnsafeHandle has methods as_readable and as_writeable which
return similar non-owning types UnsafeReadable and UnsafeWriteable,
respectively, which implement Read and Write.
AsUnsafeReadWriteHandle, AsRawReadWriteFd, and
AsRawReadWriteHandleOrSocket, are traits for working with types that
implement both Read and Write and may contain either one handle
(such as a socket) or two (such as stdin and stdout, or a pair of pipes).
Structs
| UnsafeFile | A non-owning unsafe I/O handle which on Windows is limited to handling what
Windows considers to be |
| UnsafeHandle | A non-owning unsafe I/O handle. |
| UnsafeReadable | A non-owning unsafe I/O handle that implements |
| UnsafeSocket | A non-owning unsafe I/O handle which on Windows is limited to handling what
Windows considers to be |
| UnsafeWriteable | A non-owning unsafe I/O handle that implements |
| View | A view of a resource which dereferences to a |
Traits
| AsRawReadWriteFd | Like |
| AsUnsafeFile | A trait for types which contain an unsafe file and can expose it. |
| AsUnsafeHandle | A trait for types which contain an unsafe handle and can expose it. |
| AsUnsafeReadWriteHandle | An analog of |
| AsUnsafeSocket | A trait for types which contain an unsafe socket and can expose it. |
| FromUnsafeFile | A trait for types which can be constructed from unsafe files. |
| FromUnsafeSocket | A trait for types which can be constructed from unsafe sockets. |
| IntoUnsafeFile | A trait for types which can be converted into unsafe files. |
| IntoUnsafeHandle | A trait for types which can be converted into an unsafe handle. |
| IntoUnsafeSocket | A trait for types which can be converted into unsafe sockets. |