hyperlocal

Trait UnixServerExt

Source
pub trait UnixServerExt {
    // Required method
    fn bind_unix(
        path: impl AsRef<Path>,
    ) -> Result<Builder<SocketIncoming>, Error>;
}
Expand description

Extension trait for provisioning a hyper HTTP server over a Unix domain socket.

§Example

use hyper::{Server, Body, Response, service::{make_service_fn, service_fn}};
use hyperlocal::UnixServerExt;

let make_service = make_service_fn(|_| async {
    Ok::<_, hyper::Error>(service_fn(|_req| async {
        Ok::<_, hyper::Error>(Response::new(Body::from("It works!")))
    }))
});

Server::bind_unix("/tmp/hyperlocal.sock")?.serve(make_service).await?;

Required Methods§

Source

fn bind_unix(path: impl AsRef<Path>) -> Result<Builder<SocketIncoming>, Error>

Convenience method for constructing a Server listening on a Unix socket.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnixServerExt for Server<SocketIncoming, ()>

Source§

fn bind_unix(path: impl AsRef<Path>) -> Result<Builder<SocketIncoming>, Error>

Implementors§