You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await.unwrap(); not compile anymore
if comment out the tap_io call, it will pass the compilation
/*.tap_io(|tcp_stream| { if let Err(err) = tcp_stream.set_nodelay(true) { eprintln!("failed to set TCP_NODELAY on incoming connection: {err:#}"); } })*/;
I have looked for existing issues (including closed) about this
Bug Report
Version
main branch
Platform
linux
Crates
Description
I tried this code:
use axum::{response::Html, routing::get,Router};use axum::extract::connect_info::ConnectInfo;use axum::serve::ListenerExt;use std::net::SocketAddr;#[tokio::main]asyncfnmain(){// build our application with a routelet app = Router::new().route("/",get(handler));// run itlet listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await.unwrap();println!("listening on {}", listener.local_addr().unwrap());let listener = listener
.tap_io(|tcp_stream| {ifletErr(err) = tcp_stream.set_nodelay(true){eprintln!("failed to set TCP_NODELAY on incoming connection: {err:#}");}});
axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await.unwrap();}asyncfnhandler(ConnectInfo(addr):ConnectInfo<SocketAddr>) -> Html<String>{Html(format!("<h1>Hello, World! {}</h1>", addr))}
cargo
[package]
name = "axum-connection-info"version = "0.1.0"edition = "2021"
[dependencies]
axum = { git = "https://github.com/tokio-rs/axum", branch = "main" }
tokio = { version = "1.41.1", features = ["full"] }
92 | pub fn serve<L, M, S>(listener: L, make_service: M) -> Serve<L, M, S>
| ----- required by a bound in this function
...
95 | M: for<'a> Service<IncomingStream<'a, L>, Error = Infallible, Response = S>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in serve
error[E0277]: Serve<TapIo<TcpListener, {closure@main.rs:18:17}>, IntoMakeServiceWithConnectInfo<..., ...>, ...> is not a future
--> src/main.rs:24:84
|
24 | axum::serve(listener, app.into_make_service_with_connect_info::()).await.unwrap();
| -------------------------------------------------------------------------------^^^^^
| | ||
| | |Serve<TapIo<TcpListener, {closure@main.rs:18:17}>, IntoMakeServiceWithConnectInfo<..., ...>, ...> is not a future
| | help: remove the .await
| this call returns Serve<TapIo<tokio::net::TcpListener, {closure@src/main.rs:18:17: 18:29}>, IntoMakeServiceWithConnectInfo<Router, std::net::SocketAddr>, AddExtension<Router, ConnectInfo<std::net::SocketAddr>>>
The text was updated successfully, but these errors were encountered:
ttys3
changed the title
into_make_service_with_connect_info not work anymore
into_make_service_with_connect_info not compile anymore
Dec 1, 2024
after this PR #2941
with
tap_io
called onlistener
,axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>()).await.unwrap();
not compile anymoreif comment out the tap_io call, it will pass the compilation
Bug Report
Version
main branch
Platform
linux
Crates
Description
I tried this code:
cargo
92 | pub fn serve<L, M, S>(listener: L, make_service: M) -> Serve<L, M, S>
| ----- required by a bound in this function
...
95 | M: for<'a> Service<IncomingStream<'a, L>, Error = Infallible, Response = S>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
serve
error[E0277]:
Serve<TapIo<TcpListener, {closure@main.rs:18:17}>, IntoMakeServiceWithConnectInfo<..., ...>, ...>
is not a future--> src/main.rs:24:84
|
24 | axum::serve(listener, app.into_make_service_with_connect_info::()).await.unwrap();
| -------------------------------------------------------------------------------^^^^^
| | ||
| | |
Serve<TapIo<TcpListener, {closure@main.rs:18:17}>, IntoMakeServiceWithConnectInfo<..., ...>, ...>
is not a future| | help: remove the
.await
| this call returns
Serve<TapIo<tokio::net::TcpListener, {closure@src/main.rs:18:17: 18:29}>, IntoMakeServiceWithConnectInfo<Router, std::net::SocketAddr>, AddExtension<Router, ConnectInfo<std::net::SocketAddr>>>
The text was updated successfully, but these errors were encountered: