Function hyper::server::accept::poll_fn[][src]

pub fn poll_fn<F, IO, E>(func: F) -> impl Accept<Conn = IO, Error = E> where
    F: FnMut(&mut Context<'_>) -> Poll<Option<Result<IO, E>>>, 

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);