mentat/tokio_proto/struct.TcpServer.html
2018-08-22 17:04:13 +00:00

176 lines
No EOL
18 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 `TcpServer` struct in crate `tokio_proto`.">
<meta name="keywords" content="rust, rustlang, rust-lang, TcpServer">
<title>tokio_proto::TcpServer - 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">&#9776;</div>
<p class='location'>Struct TcpServer</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#methods">Methods</a><div class="sidebar-links"><a href="#method.new">new</a><a href="#method.addr">addr</a><a href="#method.threads">threads</a><a href="#method.serve">serve</a><a href="#method.with_handle">with_handle</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'>tokio_proto</a></p><script>window.sidebarCurrent = {name: 'TcpServer', 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'>tokio_proto</a>::<wbr><a class="struct" href=''>TcpServer</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'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../src/tokio_proto/tcp_server.rs.html#36-41' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct TcpServer&lt;Kind, P&gt; { /* fields omitted */ }</pre><div class='docblock'><p>A builder for TCP servers.</p>
<p>Setting up a server needs, at minimum:</p>
<ul>
<li>A server protocol implementation</li>
<li>An address</li>
<li>A service to provide</li>
</ul>
<p>In addition to those basics, the builder provides some additional
configuration, which is expected to grow over time.</p>
<p>See the crate docs for an example.</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&lt;Kind, P&gt; <a class="struct" href="../tokio_proto/struct.TcpServer.html" title="struct tokio_proto::TcpServer">TcpServer</a>&lt;Kind, P&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="../tokio_proto/trait.BindServer.html" title="trait tokio_proto::BindServer">BindServer</a>&lt;Kind, <a class="struct" href="../tokio_core/net/tcp/struct.TcpStream.html" title="struct tokio_core::net::tcp::TcpStream">TcpStream</a>&gt; + <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,&nbsp;</span></code><a href='#impl' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/tokio_proto/tcp_server.rs.html#43-137' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class="method"><span id='new.v' class='invisible'><code>pub fn <a href='#method.new' class='fnname'>new</a>(protocol: P, addr: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>) -&gt; <a class="struct" href="../tokio_proto/struct.TcpServer.html" title="struct tokio_proto::TcpServer">TcpServer</a>&lt;Kind, P&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/tokio_proto/tcp_server.rs.html#59-66' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Starts building a server for the given protocol and address, with
default configuration.</p>
<p>Generally, a protocol is implemented <em>not</em> by implementing the
<code>BindServer</code> trait directly, but instead by implementing one of the
protocol traits:</p>
<ul>
<li><code>pipeline::ServerProto</code></li>
<li><code>multiplex::ServerProto</code></li>
<li><code>streaming::pipeline::ServerProto</code></li>
<li><code>streaming::multiplex::ServerProto</code></li>
</ul>
<p>See the crate documentation for more details on those traits.</p>
</div><h4 id='method.addr' class="method"><span id='addr.v' class='invisible'><code>pub fn <a href='#method.addr' class='fnname'>addr</a>(&amp;mut self, addr: <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/tokio_proto/tcp_server.rs.html#69-71' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Set the address for the server.</p>
</div><h4 id='method.threads' class="method"><span id='threads.v' class='invisible'><code>pub fn <a href='#method.threads' class='fnname'>threads</a>(&amp;mut 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/tokio_proto/tcp_server.rs.html#74-79' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Set the number of threads running simultaneous event loops (Unix only).</p>
</div><h4 id='method.serve' class="method"><span id='serve.v' class='invisible'><code>pub fn <a href='#method.serve' class='fnname'>serve</a>&lt;S&gt;(&amp;self, new_service: S) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="../tokio_service/trait.NewService.html" title="trait tokio_service::NewService">NewService</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>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Instance" title="type tokio_service::NewService::Instance">Instance</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceError" title="type tokio_proto::BindServer::ServiceError">ServiceError</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceResponse" title="type tokio_proto::BindServer::ServiceResponse">ServiceResponse</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceRequest" title="type tokio_proto::BindServer::ServiceRequest">ServiceRequest</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Request" title="type tokio_service::NewService::Request">Request</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceRequest" title="type tokio_proto::BindServer::ServiceRequest">ServiceRequest</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Response" title="type tokio_service::NewService::Response">Response</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceResponse" title="type tokio_proto::BindServer::ServiceResponse">ServiceResponse</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Error" title="type tokio_service::NewService::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceError" title="type tokio_proto::BindServer::ServiceError">ServiceError</a>&gt;,&nbsp;</span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/tokio_proto/tcp_server.rs.html#84-96' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Start up the server, providing the given service on it.</p>
<p>This method will block the current thread until the server is shut down.</p>
</div><h4 id='method.with_handle' class="method"><span id='with_handle.v' class='invisible'><code>pub fn <a href='#method.with_handle' class='fnname'>with_handle</a>&lt;F, S&gt;(&amp;self, new_service: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(&amp;<a class="struct" href="../tokio_core/reactor/struct.Handle.html" title="struct tokio_core::reactor::Handle">Handle</a>) -&gt; S + <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>&nbsp;&nbsp;&nbsp;&nbsp;S: <a class="trait" href="../tokio_service/trait.NewService.html" title="trait tokio_service::NewService">NewService</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>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Instance" title="type tokio_service::NewService::Instance">Instance</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceError" title="type tokio_proto::BindServer::ServiceError">ServiceError</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceResponse" title="type tokio_proto::BindServer::ServiceResponse">ServiceResponse</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceRequest" title="type tokio_proto::BindServer::ServiceRequest">ServiceRequest</a>: 'static,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Request" title="type tokio_service::NewService::Request">Request</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceRequest" title="type tokio_proto::BindServer::ServiceRequest">ServiceRequest</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Response" title="type tokio_service::NewService::Response">Response</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceResponse" title="type tokio_proto::BindServer::ServiceResponse">ServiceResponse</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;S::<a class="type" href="../tokio_service/trait.NewService.html#associatedtype.Error" title="type tokio_service::NewService::Error">Error</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;P::<a class="type" href="../tokio_proto/trait.BindServer.html#associatedtype.ServiceError" title="type tokio_proto::BindServer::ServiceError">ServiceError</a>&gt;,&nbsp;</span></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/tokio_proto/tcp_server.rs.html#106-136' title='goto source code'>[src]</a></span></h4>
<div class='docblock'><p>Start up the server, providing the given service on it, and providing
access to the event loop handle.</p>
<p>The <code>new_service</code> argument is a closure that is given an event loop
handle, and produces a value implementing <code>NewService</code>. That value is in
turn used to make a new service instance for each incoming connection.</p>
<p>This method will block the current thread until the server is shut down.</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&lt;Kind:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>, P:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>&gt; <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="../tokio_proto/struct.TcpServer.html" title="struct tokio_proto::TcpServer">TcpServer</a>&lt;Kind, P&gt;</code><a href='#impl-Debug' class='anchor'></a></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/tokio_proto/tcp_server.rs.html#35' 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>(&amp;self, __arg_0: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>) -&gt; <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/tokio_proto/tcp_server.rs.html#35' 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>&#9166;</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 = "tokio_proto";
</script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>