Skip to content

Commit 3a31fa6

Browse files
authored
feat: impl AsRawFd and AsFd for UdpSocket (#1971)
Signed-off-by: San Zhang <[email protected]>
1 parent 68ce97d commit 3a31fa6

File tree

1 file changed

+14
-0
lines changed
  • crates/shadowsocks/src/net

1 file changed

+14
-0
lines changed

crates/shadowsocks/src/net/udp.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,3 +408,17 @@ impl From<UdpSocket> for tokio::net::UdpSocket {
408408
s.socket
409409
}
410410
}
411+
412+
#[cfg(unix)]
413+
impl std::os::fd::AsRawFd for UdpSocket {
414+
fn as_raw_fd(&self) -> std::os::fd::RawFd {
415+
self.socket.as_raw_fd()
416+
}
417+
}
418+
419+
#[cfg(unix)]
420+
impl std::os::fd::AsFd for UdpSocket {
421+
fn as_fd(&self) -> std::os::fd::BorrowedFd<'_> {
422+
self.socket.as_fd()
423+
}
424+
}

0 commit comments

Comments
 (0)