Expand description
Batteries included server and client.
This module provides a set of batteries included, fully featured and
fast set of HTTP/2 server and client’s. These components each provide a or
rustls tls backend when the respective feature flag is enabled, and
provides builders to configure transport behavior.
§Features
- TLS support via rustls.
 - Load balancing
 - Timeouts
 - Concurrency Limits
 - Rate limiting
 
§Examples
§Client
let cert = std::fs::read_to_string("ca.pem")?;
let mut channel = Channel::from_static("https://example.com")
    .tls_config(ClientTlsConfig::new()
        .ca_certificate(Certificate::from_pem(&cert))
        .domain_name("example.com".to_string()))?
    .timeout(Duration::from_secs(5))
    .rate_limit(5, Duration::from_secs(1))
    .concurrency_limit(256)
    .connect()
    .await?;
channel.call(Request::new(BoxBody::empty())).await?;§Server
let cert = std::fs::read_to_string("server.pem")?;
let key = std::fs::read_to_string("server.key")?;
let addr = "[::1]:50051".parse()?;
Server::builder()
    .tls_config(ServerTlsConfig::new()
        .identity(Identity::from_pem(&cert, &key)))?
    .concurrency_limit_per_connection(256)
    .add_service(my_svc)
    .serve(addr)
    .await?;
Re-exports§
pub use self::channel::ClientTlsConfig;pub use self::server::ServerTlsConfig;
Modules§
Structs§
- Body
 - A stream of 
Bytes, used when receiving bodies. - Certificate
 - Represents a X509 certificate.
 - Channel
 - A default batteries included 
transportchannel. - Endpoint
 - Channel builder.
 - Error
 - Error’s that originate from the client or server;
 - Identity
 - Represents a private key and X509 certificate.
 - Server
 - A default batteries included 
transportserver. - Timeout
Expired  - Error returned if a request didn’t complete within the configured timeout.
 - Uri
 - The URI component of a request.
 
Traits§
- Named
Service  - A trait to provide a static reference to the service’s name. This is used for routing service’s within the router.