about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2021-11-16 09:14:19 +0900
committerGitHub <noreply@github.com>2021-11-16 09:14:19 +0900
commit96cfc9e73a6f68bde940d68dc069d84e8c8fc6ae (patch)
tree0f2fce5894af9ed7f49b5b4afb001ba7607e9303
parented7ed5fc9019f7968502d01270a82a9fa3685ee4 (diff)
parent2d46d1bec94ba9239f9c2305c574b34b853de1e5 (diff)
downloadrust-96cfc9e73a6f68bde940d68dc069d84e8c8fc6ae.tar.gz
rust-96cfc9e73a6f68bde940d68dc069d84e8c8fc6ae.zip
Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton
Rename WASI's `is_character_device` to `is_char_device`.

Rename WASI's `FileTypeExt::is_character_device` to
`FileTypeExt::is_char_device`, for consistency with the Unix
`FileTypeExt::is_char_device`.

Also, add a `FileTypeExt::is_socket` function, for consistency with the
Unix `FileTypeExt::is_socket` function.

r? `@alexcrichton`
-rw-r--r--library/std/src/os/wasi/fs.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/library/std/src/os/wasi/fs.rs b/library/std/src/os/wasi/fs.rs
index 907368061d7..5c62679f552 100644
--- a/library/std/src/os/wasi/fs.rs
+++ b/library/std/src/os/wasi/fs.rs
@@ -444,18 +444,22 @@ pub trait FileTypeExt {
     /// Returns `true` if this file type is a block device.
     fn is_block_device(&self) -> bool;
     /// Returns `true` if this file type is a character device.
-    fn is_character_device(&self) -> bool;
+    fn is_char_device(&self) -> bool;
     /// Returns `true` if this file type is a socket datagram.
     fn is_socket_dgram(&self) -> bool;
     /// Returns `true` if this file type is a socket stream.
     fn is_socket_stream(&self) -> bool;
+    /// Returns `true` if this file type is any type of socket.
+    fn is_socket(&self) -> bool {
+        self.is_socket_stream() || self.is_socket_dgram()
+    }
 }
 
 impl FileTypeExt for fs::FileType {
     fn is_block_device(&self) -> bool {
         self.as_inner().bits() == wasi::FILETYPE_BLOCK_DEVICE
     }
-    fn is_character_device(&self) -> bool {
+    fn is_char_device(&self) -> bool {
         self.as_inner().bits() == wasi::FILETYPE_CHARACTER_DEVICE
     }
     fn is_socket_dgram(&self) -> bool {