blob: 9f454ff0bf20fb6576b56841851cbcff51a2783b [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A Rust implementation of gRPC, a high performance, open source, general RPC framework that puts mobile and HTTP/2 first."><meta name="keywords" content="rust, rustlang, rust-lang, tonic"><title>tonic - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../tonic/index.html"><div class="logo-container"><img src="https://raw.githubusercontent.com/tokio-rs/website/master/public/img/icons/tonic.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../tonic/index.html"><div class="logo-container">
<img src="https://raw.githubusercontent.com/tokio-rs/website/master/public/img/icons/tonic.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate tonic</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.6.2</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#attributes">Attribute Macros</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">tonic</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/tonic/lib.rs.html#1-122">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A Rust implementation of <a href="https://grpc.io">gRPC</a>, a high performance, open source, general
RPC framework that puts mobile and HTTP/2 first.</p>
<p><a href="https://github.com/hyperium/tonic"><code>tonic</code></a> is a gRPC over HTTP/2 implementation focused on <strong>high
performance</strong>, <strong>interoperability</strong>, and <strong>flexibility</strong>. 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.</p>
<h2 id="examples"><a href="#examples">Examples</a></h2>
<p>Examples can be found in the <a href="https://github.com/hyperium/tonic/tree/master/examples"><code>tonic-examples</code></a> crate.</p>
<h2 id="getting-started"><a href="#getting-started">Getting Started</a></h2>
<p>Follow the instructions in the <a href="https://docs.rs/tonic-build"><code>tonic-build</code></a> crate documentation.</p>
<h2 id="feature-flags"><a href="#feature-flags">Feature Flags</a></h2>
<ul>
<li><code>transport</code>: Enables the fully featured, batteries included client and server
implementation based on <a href="https://docs.rs/hyper"><code>hyper</code></a>, <a href="https://docs.rs/tower"><code>tower</code></a> and <a href="https://docs.rs/tokio"><code>tokio</code></a>. Enabled by default.</li>
<li><code>codegen</code>: Enables all the required exports and optional dependencies required
for <a href="https://docs.rs/tonic-build"><code>tonic-build</code></a>. Enabled by default.</li>
<li><code>tls</code>: Enables the <code>rustls</code> based TLS options for the <code>transport</code> feature. Not
enabled by default.</li>
<li><code>tls-roots</code>: Adds system trust roots to <code>rustls</code>-based gRPC clients using the
<code>rustls-native-certs</code> crate. Not enabled by default. <code>tls</code> must be enabled to use
<code>tls-roots</code>.</li>
<li><code>tls-webpki-roots</code>: Add the standard trust roots from the <code>webpki-roots</code> crate to
<code>rustls</code>-based gRPC clients. Not enabled by default.</li>
<li><code>prost</code>: Enables the <a href="https://docs.rs/prost"><code>prost</code></a> based gRPC <a href="codec/trait.Codec.html"><code>Codec</code></a> implementation.</li>
<li><code>compression</code>: Enables compressing requests, responses, and streams. Note
that you must enable the <code>compression</code> feature on both <code>tonic</code> and
<code>tonic-build</code> to use it. Depends on <a href="https://crates.io/crates/flate2">flate2</a>. Not enabled by default.</li>
</ul>
<h2 id="structure"><a href="#structure">Structure</a></h2><h3 id="generic-implementation"><a href="#generic-implementation">Generic implementation</a></h3>
<p>The main goal of <a href="https://github.com/hyperium/tonic"><code>tonic</code></a> 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
<a href="client/index.html"><code>client</code></a> and <a href="transport/struct.Server.html"><code>server</code></a>.</p>
<h3 id="transport"><a href="#transport">Transport</a></h3>
<p>The <a href="transport/index.html"><code>transport</code></a> module contains a fully featured HTTP/2.0 <a href="transport/struct.Channel.html"><code>Channel</code></a> (gRPC terminology)
and <a href="transport/struct.Server.html"><code>Server</code></a>. These implementations are built on top of <a href="https://docs.rs/tokio"><code>tokio</code></a>, <a href="https://docs.rs/hyper"><code>hyper</code></a> and <a href="https://docs.rs/tower"><code>tower</code></a>.
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 <a href="https://docs.rs/rustls"><code>rustls</code></a>, via the <code>tls</code> feature flag.</p>
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="body/index.html" title="tonic::body mod">body</a></div><div class="item-right docblock-short">HTTP specific body utilities.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="client/index.html" title="tonic::client mod">client</a></div><div class="item-right docblock-short">Generic client implementation.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="codec/index.html" title="tonic::codec mod">codec</a></div><div class="item-right docblock-short">Generic encoding and decoding.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="metadata/index.html" title="tonic::metadata mod">metadata</a></div><div class="item-right docblock-short">Contains data structures and utilities for handling gRPC custom metadata.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="server/index.html" title="tonic::server mod">server</a></div><div class="item-right docblock-short">Generic server implementation.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="service/index.html" title="tonic::service mod">service</a></div><div class="item-right docblock-short">Utilities for using Tower services with Tonic.</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="transport/index.html" title="tonic::transport mod">transport</a></div><div class="item-right docblock-short">Batteries included server and client.</div></div></div><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.include_file_descriptor_set.html" title="tonic::include_file_descriptor_set macro">include_file_descriptor_set</a></div><div class="item-right docblock-short">Include an encoded <code>prost_types::FileDescriptorSet</code> as a <code>&amp;'static [u8]</code>. The parameter must be
the stem of the filename passed to <code>file_descriptor_set_path</code> for the <code>tonic-build::Builder</code>,
excluding the <code>.bin</code> extension.</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.include_proto.html" title="tonic::include_proto macro">include_proto</a></div><div class="item-right docblock-short">Include generated proto server and client items.</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Extensions.html" title="tonic::Extensions struct">Extensions</a></div><div class="item-right docblock-short">A type map of protocol extensions.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Request.html" title="tonic::Request struct">Request</a></div><div class="item-right docblock-short">A gRPC request and metadata from an RPC call.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Response.html" title="tonic::Response struct">Response</a></div><div class="item-right docblock-short">A gRPC response and metadata from an RPC call.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Status.html" title="tonic::Status struct">Status</a></div><div class="item-right docblock-short">A gRPC status describing the result of an RPC call.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Streaming.html" title="tonic::Streaming struct">Streaming</a></div><div class="item-right docblock-short">Streaming requests and responses.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Code.html" title="tonic::Code enum">Code</a></div><div class="item-right docblock-short">gRPC status codes used by <a href="struct.Status.html" title="Status"><code>Status</code></a>.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.IntoRequest.html" title="tonic::IntoRequest trait">IntoRequest</a></div><div class="item-right docblock-short">Trait implemented by RPC request types.</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.IntoStreamingRequest.html" title="tonic::IntoStreamingRequest trait">IntoStreamingRequest</a></div><div class="item-right docblock-short">Trait implemented by RPC streaming request types.</div></div></div><h2 id="attributes" class="small-section-header"><a href="#attributes">Attribute Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="attr" href="attr.async_trait.html" title="tonic::async_trait attr">async_trait</a></div><div class="item-right docblock-short">A re-export of <a href="https://docs.rs/async-trait"><code>async-trait</code></a> for use with codegen.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="tonic" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>