In main, we first parse a string representing our IPv6 loopback address (think localhost) as an std::net::SocketAddr, which is a type holding an IP address and a port [13]. Granted, we could have used a constant for our address, but we are showing how to parse it from a string, because in a real application you will probably fetch the address from an environment variable, as shown in Chapter 1, Learning the Basics; Interacting with environment variables.
We then run our hyper server, which we create in run_with_service_function [17]. Let's take a look at that function by learning a bit about hyper.
The most fundamental trait in hyper is the Service. It is defined as follows:
pub trait Service where
<Self::Future as Future>::Item == Self::Response,
<Self::Future as Future>::Error == Self::Error, {
type Request;
type Response;
type Error;
type Future: Future;
fn call(&self, req: Self::Request) -> Self::Future;
}
It should...