summaryrefslogtreecommitdiff
path: root/src/sys/select.rs
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2021-09-04 10:47:54 -0600
committerAlan Somers <asomers@gmail.com>2021-09-04 11:44:17 -0600
commitb6f7da61d879c67111e179a261149678d73e266f (patch)
treebecb2a500fc62e799e28b34eafee39efefc1163d /src/sys/select.rs
parent39c63662ed910763b0ccc02473121f12517d1f42 (diff)
downloadnix-b6f7da61d879c67111e179a261149678d73e266f.zip
Document more things
Also, test rustdoc in CI, and demote missing_docs from a deny to a warning (but still deny it in CI).
Diffstat (limited to 'src/sys/select.rs')
-rw-r--r--src/sys/select.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sys/select.rs b/src/sys/select.rs
index a8035f79..0a0e830d 100644
--- a/src/sys/select.rs
+++ b/src/sys/select.rs
@@ -1,3 +1,4 @@
+//! Portably monitor a group of file descriptors for readiness.
use std::iter::FusedIterator;
use std::mem;
use std::ops::Range;
@@ -11,11 +12,13 @@ use crate::sys::time::{TimeSpec, TimeVal};
pub use libc::FD_SETSIZE;
+/// Contains a set of file descriptors used by [`select`]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct FdSet(libc::fd_set);
impl FdSet {
+ /// Create an empty `FdSet`
pub fn new() -> FdSet {
let mut fdset = mem::MaybeUninit::uninit();
unsafe {
@@ -24,18 +27,22 @@ impl FdSet {
}
}
+ /// Add a file descriptor to an `FdSet`
pub fn insert(&mut self, fd: RawFd) {
unsafe { libc::FD_SET(fd, &mut self.0) };
}
+ /// Remove a file descriptor from an `FdSet`
pub fn remove(&mut self, fd: RawFd) {
unsafe { libc::FD_CLR(fd, &mut self.0) };
}
+ /// Test an `FdSet` for the presence of a certain file descriptor.
pub fn contains(&self, fd: RawFd) -> bool {
unsafe { libc::FD_ISSET(fd, &self.0) }
}
+ /// Remove all file descriptors from this `FdSet`.
pub fn clear(&mut self) {
unsafe { libc::FD_ZERO(&mut self.0) };
}