use boitalettres::proto::{Request, Response}; use boitalettres::server::accept::addr::{AddrIncoming, AddrStream}; use boitalettres::server::Server; async fn handle_req(req: Request) -> eyre::Result { use imap_codec::types::response::Status; tracing::debug!("Got request: {:#?}", req); Ok(Response::Status( Status::ok(Some(req.tag), None, "Ok").map_err(|e| eyre::eyre!(e))?, )) } #[tokio::main] async fn main() -> eyre::Result<()> { tracing_subscriber::fmt() .with_max_level(tracing::Level::TRACE) .init(); let incoming = AddrIncoming::new("127.0.0.1:4567").await?; let make_service = tower::service_fn(|addr: &AddrStream| { tracing::debug!("Accept: {} -> {}", addr.remote_addr, addr.local_addr); futures::future::ok::<_, std::convert::Infallible>(tower::service_fn(handle_req)) }); let server = Server::new(incoming).serve(make_service); let _ = server.await?; Ok(()) }