summaryrefslogtreecommitdiff
path: root/src/sys/select.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-09-04 18:25:41 +0000
committerGitHub <noreply@github.com>2021-09-04 18:25:41 +0000
commit5465167a7b56d8caeb4a44002eb108fadbfd49cb (patch)
tree3693b52af91034b1762205926ba8b00f06d4b685 /src/sys/select.rs
parent39c63662ed910763b0ccc02473121f12517d1f42 (diff)
parenta757be75fcdda80d9c441db35fdfedb402714223 (diff)
downloadnix-5465167a7b56d8caeb4a44002eb108fadbfd49cb.zip
Merge #1511
1511: Document more things r=asomers a=asomers Also, test rustdoc in CI, and demote missing_docs from a deny to a warning (but still deny it in CI). Co-authored-by: Alan Somers <asomers@gmail.com>
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) };
}