1//! The [`is_read_write`] function.
2//!
3//! [`is_read_write`]: https://docs.rs/rustix/*/rustix/io/fn.is_read_write.html
4
5use crate::{backend, io};
6use backend::fd::AsFd;
7
8/// Returns a pair of booleans indicating whether the file descriptor is
9/// readable and/or writable, respectively.
10///
11/// Unlike [`is_file_read_write`], this correctly detects whether sockets
12/// have been shutdown, partially or completely.
13///
14/// [`is_file_read_write`]: crate::fs::is_file_read_write
15#[inline]
16#[cfg_attr(doc_cfg, doc(cfg(all(feature = "fs", feature = "net"))))]
17pub fn is_read_write<Fd: AsFd>(fd: Fd) -> io::Result<(bool, bool)> {
18 backend::io::syscalls::is_read_write(fd.as_fd())
19}
20