xref: /drstd/src/std/os/wasi/net/mod.rs (revision 0fe3ff0054d3aec7fbf9bddecfecb10bc7d23a51)
1 //! WASI-specific networking functionality
2 
3 use crate::std::io;
4 use crate::std::net;
5 use crate::std::sys_common::AsInner;
6 
7 /// WASI-specific extensions to [`std::net::TcpListener`].
8 ///
9 /// [`std::net::TcpListener`]: crate::std::net::TcpListener
10 pub trait TcpListenerExt {
11     /// Accept a socket.
12     ///
13     /// This corresponds to the `sock_accept` syscall.
14     fn sock_accept(&self, flags: u16) -> io::Result<u32>;
15 }
16 
17 impl TcpListenerExt for net::TcpListener {
18     fn sock_accept(&self, flags: u16) -> io::Result<u32> {
19         self.as_inner().as_inner().as_inner().sock_accept(flags)
20     }
21 }
22