J'essaie d'écrire un simple client TCP dans Rust en utilisant Tokio caisse. Mon code est assez proche de this example moins le TLS:Le trait lié `(): futures :: Future` n'est pas satisfait lors de l'utilisation de TcpConnectionNew
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
use futures::Future;
use tokio_core::net::TcpStream;
use tokio_core::reactor::Core;
use tokio_io::io;
fn main() {
let mut core = Core::new().unwrap();
let handle = core.handle();
let connection = TcpStream::connect(&"127.0.0.1:8080".parse().unwrap(), &handle);
let server = connection.and_then(|stream| {
io::write_all(stream, b"hello");
});
core.run(server).unwrap();
}
Cependant, la compilation échoue avec l'erreur:
error[E0277]: the trait bound `(): futures::Future` is not satisfied
--> src/main.rs:16:29
|
16 | let server = connection.and_then(|stream| {
| ^^^^^^^^ the trait `futures::Future` is not implemented for `()`
|
= note: required because of the requirements on the impl of `futures::IntoFuture` for `()`
error[E0277]: the trait bound `(): futures::Future` is not satisfied
--> src/main.rs:20:10
|
20 | core.run(server).unwrap();
| ^^^ the trait `futures::Future` is not implemented for `()`
|
= note: required because of the requirements on the impl of `futures::IntoFuture` for `()`
Je trouve étrange car selon the documentation il devrait être mis en œuvre.
J'utilise
- Rust 1.19.0
- terme 0.1.16
- tokio-core 0.1.10
- tokio-io 0.1.3
Qu'est-ce que Ai-je disparu?