用户点击enter到并获得输入的响应。同时,如果用户在输入响应时点击ctrl+c,我还希望关闭客户端。我正努力在我的解决方案中实现这一点。为此,我使用tokio::select,有两个分支负责接受ctrl+c和用户输入。使用tokio::signal捕获ctrl+c击键。 use mio::net::SocketAddr; use tokio::net::TcpListener; use tokio::s...
("serve failed {err}"); } } _ = tokio::signal::ctrl_c() => { println!("shutting down"); } } Ok(()) } Changelog 0.2.1: Fix the maximum value of the size_t type. Closes: #2 Benchmark 10 VUs, 10 seconds, work as a http proxy to download 100Mb file. tokio::io::...
features=["full","tracing"]}tokio-util="0.7.11"tracing="0.1.40"tracing-subscriber="0.3.18"ctrlc="3.4.4"miette={version="7.2.0",features=["fancy"]}cross
}pub(crate) fn ctrl_c() -> io::Result<Signal> { signal(SignalKind::interrupt()) }#[cfg(all(test, not(loom)))] mod tests { use super::*;#[test] fn signal_enable_error_on_invalid_input() { signal_enable(-1).unwrap_err(); ...
}#[tokio::main]asyncfnmain(){letstart =Instant::now();letclients:Vec<reqwest::Client>=(0..NUM_CLIENTS).map(|_|{reqwest::ClientBuilder::new().pool_idle_timeout(Duration::from_secs(1)).http2_prior_knowledge()// mark as an HTTP/2 client.build().unwrap()}).collect();println!("...