In trying to adapt an example server, not sure what to make of this behaviour where the TcpStream
I'm asking for and the one I'm getting appear to be entirely different.
Example struct definition:
use mio::tcp::TcpStream;
struct Connection {
socket: TcpStream
}
Later there's a function defined for Connection
:
fn writable(&mut self, event_loop: &mut EventLoop<Server>) -> Result<()> {
loop {
let (len, res) = {
let buf = &self.buffer.bytes();
let len = buf.len();
let res = self.socket.write_slice(buf);
(len, res)
};
An error on write_slice
shows up with:
error: type `std::net::tcp::TcpStream` does not implement any method in scope named `write_slice`
Now std::net::tcp::TcpStream
doesn't implement this, but the mio::tcp::TcpStream
does. Why would one get substituted for the other?
Setting this as an alias, use mil::tcp::TcpStream as MioTcpStream
doesn't affect this either.
It turns out this is a problem with the published version of the mio
package.
Adding the following to Cargo.toml
pulls down and uses the latest working version:
[dependencies.mio]
git = "https://github.com/carllerche/mio.git"