timely_communication/allocator/zero_copy/
stream.rs1use std::io;
4use std::net::{TcpStream, Shutdown};
5#[cfg(unix)]
6use std::os::unix::net::UnixStream;
7
8pub trait Stream: Sized + Send + Sync + io::Read + io::Write {
10 fn try_clone(&self) -> io::Result<Self>;
12
13 fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()>;
15
16 fn shutdown(&self, how: Shutdown) -> io::Result<()>;
18}
19
20impl Stream for TcpStream {
21 fn try_clone(&self) -> io::Result<Self> {
22 self.try_clone()
23 }
24
25 fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
26 self.set_nonblocking(nonblocking)
27 }
28
29 fn shutdown(&self, how: Shutdown) -> io::Result<()> {
30 self.shutdown(how)
31 }
32}
33
34#[cfg(unix)]
35impl Stream for UnixStream {
36 fn try_clone(&self) -> io::Result<Self> {
37 self.try_clone()
38 }
39
40 fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
41 self.set_nonblocking(nonblocking)
42 }
43
44 fn shutdown(&self, how: Shutdown) -> io::Result<()> {
45 self.shutdown(how)
46 }
47}