69 lines
9.3 KiB
HTML
69 lines
9.3 KiB
HTML
<!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="API documentation for the Rust `h2` crate."><meta name="keywords" content="rust, rustlang, rust-lang, h2"><title>h2 - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../h2/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate h2</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all h2's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'h2', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/h2/lib.rs.html#1-144' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>h2</a></span></h1><div class='docblock'><p>An asynchronous, HTTP/2.0 server and client implementation.</p>
|
||
<p>This library implements the <a href="https://http2.github.io/">HTTP/2.0</a> specification. The implementation is
|
||
asynchronous, using <a href="https://docs.rs/futures/">futures</a> as the basis for the API. The implementation
|
||
is also decoupled from TCP or TLS details. The user must handle ALPN and
|
||
HTTP/1.1 upgrades themselves.</p>
|
||
<h1 id="getting-started" class="section-header"><a href="#getting-started">Getting started</a></h1>
|
||
<p>Add the following to your <code>Cargo.toml</code> file:</p>
|
||
<pre><code class="language-toml">[dependencies]
|
||
h2 = "0.1"
|
||
</code></pre>
|
||
<p>Next, add this to your crate:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">h2</span>;</pre></div>
|
||
<h1 id="layout" class="section-header"><a href="#layout">Layout</a></h1>
|
||
<p>The crate is split into <a href="client/index.html"><code>client</code></a> and <a href="server/index.html"><code>server</code></a> modules. Types that are
|
||
common to both clients and servers are located at the root of the crate.</p>
|
||
<p>See module level documentation for more details on how to use <code>h2</code>.</p>
|
||
<h1 id="handshake" class="section-header"><a href="#handshake">Handshake</a></h1>
|
||
<p>Both the client and the server require a connection to already be in a state
|
||
ready to start the HTTP/2.0 handshake. This library does not provide
|
||
facilities to do this.</p>
|
||
<p>There are three ways to reach an appropriate state to start the HTTP/2.0
|
||
handshake.</p>
|
||
<ul>
|
||
<li>Opening an HTTP/1.1 connection and performing an <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism">upgrade</a>.</li>
|
||
<li>Opening a connection with TLS and use ALPN to negotiate the protocol.</li>
|
||
<li>Open a connection with prior knowledge, i.e. both the client and the
|
||
server assume that the connection is immediately ready to start the
|
||
HTTP/2.0 handshake once opened.</li>
|
||
</ul>
|
||
<p>Once the connection is ready to start the HTTP/2.0 handshake, it can be
|
||
passed to <a href="server/fn.handshake.html"><code>server::handshake</code></a> or <a href="client/fn.handshake.html"><code>client::handshake</code></a>. At this point, the
|
||
library will start the handshake process, which consists of:</p>
|
||
<ul>
|
||
<li>The client sends the connection preface (a predefined sequence of 24
|
||
octets).</li>
|
||
<li>Both the client and the server sending a SETTINGS frame.</li>
|
||
</ul>
|
||
<p>See the <a href="http://httpwg.org/specs/rfc7540.html#starting">Starting HTTP/2</a> in the specification for more details.</p>
|
||
<h1 id="flow-control" class="section-header"><a href="#flow-control">Flow control</a></h1>
|
||
<p><a href="http://httpwg.org/specs/rfc7540.html#FlowControl">Flow control</a> is a fundamental feature of HTTP/2.0. The <code>h2</code> library
|
||
exposes flow control to the user.</p>
|
||
<p>An HTTP/2.0 client or server may not send unlimited data to the peer. When a
|
||
stream is initiated, both the client and the server are provided with an
|
||
initial window size for that stream. A window size is the number of bytes
|
||
the endpoint can send to the peer. At any point in time, the peer may
|
||
increase this window size by sending a <code>WINDOW_UPDATE</code> frame. Once a client
|
||
or server has sent data filling the window for a stream, no further data may
|
||
be sent on that stream until the peer increases the window.</p>
|
||
<p>There is also a <strong>connection level</strong> window governing data sent across all
|
||
streams.</p>
|
||
<p>Managing flow control for inbound data is done through <a href="struct.ReleaseCapacity.html"><code>ReleaseCapacity</code></a>.
|
||
Managing flow control for outbound data is done through <a href="struct.SendStream.html"><code>SendStream</code></a>. See
|
||
the struct level documentation for those two types for more details.</p>
|
||
</div><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
|
||
<table><tr class='module-item'><td><a class="mod" href="client/index.html" title='h2::client mod'>client</a></td><td class='docblock-short'><p>Client implementation of the HTTP/2.0 protocol.</p>
|
||
</td></tr><tr class='module-item'><td><a class="mod" href="server/index.html" title='h2::server mod'>server</a></td><td class='docblock-short'><p>Server implementation of the HTTP/2.0 protocol.</p>
|
||
</td></tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
|
||
<table><tr class='module-item'><td><a class="struct" href="struct.Error.html" title='h2::Error struct'>Error</a></td><td class='docblock-short'><p>Represents HTTP/2.0 operation errors.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Ping.html" title='h2::Ping struct'>Ping</a></td><td class='docblock-short'><p>Sent via <a href="struct.PingPong.html"><code>PingPong</code></a> to send a PING frame to a peer.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.PingPong.html" title='h2::PingPong struct'>PingPong</a></td><td class='docblock-short'><p>A handle to send and receive PING frames with the peer.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Pong.html" title='h2::Pong struct'>Pong</a></td><td class='docblock-short'><p>Received via <a href="struct.PingPong.html"><code>PingPong</code></a> when a peer acknowledges a <a href="struct.Ping.html"><code>Ping</code></a>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Reason.html" title='h2::Reason struct'>Reason</a></td><td class='docblock-short'><p>HTTP/2.0 error codes.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.RecvStream.html" title='h2::RecvStream struct'>RecvStream</a></td><td class='docblock-short'><p>Receives the body stream and trailers from the remote peer.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.ReleaseCapacity.html" title='h2::ReleaseCapacity struct'>ReleaseCapacity</a></td><td class='docblock-short'><p>A handle to release window capacity to a remote stream.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.SendStream.html" title='h2::SendStream struct'>SendStream</a></td><td class='docblock-short'><p>Sends the body stream and trailers to the remote peer.</p>
|
||
</td></tr><tr class='module-item'><td><a class="struct" href="struct.StreamId.html" title='h2::StreamId struct'>StreamId</a></td><td class='docblock-short'><p>A stream identifier, as described in <a href="https://tools.ietf.org/html/rfc7540#section-5.1.1">Section 5.1.1</a> of RFC 7540.</p>
|
||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "h2";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |