Rust 1.39.0 (latest stable)
tokio 0.2.4
futures 0.3.1
Linux latitude 4.19.0-kali5-amd64 #1 SMP Debian 4.19.37-6kali1 (2019-07-22) x86_64 GNU/Linux
I created a project using the proxy example
After running cargo build I see the following errors:
Compiling proxy v0.1.0 (/home/seguidor777/Rust/proxy)
error[E0432]: unresolved imports `tokio::net::TcpListener`, `tokio::net::TcpStream`
--> src/main.rs:26:18
|
26 | use tokio::net::{TcpListener, TcpStream};
| ^^^^^^^^^^^ ^^^^^^^^^ no `TcpStream` in `net`
| |
| no `TcpListener` in `net`
error[E0433]: failed to resolve: could not find `main` in `tokio`
--> src/main.rs:33:10
|
33 | #[tokio::main]
| ^^^^ could not find `main` in `tokio`
error[E0425]: cannot find function `spawn` in crate `tokio`
--> src/main.rs:50:16
|
50 | tokio::spawn(transfer);
| ^^^^^ not found in `tokio`
help: possible candidate is found in another module, you can import it into scope
|
25 | use std::thread::spawn;
|
error[E0425]: cannot find function `copy` in module `io`
--> src/main.rs:62:32
|
62 | let client_to_server = io::copy(&mut ri, &mut wo);
| ^^^^ not found in `io`
help: possible candidates are found in other modules, you can import them into scope
|
25 | use core::intrinsics::copy;
|
25 | use core::ptr::copy;
|
25 | use futures::core_reexport::intrinsics::copy;
|
25 | use futures::core_reexport::ptr::copy;
|
and 5 other candidates
error[E0425]: cannot find function `copy` in module `io`
--> src/main.rs:63:32
|
63 | let server_to_client = io::copy(&mut ro, &mut wi);
| ^^^^ not found in `io`
help: possible candidates are found in other modules, you can import them into scope
|
25 | use core::intrinsics::copy;
|
25 | use core::ptr::copy;
|
25 | use futures::core_reexport::intrinsics::copy;
|
25 | use futures::core_reexport::ptr::copy;
|
and 5 other candidates
error[E0277]: `main` has invalid return type `impl core::future::future::Future`
--> src/main.rs:34:20
|
34 | async fn main() -> Result<(), Box<dyn Error>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination`
|
= help: consider using `()`, or a `Result`
error: aborting due to 6 previous errors
Some errors have detailed explanations: E0277, E0425, E0432, E0433.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `proxy`.
To learn more, run the command again with --verbose.
Could you please let me know if there really is a problem with the versions or if there are others that I should use?
it looks to me like you haven't added any features to your tokio dependency.
try
tokio = { version = "0.2.4", features = ["full"] }
It also looks like Result<(), Box<dyn Error>> doesn't implement Termination, which is unfortunate. You could try replacing Box<dyn Error> with anyhow::Error (docs) and see if that gets you where you need.
You are absolutely right, I am new to Rust and did not know of the features addition.
Thanks a lot!
Most helpful comment
it looks to me like you haven't added any features to your tokio dependency.
try
It also looks like
Result<(), Box<dyn Error>>doesn't implementTermination, which is unfortunate. You could try replacingBox<dyn Error>withanyhow::Error(docs) and see if that gets you where you need.