diff options
| author | Harald Hoyer <harald@profian.com> | 2022-11-24 09:38:14 +0100 |
|---|---|---|
| committer | Harald Hoyer <harald@profian.com> | 2022-11-24 10:08:36 +0100 |
| commit | e598af6f2710464e20a796d0d3eba642747bcbe3 (patch) | |
| tree | dba326a9b0d69a7ec424d39abfe89f03257f34b5 /library/std/src/sys | |
| parent | 008bc1d587b4f9d7197eb159922dd2080eea9284 (diff) | |
| download | rust-e598af6f2710464e20a796d0d3eba642747bcbe3.tar.gz rust-e598af6f2710464e20a796d0d3eba642747bcbe3.zip | |
feat: implement TcpStream shutdown for wasm32-wasi
Signed-off-by: Harald Hoyer <harald@profian.com>
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/wasi/net.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs index 590d268c380..cf4ebba1a39 100644 --- a/library/std/src/sys/wasi/net.rs +++ b/library/std/src/sys/wasi/net.rs @@ -119,8 +119,14 @@ impl TcpStream { unsupported() } - pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { - unsupported() + pub fn shutdown(&self, how: Shutdown) -> io::Result<()> { + let wasi_how = match how { + Shutdown::Read => wasi::SDFLAGS_RD, + Shutdown::Write => wasi::SDFLAGS_WR, + Shutdown::Both => wasi::SDFLAGS_RD | wasi::SDFLAGS_WR, + }; + + unsafe { wasi::sock_shutdown(self.socket().as_raw_fd() as _, wasi_how).map_err(err2io) } } pub fn duplicate(&self) -> io::Result<TcpStream> { |
