173 lines
21 KiB
HTML
173 lines
21 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 `Server` struct in crate `hyper`.">
|
|||
|
<meta name="keywords" content="rust, rustlang, rust-lang, Server">
|
|||
|
|
|||
|
<title>hyper::server::Server - 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="../../main.css" id="themeStyle">
|
|||
|
<script src="../../storage.js"></script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
<body class="rustdoc struct">
|
|||
|
<!--[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>
|
|||
|
|
|||
|
<p class='location'>Struct Server</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.local_addr">local_addr</a><a href="#method.handle">handle</a><a href="#method.shutdown_timeout">shutdown_timeout</a><a href="#method.run">run</a><a href="#method.run_until">run_until</a><a href="#method.run_threads">run_threads</a></div><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Debug">Debug</a></div></div><p class='location'><a href='../index.html'>hyper</a>::<wbr><a href='index.html'>server</a></p><script>window.sidebarCurrent = {name: 'Server', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></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 js-only">
|
|||
|
<div class="search-container">
|
|||
|
<input class="search-input" name="search"
|
|||
|
autocomplete="off"
|
|||
|
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
|||
|
type="search">
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
</nav>
|
|||
|
|
|||
|
<section id='main' class="content">
|
|||
|
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>hyper</a>::<wbr><a href='index.html'>server</a>::<wbr><a class="struct" href=''>Server</a></span><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/hyper/server/mod.rs.html#73-82' title='goto source code'>[src]</a></span></h1>
|
|||
|
<pre class='rust struct'>pub struct Server<S, B> <span class="where fmt-newline">where<br> B: <a class="trait" href="../../futures/stream/trait.Stream.html" title="trait futures::stream::Stream">Stream</a><Error = <a class="enum" href="../../hyper/error/enum.Error.html" title="enum hyper::error::Error">Error</a>>,<br> B::<a class="type" href="../../futures/stream/trait.Stream.html#associatedtype.Item" title="type futures::stream::Stream::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span> { /* fields omitted */ }</pre><div class='docblock'><p>An instance of a server created through <code>Http::bind</code>.</p>
|
|||
|
<p>This server is intended as a convenience for creating a TCP listener on an
|
|||
|
address and then serving TCP connections accepted with the service provided.</p>
|
|||
|
</div>
|
|||
|
<h2 id='methods' class='small-section-header'>
|
|||
|
Methods<a href='#methods' class='anchor'></a>
|
|||
|
</h2>
|
|||
|
<h3 id='impl' class='impl'><span class='in-band'><code>impl<S, B> <a class="struct" href="../../hyper/server/struct.Server.html" title="struct hyper::server::Server">Server</a><S, B> <span class="where fmt-newline">where<br> S: <a class="trait" href="../../hyper/server/trait.NewService.html" title="trait hyper::server::NewService">NewService</a><Request = <a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a>, Response = <a class="struct" href="../../hyper/struct.Response.html" title="struct hyper::Response">Response</a><B>, Error = <a class="enum" href="../../hyper/error/enum.Error.html" title="enum hyper::error::Error">Error</a>> + 'static,<br> B: <a class="trait" href="../../futures/stream/trait.Stream.html" title="trait futures::stream::Stream">Stream</a><Error = <a class="enum" href="../../hyper/error/enum.Error.html" title="enum hyper::error::Error">Error</a>> + 'static,<br> B::<a class="type" href="../../futures/stream/trait.Stream.html#associatedtype.Item" title="type futures::stream::Stream::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#326-451' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.local_addr' class="method"><span id='local_addr.v' class='invisible'><code>pub fn <a href='#method.local_addr' class='fnname'>local_addr</a>(&self) -> <a class="type" href="../../hyper/error/type.Result.html" title="type hyper::error::Result">Result</a><<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#332-334' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns the local address that this server is bound to.</p>
|
|||
|
</div><h4 id='method.handle' class="method"><span id='handle.v' class='invisible'><code>pub fn <a href='#method.handle' class='fnname'>handle</a>(&self) -> <a class="struct" href="../../tokio_core/reactor/struct.Handle.html" title="struct tokio_core::reactor::Handle">Handle</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#338-340' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Returns a handle to the underlying event loop that this server will be
|
|||
|
running on.</p>
|
|||
|
</div><h4 id='method.shutdown_timeout' class="method"><div class="important-traits"><div class='tooltip'>ⓘ<span class='tooltiptext'>Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>R</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>R</h3><code class="content"><span class="where fmt-newline">impl<'a, R> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>R <span class="where fmt-newline">where<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'a, W> <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>W <span class="where fmt-newline">where<br> W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline">impl<'a, I> <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>I <span class="where fmt-newline">where<br> I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <I as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>>::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><span id='shutdown_timeout.v' class='invisible'><code>pub fn <a href='#method.shutdown_timeout' class='fnname'>shutdown_timeout</a>(&mut self, timeout: <a class="struct" href="https://doc.rust-lang.org/nightly/core/time/struct.Duration.html" title="struct core::time::Duration">Duration</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#350-353' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Configure the amount of time this server will wait for a "graceful
|
|||
|
shutdown".</p>
|
|||
|
<p>This is the amount of time after the shutdown signal is received the
|
|||
|
server will wait for all pending connections to finish. If the timeout
|
|||
|
elapses then the server will be forcibly shut down.</p>
|
|||
|
<p>This defaults to 1s.</p>
|
|||
|
</div><h4 id='method.run' class="method"><span id='run.v' class='invisible'><code>pub fn <a href='#method.run' class='fnname'>run</a>(self) -> <a class="type" href="../../hyper/error/type.Result.html" title="type hyper::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#365-367' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Execute this server infinitely.</p>
|
|||
|
<p>This method does not currently return, but it will return an error if
|
|||
|
one occurs.</p>
|
|||
|
</div><h4 id='method.run_until' class="method"><span id='run_until.v' class='invisible'><code>pub fn <a href='#method.run_until' class='fnname'>run_until</a><F>(self, shutdown_signal: F) -> <a class="type" href="../../hyper/error/type.Result.html" title="type hyper::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> <span class="where fmt-newline">where<br> F: <a class="trait" href="../../futures/future/trait.Future.html" title="trait futures::future::Future">Future</a><Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>, </span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#382-450' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Execute this server until the given future, <code>shutdown_signal</code>, resolves.</p>
|
|||
|
<p>This method, like <code>run</code> above, is used to execute this HTTP server. The
|
|||
|
difference with <code>run</code>, however, is that this method allows for shutdown
|
|||
|
in a graceful fashion. The future provided is interpreted as a signal to
|
|||
|
shut down the server when it resolves.</p>
|
|||
|
<p>This method will block the current thread executing the HTTP server.
|
|||
|
When the <code>shutdown_signal</code> has resolved then the TCP listener will be
|
|||
|
unbound (dropped). The thread will continue to block for a maximum of
|
|||
|
<code>shutdown_timeout</code> time waiting for active connections to shut down.
|
|||
|
Once the <code>shutdown_timeout</code> elapses or all active connections are
|
|||
|
cleaned out then this method will return.</p>
|
|||
|
</div></div><h3 id='impl-1' class='impl'><span class='in-band'><code>impl<S, B> <a class="struct" href="../../hyper/server/struct.Server.html" title="struct hyper::server::Server">Server</a><S, B> <span class="where fmt-newline">where<br> S: <a class="trait" href="../../hyper/server/trait.NewService.html" title="trait hyper::server::NewService">NewService</a><Request = <a class="struct" href="../../hyper/struct.Request.html" title="struct hyper::Request">Request</a>, Response = <a class="struct" href="../../hyper/struct.Response.html" title="struct hyper::Response">Response</a><B>, Error = <a class="enum" href="../../hyper/error/enum.Error.html" title="enum hyper::error::Error">Error</a>> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> + 'static,<br> B: <a class="trait" href="../../futures/stream/trait.Stream.html" title="trait futures::stream::Stream">Stream</a><Error = <a class="enum" href="../../hyper/error/enum.Error.html" title="enum hyper::error::Error">Error</a>> + 'static,<br> B::<a class="type" href="../../futures/stream/trait.Stream.html#associatedtype.Item" title="type futures::stream::Stream::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a href='#impl-1' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#454-508' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.run_threads' class="method"><span id='run_threads.v' class='invisible'><code>pub fn <a href='#method.run_threads' class='fnname'>run_threads</a>(self, threads: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#461-507' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Run the server on multiple threads.</p>
|
|||
|
</div></div>
|
|||
|
<h2 id='implementations' class='small-section-header'>
|
|||
|
Trait Implementations<a href='#implementations' class='anchor'></a>
|
|||
|
</h2>
|
|||
|
<h3 id='impl-Debug' class='impl'><span class='in-band'><code>impl<S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>, B: <a class="trait" href="../../futures/stream/trait.Stream.html" title="trait futures::stream::Stream">Stream</a><Error = <a class="enum" href="../../hyper/error/enum.Error.html" title="enum hyper::error::Error">Error</a>>> <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../../hyper/server/struct.Server.html" title="struct hyper::server::Server">Server</a><S, B> <span class="where fmt-newline">where<br> B::<a class="type" href="../../futures/stream/trait.Stream.html#associatedtype.Item" title="type futures::stream::Stream::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>>, </span></code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#588-599' title='goto source code'>[src]</a></span></h3>
|
|||
|
<div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/hyper/server/mod.rs.html#591-598' title='goto source code'>[src]</a></span></h4>
|
|||
|
<div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
|
|||
|
</div></div></section>
|
|||
|
<section id='search' class="content hidden"></section>
|
|||
|
|
|||
|
<section class="footer"></section>
|
|||
|
|
|||
|
<aside id="help" class="hidden">
|
|||
|
<div>
|
|||
|
<h1 class="hidden">Help</h1>
|
|||
|
|
|||
|
<div class="shortcuts">
|
|||
|
<h2>Keyboard Shortcuts</h2>
|
|||
|
|
|||
|
<dl>
|
|||
|
<dt><kbd>?</kbd></dt>
|
|||
|
<dd>Show this help dialog</dd>
|
|||
|
<dt><kbd>S</kbd></dt>
|
|||
|
<dd>Focus the search field</dd>
|
|||
|
<dt><kbd>↑</kbd></dt>
|
|||
|
<dd>Move up in search results</dd>
|
|||
|
<dt><kbd>↓</kbd></dt>
|
|||
|
<dd>Move down in search results</dd>
|
|||
|
<dt><kbd>↹</kbd></dt>
|
|||
|
<dd>Switch tab</dd>
|
|||
|
<dt><kbd>⏎</kbd></dt>
|
|||
|
<dd>Go to active search result</dd>
|
|||
|
<dt><kbd>+</kbd></dt>
|
|||
|
<dd>Expand all sections</dd>
|
|||
|
<dt><kbd>-</kbd></dt>
|
|||
|
<dd>Collapse all sections</dd>
|
|||
|
</dl>
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="infos">
|
|||
|
<h2>Search Tricks</h2>
|
|||
|
|
|||
|
<p>
|
|||
|
Prefix searches with a type followed by a colon (e.g.
|
|||
|
<code>fn:</code>) to restrict the search to a given type.
|
|||
|
</p>
|
|||
|
|
|||
|
<p>
|
|||
|
Accepted types are: <code>fn</code>, <code>mod</code>,
|
|||
|
<code>struct</code>, <code>enum</code>,
|
|||
|
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
|||
|
and <code>const</code>.
|
|||
|
</p>
|
|||
|
|
|||
|
<p>
|
|||
|
Search functions by type signature (e.g.
|
|||
|
<code>vec -> usize</code> or <code>* -> vec</code>)
|
|||
|
</p>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</aside>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<script>
|
|||
|
window.rootPath = "../../";
|
|||
|
window.currentCrate = "hyper";
|
|||
|
</script>
|
|||
|
<script src="../../main.js"></script>
|
|||
|
<script defer src="../../search-index.js"></script>
|
|||
|
</body>
|
|||
|
</html>
|