From 2cbb9d2ea1e72072394eb00b7c1658ec08512547 Mon Sep 17 00:00:00 2001 From: Gilad Naaman Date: Mon, 24 Feb 2025 11:31:49 +0000 Subject: [PATCH] Implement conversion from std::net::Shutdown --- changelog/2608.added.md | 1 + src/sys/socket/mod.rs | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 changelog/2608.added.md diff --git a/changelog/2608.added.md b/changelog/2608.added.md new file mode 100644 index 0000000000..2a8f927920 --- /dev/null +++ b/changelog/2608.added.md @@ -0,0 +1 @@ +Added `From` implementation for `sys::socket::Shutdown`. \ No newline at end of file diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs index e26e327d78..738bccf4f7 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs @@ -2545,6 +2545,17 @@ pub enum Shutdown { Both, } +#[cfg(feature = "net")] +impl From for Shutdown { + fn from(value: net::Shutdown) -> Self { + match value { + net::Shutdown::Read => Shutdown::Read, + net::Shutdown::Write => Shutdown::Write, + net::Shutdown::Both => Shutdown::Both, + } + } +} + /// Shut down part of a full-duplex connection. /// /// [Further reading](https://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html)