@@ -62,11 +62,16 @@ and [`RawHandle`]/[`RawSocket`] on Windows, which represent raw OS resource
62
62
handles. These don't provide any behavior on their own, and just represent
63
63
identifiers which can be passed to low-level OS APIs.
64
64
65
- These raw handles can be thought of as raw pointers, with similar hazards. The
66
- consequences of using an unintentionally aliased raw resource handle could
67
- include corrupted output or silently lost input data. It could also mean that
68
- code in one crate could accidentally corrupt or observe private data in another
69
- crate. Protection from these hazards is called * I/O safety* .
65
+ These raw handles can be thought of as raw pointers, with similar hazards.
66
+ While it's safe to * obtain* a raw pointer, * dereferencing* a raw pointer could
67
+ invoke undefined behavior if it isn't a valid pointer or if it outlives the
68
+ lifetime of the memory it points to. Similarly, it's safe to * obtain* a raw
69
+ handle, via [ ` AsRawFd::as_raw_fd ` ] and similar, but using it to do I/O could
70
+ lead to corrupted output, lost or leaked input data, or violated encapsulation
71
+ boundaries, if it isn't a valid handle or it's used after the ` close ` of its
72
+ resource. And in both cases, the effects can be non-local, affecting otherwise
73
+ unrelated parts of a program. Protection from raw pointer hazards is called
74
+ memory safety, so protection from raw handle hazards is called * I/O safety* .
70
75
71
76
Rust's standard library also has high-level types such as [ ` File ` ] and
72
77
[ ` TcpStream ` ] which are wrappers around these raw handles, providing high-level
0 commit comments