// Spawn a task to poll the connection, driving the HTTP state
tokio::task::spawn(async move {
if let Err(err) = conn.await {
println!("Connection failed: {:?}", err);
}
});
What errors might this spawned thread generate? Should they be sent back to the main thread? If so, how should they be sent back?
tokio::spawn() returns a JoinHandle that can you can .await to get the result . You can also use async channels to send the errors elsewhere out of the task (oneshot channel).
However, I'd avoid spawning completely and use:
try_join!(conn, async { rest of the code })
which will poll both futures without having to spawn.