pub fn poll_fn<F, IO, E>(func: F) -> impl Accept<Conn = IO, Error = E>
Expand description
Create an Accept
with a polling function.
§Example
use std::task::Poll;
use hyper::server::{accept, Server};
// If we created some mocked connection...
let mut conn = Some(mock_conn);
// And accept just the mocked conn once...
let once = accept::poll_fn(move |cx| {
Poll::Ready(conn.take().map(Ok::<_, ()>))
});
let builder = Server::builder(once);