(stream: TcpStream)
| 106 | tx_cursor: usize, |
| 107 | read_eof: bool, |
| 108 | disconnect_emitted: bool, |
| 109 | } |
| 110 | |
| 111 | impl TcpConnection { |
| 112 | pub fn connect<A: ToSocketAddrs>(addr: A) -> NetResult<Self> { |
| 113 | let stream = TcpStream::connect(addr) |
| 114 | .map_err(|err| NetError::from_io(NetErrorKind::Connect, err))?; |
| 115 | Self::from_stream(stream) |
| 116 | } |
| 117 | |
| 118 | pub fn from_stream(stream: TcpStream) -> NetResult<Self> { |
| 119 | let peer = stream |
| 120 | .peer_addr() |
| 121 | .map_err(|err| NetError::from_io(NetErrorKind::PeerAddress, err))?; |
| 122 | stream |
| 123 | .set_nonblocking(true) |
nothing calls this directly
no test coverage detected