Skip to content

Commit 704611a

Browse files
authored
Miscellaneous documentation cleanups. (bytecodealliance#967)
1 parent 287509b commit 704611a

27 files changed

+136
-131
lines changed

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = [
55
"Dan Gohman <dev@sunfishcode.online>",
66
"Jakub Konka <kubkon@jakubkonka.com>",
77
]
8-
description = "Safe Rust bindings to POSIX/Unix/Linux/Winsock2-like syscalls"
8+
description = "Safe Rust bindings to POSIX/Unix/Linux/Winsock-like syscalls"
99
documentation = "https://docs.rs/rustix"
1010
license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
1111
repository = "https://github.com/bytecodealliance/rustix"
@@ -55,7 +55,7 @@ libc = { version = "0.2.150", default-features = false, features = ["extra_trait
5555
[target.'cfg(all(any(target_os = "android", target_os = "linux"), any(rustix_use_libc, miri, not(all(target_os = "linux", target_endian = "little", any(target_arch = "arm", all(target_arch = "aarch64", target_pointer_width = "64"), target_arch = "riscv64", all(rustix_use_experimental_asm, target_arch = "powerpc64"), all(rustix_use_experimental_asm, target_arch = "mips"), all(rustix_use_experimental_asm, target_arch = "mips32r6"), all(rustix_use_experimental_asm, target_arch = "mips64"), all(rustix_use_experimental_asm, target_arch = "mips64r6"), target_arch = "x86", all(target_arch = "x86_64", target_pointer_width = "64")))))))'.dependencies]
5656
linux-raw-sys = { version = "0.4.11", default-features = false, features = ["general", "ioctl", "no_std"] }
5757

58-
# For the libc backend on Windows, use the Winsock2 API in windows-sys.
58+
# For the libc backend on Windows, use the Winsock API in windows-sys.
5959
[target.'cfg(windows)'.dependencies.windows-sys]
6060
version = "0.52.0"
6161
features = [

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<h1><code>rustix</code></h1>
33

44
<p>
5-
<strong>Safe Rust bindings to POSIX/Unix/Linux/Winsock2 syscalls</strong>
5+
<strong>Safe Rust bindings to POSIX/Unix/Linux/Winsock syscalls</strong>
66
</p>
77

88
<strong>A <a href="https://bytecodealliance.org/">Bytecode Alliance</a> project</strong>
@@ -16,17 +16,17 @@
1616
</div>
1717

1818
`rustix` provides efficient memory-safe and [I/O-safe] wrappers to POSIX-like,
19-
Unix-like, Linux, and Winsock2 syscall-like APIs, with configurable backends.
19+
Unix-like, Linux, and Winsock syscall-like APIs, with configurable backends.
2020
It uses Rust references, slices, and return values instead of raw pointers, and
2121
[I/O safety types] instead of raw file descriptors, providing memory safety,
2222
[I/O safety], and [provenance]. It uses `Result`s for reporting errors,
2323
[`bitflags`] instead of bare integer flags, an [`Arg`] trait with optimizations
2424
to efficiently accept any Rust string type, and several other efficient
2525
conveniences.
2626

27-
`rustix` is low-level and, and while the `net` API supports Winsock2 on
28-
Windows, the rest of the APIs do not support Windows; for higher-level and more
29-
portable APIs built on this functionality, see the [`cap-std`], [`memfd`],
27+
`rustix` is low-level and, and while the `net` API supports [Windows Sockets 2]
28+
(Winsock), the rest of the APIs do not support Windows; for higher-level and
29+
more portable APIs built on this functionality, see the [`cap-std`], [`memfd`],
3030
[`timerfd`], and [`io-streams`] crates, for example.
3131

3232
`rustix` currently has two backends available:
@@ -42,7 +42,7 @@ portable APIs built on this functionality, see the [`cap-std`], [`memfd`],
4242
provenance all the way down to the syscalls.
4343

4444
* libc, which uses the [`libc`] crate which provides bindings to native `libc`
45-
libraries on Unix-family platforms, and [`windows-sys`] for Winsock2 on
45+
libraries on Unix-family platforms, and [`windows-sys`] for Winsock on
4646
Windows, and is portable to many OS's.
4747

4848
The linux_raw backend is enabled by default on platforms which support it. To
@@ -165,6 +165,7 @@ always reflect “very old” Linux versions.
165165
[any current Rust target]: https://doc.rust-lang.org/nightly/rustc/platform-support.html
166166
[kernel.org]: https://www.kernel.org/releases.html
167167
[Rust on Debian stable]: https://packages.debian.org/stable/rust/rustc
168+
[Windows Sockets 2]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-start-page-2
168169
[`nix`]: https://crates.io/crates/nix
169170
[`unix`]: https://crates.io/crates/unix
170171
[`nc`]: https://crates.io/crates/nc

src/backend/libc/fs/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ bitflags! {
159159
#[cfg(not(target_os = "espidf"))]
160160
impl Mode {
161161
/// Construct a `Mode` from the mode bits of the `st_mode` field of a
162-
/// `Stat`.
162+
/// `Mode`.
163163
#[inline]
164164
pub const fn from_raw_mode(st_mode: RawMode) -> Self {
165165
Self::from_bits_truncate(st_mode)
166166
}
167167

168-
/// Construct an `st_mode` value from `Stat`.
168+
/// Construct an `st_mode` value from a `Mode`.
169169
#[inline]
170170
pub const fn as_raw_mode(self) -> RawMode {
171171
self.bits()
@@ -503,7 +503,7 @@ impl FileType {
503503
}
504504
}
505505

506-
/// Construct an `st_mode` value from `Stat`.
506+
/// Construct an `st_mode` value from a `FileType`.
507507
#[inline]
508508
pub const fn as_raw_mode(self) -> RawMode {
509509
match self {

src/backend/libc/io/errno.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use libc_errno::errno;
1414
/// # References
1515
/// - [POSIX]
1616
/// - [Linux]
17-
/// - [Winsock2]
17+
/// - [Winsock]
1818
/// - [FreeBSD]
1919
/// - [NetBSD]
2020
/// - [OpenBSD]
@@ -24,7 +24,7 @@ use libc_errno::errno;
2424
///
2525
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
2626
/// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
27-
/// [Winsock2]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
27+
/// [Winsock]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
2828
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
2929
/// [NetBSD]: https://man.netbsd.org/errno.2
3030
/// [OpenBSD]: https://man.openbsd.org/errno.2

src/backend/libc/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! The libc backend.
22
//!
33
//! On most platforms, this uses the `libc` crate to make system calls. On
4-
//! Windows, this uses the Winsock2 API in `windows-sys`, which can be adapted
4+
//! Windows, this uses the Winsock API in `windows-sys`, which can be adapted
55
//! to have a very `libc`-like interface.
66
77
// Every FFI call requires an unsafe block, and there are a lot of FFI
@@ -21,11 +21,11 @@ pub(crate) mod fd {
2121
};
2222
pub(crate) use windows_sys::Win32::Networking::WinSock::SOCKET as LibcFd;
2323

24-
/// A version of [`AsRawFd`] for use with Winsock2 API.
24+
/// A version of [`AsRawFd`] for use with Winsock API.
2525
///
2626
/// [`AsRawFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.AsRawFd.html
2727
pub trait AsRawFd {
28-
/// A version of [`as_raw_fd`] for use with Winsock2 API.
28+
/// A version of [`as_raw_fd`] for use with Winsock API.
2929
///
3030
/// [`as_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.as_raw_fd
3131
fn as_raw_fd(&self) -> RawFd;
@@ -37,11 +37,11 @@ pub(crate) mod fd {
3737
}
3838
}
3939

40-
/// A version of [`IntoRawFd`] for use with Winsock2 API.
40+
/// A version of [`IntoRawFd`] for use with Winsock API.
4141
///
4242
/// [`IntoRawFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.IntoRawFd.html
4343
pub trait IntoRawFd {
44-
/// A version of [`into_raw_fd`] for use with Winsock2 API.
44+
/// A version of [`into_raw_fd`] for use with Winsock API.
4545
///
4646
/// [`into_raw_fd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html#tymethod.into_raw_fd
4747
fn into_raw_fd(self) -> RawFd;
@@ -53,11 +53,11 @@ pub(crate) mod fd {
5353
}
5454
}
5555

56-
/// A version of [`FromRawFd`] for use with Winsock2 API.
56+
/// A version of [`FromRawFd`] for use with Winsock API.
5757
///
5858
/// [`FromRawFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.FromRawFd.html
5959
pub trait FromRawFd {
60-
/// A version of [`from_raw_fd`] for use with Winsock2 API.
60+
/// A version of [`from_raw_fd`] for use with Winsock API.
6161
///
6262
/// # Safety
6363
///
@@ -74,11 +74,11 @@ pub(crate) mod fd {
7474
}
7575
}
7676

77-
/// A version of [`AsFd`] for use with Winsock2 API.
77+
/// A version of [`AsFd`] for use with Winsock API.
7878
///
7979
/// [`AsFd`]: https://doc.rust-lang.org/stable/std/os/fd/trait.AsFd.html
8080
pub trait AsFd {
81-
/// An `as_fd` function for Winsock2, where a `Fd` is a `Socket`.
81+
/// An `as_fd` function for Winsock, where a `Fd` is a `Socket`.
8282
fn as_fd(&self) -> BorrowedFd;
8383
}
8484
impl<T: AsSocket> AsFd for T {

src/backend/libc/mount/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ bitflags! {
227227
/// `MOVE_MOUNT__MASK`
228228
const MOVE_MOUNT_SET_GROUP = 0x0000_0100;
229229

230-
// TODO: add when linux 6.5 is released
230+
// TODO: add when Linux 6.5 is released
231231
// /// `MOVE_MOUNT_BENEATH`
232232
// const MOVE_MOUNT_BENEATH = 0x0000_0200;
233233

src/backend/libc/pipe/types.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ bitflags! {
5353
}
5454
}
5555

56-
/// A buffer type used with `vmsplice`.
56+
/// A buffer type for use with [`vmsplice`].
5757
///
5858
/// It is guaranteed to be ABI compatible with the iovec type on Unix platforms
5959
/// and `WSABUF` on Windows. Unlike `IoSlice` and `IoSliceMut` it is
6060
/// semantically like a raw pointer, and therefore can be shared or mutated as
6161
/// needed.
62+
///
63+
/// [`vmsplice`]: crate::pipe::vmsplice
6264
#[cfg(linux_kernel)]
6365
#[repr(transparent)]
6466
pub struct IoSliceRaw<'a> {

src/backend/libc/pty/syscalls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(crate) fn ptsname(fd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CSt
5858
}
5959
};
6060

61-
// MacOS 10.13.4 has `ptsname_r`; use it if we have it, otherwise fall
61+
// macOS 10.13.4 has `ptsname_r`; use it if we have it, otherwise fall
6262
// back to calling the underlying ioctl directly.
6363
#[cfg(apple)]
6464
let r = unsafe {

src/backend/libc/winsock_c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Adapt the Winsock2 API to resemble a POSIX-style libc API.
1+
//! Adapt the Winsock API to resemble a POSIX-style libc API.
22
33
#![allow(unused_imports)]
44
#![allow(non_camel_case_types)]

src/backend/linux_raw/event/epoll.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Linx `epoll` support.
1+
//! Linux `epoll` support.
22
//!
33
//! # Examples
44
//!
@@ -160,8 +160,8 @@ pub fn create(flags: CreateFlags) -> io::Result<OwnedFd> {
160160
syscalls::epoll_create(flags)
161161
}
162162

163-
/// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an
164-
/// epoll object.
163+
/// `epoll_ctl(self, EPOLL_CTL_ADD, data, event)`—Adds an element to an epoll
164+
/// object.
165165
///
166166
/// This registers interest in any of the events set in `events` occurring on
167167
/// the file descriptor associated with `data`.

src/backend/linux_raw/fs/inotify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub fn inotify_add_watch<P: crate::path::Arg>(
107107
path.into_with_c_str(|path| syscalls::inotify_add_watch(inot, path, flags))
108108
}
109109

110-
/// `inotify_rm_watch(self, wd)`—Removes a watch from this inotify
110+
/// `inotify_rm_watch(self, wd)`—Removes a watch from this inotify.
111111
///
112112
/// The watch descriptor provided should have previously been returned by
113113
/// [`inotify_add_watch`] and not previously have been removed.

src/backend/linux_raw/fs/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ bitflags! {
127127

128128
impl Mode {
129129
/// Construct a `Mode` from the mode bits of the `st_mode` field of a
130-
/// `Stat`.
130+
/// `Mode`.
131131
#[inline]
132132
pub const fn from_raw_mode(st_mode: RawMode) -> Self {
133133
Self::from_bits_truncate(st_mode)
134134
}
135135

136-
/// Construct an `st_mode` value from `Stat`.
136+
/// Construct an `st_mode` value from a `Mode`.
137137
#[inline]
138138
pub const fn as_raw_mode(self) -> RawMode {
139139
self.bits()
@@ -355,7 +355,7 @@ impl FileType {
355355
}
356356
}
357357

358-
/// Construct an `st_mode` value from `Stat`.
358+
/// Construct an `st_mode` value from a `FileType`.
359359
#[inline]
360360
pub const fn as_raw_mode(self) -> RawMode {
361361
match self {

src/backend/linux_raw/io/errno.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use linux_raw_sys::errno;
2424
/// # References
2525
/// - [POSIX]
2626
/// - [Linux]
27-
/// - [Winsock2]
27+
/// - [Winsock]
2828
/// - [FreeBSD]
2929
/// - [NetBSD]
3030
/// - [OpenBSD]
@@ -34,7 +34,7 @@ use linux_raw_sys::errno;
3434
///
3535
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
3636
/// [Linux]: https://man7.org/linux/man-pages/man3/errno.3.html
37-
/// [Winsock2]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
37+
/// [Winsock]: https://learn.microsoft.com/en-us/windows/win32/winsock/windows-sockets-error-codes-2
3838
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?errno
3939
/// [NetBSD]: https://man.netbsd.org/errno.2
4040
/// [OpenBSD]: https://man.openbsd.org/errno.2

src/backend/linux_raw/mount/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ bitflags! {
223223
/// `MOVE_MOUNT__MASK`
224224
const MOVE_MOUNT_SET_GROUP = linux_raw_sys::general::MOVE_MOUNT_SET_GROUP;
225225

226-
// TODO: add when linux 6.5 is released
226+
// TODO: add when Linux 6.5 is released
227227
// /// `MOVE_MOUNT_BENEATH`
228228
// const MOVE_MOUNT_BENEATH = linux_raw_sys::general::MOVE_MOUNT_BENEATH;
229229

src/backend/linux_raw/pipe/types.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bitflags! {
2222
}
2323

2424
bitflags! {
25-
/// `SPLICE_F_*` constants for use with [`splice`] [`vmsplice`], and
25+
/// `SPLICE_F_*` constants for use with [`splice`], [`vmsplice`], and
2626
/// [`tee`].
2727
#[repr(transparent)]
2828
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
@@ -41,12 +41,14 @@ bitflags! {
4141
}
4242
}
4343

44-
/// A buffer type used with `vmsplice`.
44+
/// A buffer type for use with [`vmsplice`].
4545
///
4646
/// It is guaranteed to be ABI compatible with the iovec type on Unix platforms
4747
/// and `WSABUF` on Windows. Unlike `IoSlice` and `IoSliceMut` it is
4848
/// semantically like a raw pointer, and therefore can be shared or mutated as
4949
/// needed.
50+
///
51+
/// [`vmsplice`]: crate::pipe::vmsplice
5052
#[repr(transparent)]
5153
pub struct IoSliceRaw<'a> {
5254
_buf: c::iovec,

src/event/kqueue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use core::mem::zeroed;
1313
use core::ptr::slice_from_raw_parts_mut;
1414
use core::time::Duration;
1515

16-
/// A `kqueue` event.
16+
/// A `kqueue` event for use with [`kevent`].
1717
#[repr(transparent)]
1818
#[derive(Copy, Clone)]
1919
pub struct Event {

src/event/poll.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub use backend::event::poll_fd::{PollFd, PollFlags};
99
/// - [POSIX]
1010
/// - [Linux]
1111
/// - [Apple]
12-
/// - [Winsock2]
12+
/// - [Winsock]
1313
/// - [FreeBSD]
1414
/// - [NetBSD]
1515
/// - [OpenBSD]
@@ -20,7 +20,7 @@ pub use backend::event::poll_fd::{PollFd, PollFlags};
2020
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html
2121
/// [Linux]: https://man7.org/linux/man-pages/man2/poll.2.html
2222
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/poll.2.html
23-
/// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsapoll
23+
/// [Winsock]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsapoll
2424
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=poll&sektion=2
2525
/// [NetBSD]: https://man.netbsd.org/poll.2
2626
/// [OpenBSD]: https://man.openbsd.org/poll.2

src/io/close.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use backend::fd::RawFd;
2525
/// - [POSIX]
2626
/// - [Linux]
2727
/// - [Apple]
28-
/// - [Winsock2]
28+
/// - [Winsock]
2929
/// - [FreeBSD]
3030
/// - [NetBSD]
3131
/// - [OpenBSD]
@@ -37,7 +37,7 @@ use backend::fd::RawFd;
3737
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html
3838
/// [Linux]: https://man7.org/linux/man-pages/man2/close.2.html
3939
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/close.2.html#//apple_ref/doc/man/2/close
40-
/// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-closesocket
40+
/// [Winsock]: https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-closesocket
4141
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=close&sektion=2
4242
/// [NetBSD]: https://man.netbsd.org/close.2
4343
/// [OpenBSD]: https://man.openbsd.org/close.2

src/io/ioctl.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ pub fn ioctl_fioclex<Fd: AsFd>(fd: Fd) -> io::Result<()> {
3131
/// `ioctl(fd, FIONBIO, &value)`—Enables or disables non-blocking mode.
3232
///
3333
/// # References
34-
/// - [Winsock2]
34+
/// - [Winsock]
3535
/// - [NetBSD]
3636
/// - [OpenBSD]
3737
///
38-
/// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#unix-ioctl-codes
38+
/// [Winsock]: https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#unix-ioctl-codes
3939
/// [NetBSD]: https://man.netbsd.org/ioctl.2#GENERIC%20IOCTLS
4040
/// [OpenBSD]: https://man.openbsd.org/ioctl.2#GENERIC_IOCTLS
4141
#[inline]
@@ -55,13 +55,13 @@ pub fn ioctl_fionbio<Fd: AsFd>(fd: Fd, value: bool) -> io::Result<()> {
5555
///
5656
/// # References
5757
/// - [Linux]
58-
/// - [Winsock2]
58+
/// - [Winsock]
5959
/// - [FreeBSD]
6060
/// - [NetBSD]
6161
/// - [OpenBSD]
6262
///
6363
/// [Linux]: https://man7.org/linux/man-pages/man2/ioctl_tty.2.html
64-
/// [Winsock2]: https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#unix-ioctl-codes
64+
/// [Winsock]: https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#unix-ioctl-codes
6565
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=ioctl&sektion=2#GENERIC%09IOCTLS
6666
/// [NetBSD]: https://man.netbsd.org/ioctl.2#GENERIC%20IOCTLS
6767
/// [OpenBSD]: https://man.openbsd.org/ioctl.2#GENERIC_IOCTLS

0 commit comments

Comments
 (0)