Crate tonic[−][src]
A Rust implementation of gRPC, a high performance, open source, general RPC framework that puts mobile and HTTP/2 first.
tonic is a gRPC over HTTP/2 implementation focused on high
performance, interoperability, and flexibility. This library was
created to have first class support of async/await and to act as a core building
block for production systems written in Rust.
Examples
Examples can be found in the tonic-examples crate.
Getting Started
Follow the instructions in the tonic-build crate documentation.
Feature Flags
transport: Enables the fully featured, batteries included client and server implementation based onhyper,towerandtokio. Enabled by default.codegen: Enables all the required exports and optional dependencies required fortonic-build. Enabled by default.tls: Enables therustlsbased TLS options for thetransportfeature. Not enabled by default.tls-roots: Adds system trust roots torustls-based gRPC clients using therustls-native-certscrate. Not enabled by default.tlsmust be enabled to usetls-roots.prost: Enables theprostbased gRPCCodecimplementation.
Structure
Generic implementation
The main goal of tonic is to provide a generic gRPC implementation over HTTP/2
framing. This means at the lowest level this library provides the ability to use
a generic HTTP/2 implementation with different types of gRPC encodings formats. Generally,
some form of codegen should be used instead of interacting directly with the items in
client and server.
Transport
The transport module contains a fully featured HTTP/2.0 Channel (gRPC terminology)
and Server. These implementations are built on top of tokio, hyper and tower.
It also provides many of the features that the core gRPC libraries provide such as load balancing,
tls, timeouts, and many more. This implementation can also be used as a reference implementation
to build even more feature rich clients and servers. This module also provides the ability to
enable TLS using rustls, via the tls feature flag.
Modules
| body | HTTP specific body utilities. |
| client | Generic client implementation. |
| codec | Generic encoding and decoding. |
| metadata | Contains data structures and utilities for handling gRPC custom metadata. |
| server | Generic server implementation. |
| transport | transportBatteries included server and client. |
Macros
| include_file_descriptor_set | Include an encoded |
| include_proto | Include generated proto server and client items. |
Structs
| Interceptor | Represents a gRPC interceptor. |
| Request | A gRPC request and metadata from an RPC call. |
| Response | A gRPC response and metadata from an RPC call. |
| Status | A gRPC status describing the result of an RPC call. |
| Streaming | Streaming requests and responses. |
Enums
| Code | gRPC status codes used by |
Traits
| IntoRequest | Trait implemented by RPC request types. |
| IntoStreamingRequest | Trait implemented by RPC streaming request types. |
Attribute Macros
| async_trait | codegenA re-export of |