I am writing a http server that works with it's host machine via a unix domain sockets. The server is written using hyper and I am connecting to UDS via socket2.
This is my code:
let socket = Socket::new(Domain::UNIX, Type::STREAM, None)?;
let socket_address = SockAddr::unix("unix://tmp/test.sock")?;
socket.bind(&socket_address)?;
socket.listen(128)?;
let server = hyper::server::Server::builder(socket.into()).serve(service);
What is the right way to do this? I am getting an error saying cannot infer type for type parameter I
error[E0698]: type inside `async fn` body must be known in this context
--> src/server.rs:65:64
|
65 | let server = hyper::server::Server::builder(socket.into()).serve(service);
| ^^^^^ cannot infer type for type parameter `I`
|
note: the type is part of the `async fn` body because of this `await`
--> src/server.rs:66:13
|
66 | let _ = server.await?;
| ^^^^^^^^^^^^
I
is the generic parameter to hyper::server::Server
. While I am aware what is causing the issue: compiler not able to determine what does socket.into()
get cast to, I don't know to solve it.
Please correct if my understanding is wrong. Can I get some help in this?