[−][src]Crate roa_tokio
This crate provides tokio-based runtime and acceptor for roa.
use roa::http::StatusCode; use roa::{App, Context}; use roa_tokio::{TcpIncoming, Exec}; use std::error::Error; async fn end(_ctx: &mut Context) -> roa::Result { Ok(()) } #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { let app = App::with_exec((), Exec).end(end); let incoming = TcpIncoming::bind("127.0.0.1:0")?; println!("server is listening on {}", incoming.local_addr()); app.accept(incoming).await?; Ok(()) }
Structs
Exec | Tokio-based executor. |
TcpIncoming | A stream of connections from binding to an address. As an implementation of roa_core::Accept. |