mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +01:00
306 lines
73 KiB
HTML
306 lines
73 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="A file with an associated name."><title>NamedFile in actix_files - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="actix_files" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0-nightly (bdbbb6c6a 2024-05-26)" data-channel="nightly" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="icon" href="https://actix.rs/favicon.ico"></head><body class="rustdoc struct"><!--[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" title="show sidebar"></button><a class="logo-container" href="../actix_files/index.html"><img src="https://actix.rs/img/logo.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../actix_files/index.html"><img src="https://actix.rs/img/logo.png" alt="logo"></a><h2><a href="../actix_files/index.html">actix_files</a><span class="version">0.6.5</span></h2></div><h2 class="location"><a href="#">NamedFile</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.content_disposition">content_disposition</a></li><li><a href="#method.content_encoding">content_encoding</a></li><li><a href="#method.content_type">content_type</a></li><li><a href="#method.disable_content_disposition">disable_content_disposition</a></li><li><a href="#method.file">file</a></li><li><a href="#method.from_file">from_file</a></li><li><a href="#method.into_response">into_response</a></li><li><a href="#method.metadata">metadata</a></li><li><a href="#method.modified">modified</a></li><li><a href="#method.open_async">open_async</a></li><li><a href="#method.path">path</a></li><li><a href="#method.prefer_utf8">prefer_utf8</a></li><li><a href="#method.set_content_disposition">set_content_disposition</a></li><li><a href="#method.set_content_encoding">set_content_encoding</a></li><li><a href="#method.set_content_type">set_content_type</a></li><li><a href="#method.set_status_code">set_status_code</a></li><li><a href="#method.use_etag">use_etag</a></li><li><a href="#method.use_last_modified">use_last_modified</a></li></ul><h3><a href="#deref-methods-File">Methods from Deref<Target=File></a></h3><ul class="block deref-methods"><li><a href="#method.read_at">read_at</a></li><li><a href="#method.readv_at">readv_at</a></li><li><a href="#method.sync_all">sync_all</a></li><li><a href="#method.sync_data">sync_data</a></li><li><a href="#method.write_at">write_at</a></li><li><a href="#method.writev_at">writev_at</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Debug-for-NamedFile">Debug</a></li><li><a href="#impl-Deref-for-NamedFile">Deref</a></li><li><a href="#impl-DerefMut-for-NamedFile">DerefMut</a></li><
|
|||
|
<p><code>NamedFile</code> can be registered as services:</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::App;
|
|||
|
<span class="kw">use </span>actix_files::NamedFile;
|
|||
|
|
|||
|
<span class="kw">let </span>file = NamedFile::open_async(<span class="string">"./static/index.html"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>app = App::new().service(file);</code></pre></div>
|
|||
|
<p>They can also be returned from handlers:</p>
|
|||
|
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_web::{Responder, get};
|
|||
|
<span class="kw">use </span>actix_files::NamedFile;
|
|||
|
|
|||
|
<span class="attr">#[get(<span class="string">"/"</span>)]
|
|||
|
</span><span class="kw">async fn </span>index() -> <span class="kw">impl </span>Responder {
|
|||
|
NamedFile::open_async(<span class="string">"./static/index.html"</span>).<span class="kw">await
|
|||
|
</span>}</code></pre></div>
|
|||
|
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-NamedFile" class="impl"><a class="src rightside" href="../src/actix_files/named.rs.html#93-588">source</a><a href="#impl-NamedFile" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from_file" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#114-204">source</a><h4 class="code-header">pub fn <a href="#method.from_file" class="fn">from_file</a><P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(file: File, path: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a>></h4></section></summary><div class="docblock"><p>Creates an instance from a previously opened file.</p>
|
|||
|
<p>The given <code>path</code> need not exist and is only used to determine the <code>ContentType</code> and
|
|||
|
<code>ContentDisposition</code> headers.</p>
|
|||
|
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
|||
|
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::{
|
|||
|
io::{<span class="self">self</span>, Write <span class="kw">as _</span>},
|
|||
|
env,
|
|||
|
fs::File
|
|||
|
};
|
|||
|
<span class="kw">use </span>actix_files::NamedFile;
|
|||
|
|
|||
|
<span class="kw">let </span><span class="kw-2">mut </span>file = File::create(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>;
|
|||
|
file.write_all(<span class="string">b"Hello, world!"</span>)<span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>named_file = NamedFile::from_file(file, <span class="string">"bar.txt"</span>)<span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.open_async" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#231-245">source</a><h4 class="code-header">pub async fn <a href="#method.open_async" class="fn">open_async</a><P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(path: P) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a>></h4></section></summary><div class="docblock"><p>Attempts to open a file asynchronously in read-only mode.</p>
|
|||
|
<p>When the <code>experimental-io-uring</code> crate feature is enabled, this will be async. Otherwise, it
|
|||
|
will behave just like <code>open</code>.</p>
|
|||
|
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_files::NamedFile;
|
|||
|
<span class="kw">let </span>file = NamedFile::open_async(<span class="string">"foo.txt"</span>).<span class="kw">await</span>.unwrap();</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.file" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#249-251">source</a><h4 class="code-header">pub fn <a href="#method.file" class="fn">file</a>(&self) -> &File</h4></section></summary><div class="docblock"><p>Returns reference to the underlying file object.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.path" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#267-269">source</a><h4 class="code-header">pub fn <a href="#method.path" class="fn">path</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a></h4></section></summary><div class="docblock"><p>Returns the filesystem path to this file.</p>
|
|||
|
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>actix_files::NamedFile;
|
|||
|
|
|||
|
<span class="kw">let </span>file = NamedFile::open_async(<span class="string">"test.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="macro">assert_eq!</span>(file.path().as_os_str(), <span class="string">"foo.txt"</span>);</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.modified" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#276-278">source</a><h4 class="code-header">pub fn <a href="#method.modified" class="fn">modified</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/time/struct.SystemTime.html" title="struct std::time::SystemTime">SystemTime</a>></h4></section></summary><div class="docblock"><p>Returns the time the file was last modified.</p>
|
|||
|
<p>Returns <code>None</code> only on unsupported platforms; see <a href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html#method.modified" title="method std::fs::Metadata::modified"><code>std::fs::Metadata::modified()</code></a>.
|
|||
|
Therefore, it is usually safe to unwrap this.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.metadata" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#282-284">source</a><h4 class="code-header">pub fn <a href="#method.metadata" class="fn">metadata</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html" title="struct std::fs::Metadata">Metadata</a></h4></section></summary><div class="docblock"><p>Returns the filesystem metadata associated with this file.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.content_type" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#288-290">source</a><h4 class="code-header">pub fn <a href="#method.content_type" class="fn">content_type</a>(&self) -> &<a class="struct" href="https://docs.rs/mime/0.3.17/mime/struct.Mime.html" title="struct mime::Mime">Mime</a></h4></section></summary><div class="docblock"><p>Returns the <code>Content-Type</code> header that will be used when serving this file.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.content_disposition" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#294-296">source</a><h4 class="code-header">pub fn <a href="#method.content_disposition" class="fn">content_disposition</a>(&self) -> &ContentDisposition</h4></section></summary><div class="docblock"><p>Returns the <code>Content-Disposition</code> that will be used when serving this file.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.content_encoding" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#303-305">source</a><h4 class="code-header">pub fn <a href="#method.content_encoding" class="fn">content_encoding</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><ContentEncoding></h4></section></summary><div class="docblock"><p>Returns the <code>Content-Encoding</code> that will be used when serving this file.</p>
|
|||
|
<p>A return value of <code>None</code> indicates that the content is not already using a compressed
|
|||
|
representation and may be subject to compression downstream.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_status_code" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#309-312">source</a><h4 class="code-header">pub fn <a href="#method.set_status_code" class="fn">set_status_code</a>(self, status: <a class="struct" href="https://docs.rs/http/0.2.11/http/status/struct.StatusCode.html" title="struct http::status::StatusCode">StatusCode</a>) -> Self</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 0.7.0: Prefer <code>Responder::customize()</code>.</span></div></span></summary><div class="docblock"><p>Set response status code.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_content_type" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#317-320">source</a><h4 class="code-header">pub fn <a href="#method.set_content_type" class="fn">set_content_type</a>(self, mime_type: <a class="struct" href="https://docs.rs/mime/0.3.17/mime/struct.Mime.html" title="struct mime::Mime">Mime</a>) -> Self</h4></section></summary><div class="docblock"><p>Sets the <code>Content-Type</code> header that will be used when serving this file. By default the
|
|||
|
<code>Content-Type</code> is inferred from the filename extension.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_content_disposition" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#330-334">source</a><h4 class="code-header">pub fn <a href="#method.set_content_disposition" class="fn">set_content_disposition</a>(self, cd: ContentDisposition) -> Self</h4></section></summary><div class="docblock"><p>Set the Content-Disposition for serving this file. This allows changing the
|
|||
|
<code>inline/attachment</code> disposition as well as the filename sent to the peer.</p>
|
|||
|
<p>By default the disposition is <code>inline</code> for <code>text/*</code>, <code>image/*</code>, <code>video/*</code> and
|
|||
|
<code>application/{javascript, json, wasm}</code> mime types, and <code>attachment</code> otherwise, and the
|
|||
|
filename is taken from the path provided in the <code>open</code> method after converting it to UTF-8
|
|||
|
(using <code>to_string_lossy</code>).</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.disable_content_disposition" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#340-343">source</a><h4 class="code-header">pub fn <a href="#method.disable_content_disposition" class="fn">disable_content_disposition</a>(self) -> Self</h4></section></summary><div class="docblock"><p>Disables <code>Content-Disposition</code> header.</p>
|
|||
|
<p>By default, the <code>Content-Disposition</code> header is sent.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_content_encoding" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#351-354">source</a><h4 class="code-header">pub fn <a href="#method.set_content_encoding" class="fn">set_content_encoding</a>(self, enc: ContentEncoding) -> Self</h4></section></summary><div class="docblock"><p>Sets content encoding for this file.</p>
|
|||
|
<p>This prevents the <code>Compress</code> middleware from modifying the file contents and signals to
|
|||
|
browsers/clients how to decode it. For example, if serving a compressed HTML file (e.g.,
|
|||
|
<code>index.html.gz</code>) then use <code>.set_content_encoding(ContentEncoding::Gzip)</code>.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.use_etag" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#360-363">source</a><h4 class="code-header">pub fn <a href="#method.use_etag" class="fn">use_etag</a>(self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> Self</h4></section></summary><div class="docblock"><p>Specifies whether to return <code>ETag</code> header in response.</p>
|
|||
|
<p>Default is true.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.use_last_modified" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#369-372">source</a><h4 class="code-header">pub fn <a href="#method.use_last_modified" class="fn">use_last_modified</a>(self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> Self</h4></section></summary><div class="docblock"><p>Specifies whether to return <code>Last-Modified</code> header in response.</p>
|
|||
|
<p>Default is true.</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.prefer_utf8" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#378-381">source</a><h4 class="code-header">pub fn <a href="#method.prefer_utf8" class="fn">prefer_utf8</a>(self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> Self</h4></section></summary><div class="docblock"><p>Specifies whether text responses should signal a UTF-8 encoding.</p>
|
|||
|
<p>Default is false (but will default to true in a future version).</p>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_response" class="method"><a class="src rightside" href="../src/actix_files/named.rs.html#420-587">source</a><h4 class="code-header">pub fn <a href="#method.into_response" class="fn">into_response</a>(self, req: &HttpRequest) -> HttpResponse<BoxBody></h4></section></summary><div class="docblock"><p>Creates an <code>HttpResponse</code> with file as a streaming body.</p>
|
|||
|
</div></details></div></details></div><h2 id="deref-methods-File" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = File></span><a href="#deref-methods-File" class="anchor">§</a></h2><div id="deref-methods-File-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.read_at" class="method"><h4 class="code-header">pub async fn <a href="#method.read_at" class="fn">read_at</a><T>(&self, buf: T, pos: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>, T)<div class="where">where
|
|||
|
T: IoBufMut,</div></h4></section></summary><div class="docblock"><p>Read some bytes at the specified offset from the file into the specified
|
|||
|
buffer, returning how many bytes were read.</p>
|
|||
|
<h5 id="return"><a class="doc-anchor" href="#return">§</a>Return</h5>
|
|||
|
<p>The method returns the operation result and the same buffer value passed
|
|||
|
as an argument.</p>
|
|||
|
<p>If the method returns [<code>Ok(n)</code>], then the read was successful. A nonzero
|
|||
|
<code>n</code> value indicates that the buffer has been filled with <code>n</code> bytes of
|
|||
|
data from the file. If <code>n</code> is <code>0</code>, then one of the following happened:</p>
|
|||
|
<ol>
|
|||
|
<li>The specified offset is the end of the file.</li>
|
|||
|
<li>The buffer specified was 0 bytes in length.</li>
|
|||
|
</ol>
|
|||
|
<p>It is not an error if the returned value <code>n</code> is smaller than the buffer
|
|||
|
size, even when the file contains enough data to fill the buffer.</p>
|
|||
|
<h5 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h5>
|
|||
|
<p>If this function encounters any form of I/O or other error, an error
|
|||
|
variant will be returned. The buffer is returned on error.</p>
|
|||
|
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_uring::fs::File;
|
|||
|
|
|||
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
|||
|
tokio_uring::start(<span class="kw">async </span>{
|
|||
|
<span class="kw">let </span>f = File::open(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>buffer = <span class="macro">vec!</span>[<span class="number">0</span>; <span class="number">10</span>];
|
|||
|
|
|||
|
<span class="comment">// Read up to 10 bytes
|
|||
|
</span><span class="kw">let </span>(res, buffer) = f.read_at(buffer, <span class="number">0</span>).<span class="kw">await</span>;
|
|||
|
<span class="kw">let </span>n = res<span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"The bytes: {:?}"</span>, <span class="kw-2">&</span>buffer[..n]);
|
|||
|
|
|||
|
<span class="comment">// Close the file
|
|||
|
</span>f.close().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
})
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.readv_at" class="method"><h4 class="code-header">pub async fn <a href="#method.readv_at" class="fn">readv_at</a><T>(
|
|||
|
&self,
|
|||
|
bufs: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>,
|
|||
|
pos: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>
|
|||
|
) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)<div class="where">where
|
|||
|
T: IoBufMut,</div></h4></section></summary><div class="docblock"><p>Read some bytes at the specified offset from the file into the specified
|
|||
|
array of buffers, returning how many bytes were read.</p>
|
|||
|
<h5 id="return-1"><a class="doc-anchor" href="#return-1">§</a>Return</h5>
|
|||
|
<p>The method returns the operation result and the same array of buffers
|
|||
|
passed as an argument.</p>
|
|||
|
<p>If the method returns [<code>Ok(n)</code>], then the read was successful. A nonzero
|
|||
|
<code>n</code> value indicates that the buffers have been filled with <code>n</code> bytes of
|
|||
|
data from the file. If <code>n</code> is <code>0</code>, then one of the following happened:</p>
|
|||
|
<ol>
|
|||
|
<li>The specified offset is the end of the file.</li>
|
|||
|
<li>The buffers specified were 0 bytes in length.</li>
|
|||
|
</ol>
|
|||
|
<p>It is not an error if the returned value <code>n</code> is smaller than the buffer
|
|||
|
size, even when the file contains enough data to fill the buffer.</p>
|
|||
|
<h5 id="errors-1"><a class="doc-anchor" href="#errors-1">§</a>Errors</h5>
|
|||
|
<p>If this function encounters any form of I/O or other error, an error
|
|||
|
variant will be returned. The buffer is returned on error.</p>
|
|||
|
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_uring::fs::File;
|
|||
|
|
|||
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
|||
|
tokio_uring::start(<span class="kw">async </span>{
|
|||
|
<span class="kw">let </span>f = File::open(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>buffers = <span class="macro">vec!</span>[Vec::<u8>::with_capacity(<span class="number">10</span>), Vec::<u8>::with_capacity(<span class="number">10</span>)];
|
|||
|
|
|||
|
<span class="comment">// Read up to 20 bytes
|
|||
|
</span><span class="kw">let </span>(res, buffer) = f.readv_at(buffers, <span class="number">0</span>).<span class="kw">await</span>;
|
|||
|
<span class="kw">let </span>n = res<span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"Read {} bytes"</span>, n);
|
|||
|
|
|||
|
<span class="comment">// Close the file
|
|||
|
</span>f.close().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
})
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.writev_at" class="method"><h4 class="code-header">pub async fn <a href="#method.writev_at" class="fn">writev_at</a><T>(
|
|||
|
&self,
|
|||
|
buf: <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>,
|
|||
|
pos: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>
|
|||
|
) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T>)<div class="where">where
|
|||
|
T: IoBuf,</div></h4></section></summary><div class="docblock"><p>Write data from buffers into this file at the specified offset,
|
|||
|
returning how many bytes were written.</p>
|
|||
|
<p>This function will attempt to write the entire contents of <code>bufs</code>, but
|
|||
|
the entire write may not succeed, or the write may also generate an
|
|||
|
error. The bytes will be written starting at the specified offset.</p>
|
|||
|
<h5 id="return-2"><a class="doc-anchor" href="#return-2">§</a>Return</h5>
|
|||
|
<p>The method returns the operation result and the same array of buffers passed
|
|||
|
in as an argument. A return value of <code>0</code> typically means that the
|
|||
|
underlying file is no longer able to accept bytes and will likely not be
|
|||
|
able to in the future as well, or that the buffer provided is empty.</p>
|
|||
|
<h5 id="errors-2"><a class="doc-anchor" href="#errors-2">§</a>Errors</h5>
|
|||
|
<p>Each call to <code>write</code> may generate an I/O error indicating that the
|
|||
|
operation could not be completed. If an error is returned then no bytes
|
|||
|
in the buffer were written to this writer.</p>
|
|||
|
<p>It is <strong>not</strong> considered an error if the entire buffer could not be
|
|||
|
written to this writer.</p>
|
|||
|
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_uring::fs::File;
|
|||
|
|
|||
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
|||
|
tokio_uring::start(<span class="kw">async </span>{
|
|||
|
<span class="kw">let </span>file = File::create(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Writes some prefix of the byte string, not necessarily all of it.
|
|||
|
</span><span class="kw">let </span>bufs = <span class="macro">vec!</span>[<span class="string">"some"</span>.to_owned().into_bytes(), <span class="string">" bytes"</span>.to_owned().into_bytes()];
|
|||
|
<span class="kw">let </span>(res, <span class="kw">_</span>) = file.writev_at(bufs, <span class="number">0</span>).<span class="kw">await</span>;
|
|||
|
<span class="kw">let </span>n = res<span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"wrote {} bytes"</span>, n);
|
|||
|
|
|||
|
<span class="comment">// Close the file
|
|||
|
</span>file.close().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
})
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_at" class="method"><h4 class="code-header">pub async fn <a href="#method.write_at" class="fn">write_at</a><T>(&self, buf: T, pos: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> (<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>>, T)<div class="where">where
|
|||
|
T: IoBuf,</div></h4></section></summary><div class="docblock"><p>Write a buffer into this file at the specified offset, returning how
|
|||
|
many bytes were written.</p>
|
|||
|
<p>This function will attempt to write the entire contents of <code>buf</code>, but
|
|||
|
the entire write may not succeed, or the write may also generate an
|
|||
|
error. The bytes will be written starting at the specified offset.</p>
|
|||
|
<h5 id="return-3"><a class="doc-anchor" href="#return-3">§</a>Return</h5>
|
|||
|
<p>The method returns the operation result and the same buffer value passed
|
|||
|
in as an argument. A return value of <code>0</code> typically means that the
|
|||
|
underlying file is no longer able to accept bytes and will likely not be
|
|||
|
able to in the future as well, or that the buffer provided is empty.</p>
|
|||
|
<h5 id="errors-3"><a class="doc-anchor" href="#errors-3">§</a>Errors</h5>
|
|||
|
<p>Each call to <code>write</code> may generate an I/O error indicating that the
|
|||
|
operation could not be completed. If an error is returned then no bytes
|
|||
|
in the buffer were written to this writer.</p>
|
|||
|
<p>It is <strong>not</strong> considered an error if the entire buffer could not be
|
|||
|
written to this writer.</p>
|
|||
|
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_uring::fs::File;
|
|||
|
|
|||
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
|||
|
tokio_uring::start(<span class="kw">async </span>{
|
|||
|
<span class="kw">let </span>file = File::create(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Writes some prefix of the byte string, not necessarily all of it.
|
|||
|
</span><span class="kw">let </span>(res, <span class="kw">_</span>) = file.write_at(<span class="kw-2">&</span><span class="string">b"some bytes"</span>[..], <span class="number">0</span>).<span class="kw">await</span>;
|
|||
|
<span class="kw">let </span>n = res<span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="macro">println!</span>(<span class="string">"wrote {} bytes"</span>, n);
|
|||
|
|
|||
|
<span class="comment">// Close the file
|
|||
|
</span>file.close().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
})
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.sync_all" class="method"><h4 class="code-header">pub async fn <a href="#method.sync_all" class="fn">sync_all</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Attempts to sync all OS-internal metadata to disk.</p>
|
|||
|
<p>This function will attempt to ensure that all in-memory data reaches the
|
|||
|
filesystem before completing.</p>
|
|||
|
<p>This can be used to handle errors that would otherwise only be caught
|
|||
|
when the <code>File</code> is closed. Dropping a file will ignore errors in
|
|||
|
synchronizing this in-memory data.</p>
|
|||
|
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_uring::fs::File;
|
|||
|
|
|||
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
|||
|
tokio_uring::start(<span class="kw">async </span>{
|
|||
|
<span class="kw">let </span>f = File::create(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>(res, buf) = f.write_at(<span class="kw-2">&</span><span class="string">b"Hello, world!"</span>[..], <span class="number">0</span>).<span class="kw">await</span>;
|
|||
|
<span class="kw">let </span>n = res<span class="question-mark">?</span>;
|
|||
|
|
|||
|
f.sync_all().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Close the file
|
|||
|
</span>f.close().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
})
|
|||
|
}</code></pre></div>
|
|||
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.sync_data" class="method"><h4 class="code-header">pub async fn <a href="#method.sync_data" class="fn">sync_data</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Attempts to sync file data to disk.</p>
|
|||
|
<p>This method is similar to <a href="File::sync_all"><code>sync_all</code></a>, except that it may not
|
|||
|
synchronize file metadata to the filesystem.</p>
|
|||
|
<p>This is intended for use cases that must synchronize content, but don’t
|
|||
|
need the metadata on disk. The goal of this method is to reduce disk
|
|||
|
operations.</p>
|
|||
|
<p>Note that some platforms may simply implement this in terms of
|
|||
|
<a href="File::sync_all"><code>sync_all</code></a>.</p>
|
|||
|
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
|||
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>tokio_uring::fs::File;
|
|||
|
|
|||
|
<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>std::error::Error>> {
|
|||
|
tokio_uring::start(<span class="kw">async </span>{
|
|||
|
<span class="kw">let </span>f = File::create(<span class="string">"foo.txt"</span>).<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="kw">let </span>(res, buf) = f.write_at(<span class="kw-2">&</span><span class="string">b"Hello, world!"</span>[..], <span class="number">0</span>).<span class="kw">await</span>;
|
|||
|
<span class="kw">let </span>n = res<span class="question-mark">?</span>;
|
|||
|
|
|||
|
f.sync_data().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
|
|||
|
<span class="comment">// Close the file
|
|||
|
</span>f.close().<span class="kw">await</span><span class="question-mark">?</span>;
|
|||
|
<span class="prelude-val">Ok</span>(())
|
|||
|
})
|
|||
|
}</code></pre></div>
|
|||
|
</div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-NamedFile" class="impl"><a class="src rightside" href="../src/actix_files/named.rs.html#70">source</a><a href="#impl-Debug-for-NamedFile" class="anchor">§</a><h3 class="code-header">impl <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="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/actix_files/named.rs.html#70">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">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></h4></section></summary><div class='docblock'>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></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deref-for-NamedFile" class="impl"><a class="src rightside" href="../src/actix_files/named.rs.html#70">source</a><a href="#impl-Deref-for-NamedFile" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Target" class="associatedtype trait-impl"><a href="#associatedtype.Target" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" class="associatedtype">Target</a> = File</h4></section></summary><div class='docblock'>The resulting type after dereferencing.</div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../src/actix_files/named.rs.html#70">source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref" class="fn">deref</a>(&self) -> &Self::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a></h4></section></summary><div class='docblock'>Dereferences the value.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-DerefMut-for-NamedFile" class="impl"><a class="src rightside" href="../src/actix_files/named.rs.html#70">source</a><a href="#impl-DerefMut-for-NamedFile" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.DerefMut.html" title="trait core::ops::deref::DerefMut">DerefMut</a> for <a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.deref_mut" class="method trait-impl"><a class="src rightside" href="../src/actix_files/named.rs.html#70">source</a><a href="#method.deref_mut" class="anchor">
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Wraps responder to allow alteration of its response. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-ServiceFactory%3CServiceRequest%3E-for-NamedFile" class="impl"><a class="src rightside" href="../src/actix_files/named.rs.html#638-653">source</a><a href="#impl-ServiceFactory%3CServiceRequest%3E-for-NamedFile" class="anchor">§</a><h3 class="code-header">impl ServiceFactory<ServiceRequest> for <a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Response" class="associatedtype trait-impl"><a href="#associatedtype.Response" class="anchor">§</a><h4 class="code-header">type <a class="associatedtype">Response</a> = ServiceResponse</h4></section></summary><div class='docblock'>Responses given by the created services.</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a class="associatedtype">Error</a> = Error</h4></section></summary><div class='docblock'>Errors produced by the created services.</div></details><details class="toggle" open><summary><section id="associatedtype.Config" class="associatedtype trait-impl"><a href="#associatedtype.Config" class="anchor">§</a><h4 class="code-header">type <a class="associatedtype">Config</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a></h4></section></summary><div class='docblock'>Service factory configuration.</div></details><details class="toggle" open><summary><section id="associatedtype.Service" class="associatedtype trait-impl"><a href="#associatedtype.Service" class="anchor">§</a><h4 class="code-header">type <a class="associatedtype">Service</a> = NamedFileService</h4></section></summary><div class='docblock'>The kind of <code>Service</code> created by this factory.</div></details><details class="toggle" open><summary><section id="associatedtype.InitError" class="associatedtype trait-impl"><a href="#associatedtype.InitError" class="anchor">§</a><h4 class="code-header">type <a class="associatedtype">InitError</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a></h4></section></summary><div class='docblock'>Errors potentially raised while building a service.</div></details><details class="toggle" open><summary><section id="associatedtype.Future" class="associatedtype trait-impl"><a href="#associatedtype.Future" class="anchor">§</a><h4 class="code-header">type <a class="associatedtype">Future</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/core/pin/struct.Pin.html" title="struct core::pin::Pin">Pin</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><dyn <a class="trait" href="https://doc.rust-lang.org/nightly/core/future/future/trait.Future.html" title="trait core::future::future::Future">Future</a><Output = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<<a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a> as ServiceFactory<ServiceRequest>>::Service, <<a class="struct" href="struct.NamedFile.html" title="struct actix_files::NamedFile">NamedFile</a> as ServiceFactory<ServiceRequest>>::InitError>>>></h4></section></summary><div class='docblock'>The future of the <code>Service</code> instance.g</div></details><details class="toggle method-toggle" open><summary><section id="method.new_service" class="method trait-impl"><a class="src right
|
|||
|
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
|||
|
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#768">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Instrument-for-T" class="impl"><a href="#impl-Instrument-for-T" class="anchor">§</a><h3 class="code-header">impl<T> Instrument for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.instrument" class="method trait-impl"><a href="#method.instrument" class="anchor">§</a><h4 class="code-header">fn <a class="fn">instrument</a>(self, span: Span) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the provided [<code>Span</code>], returning an
|
|||
|
<code>Instrumented</code> wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.in_current_span" class="method trait-impl"><a href="#method.in_current_span" class="anchor">§</a><h4 class="code-header">fn <a class="fn">in_current_span</a>(self) -> Instrumented<Self></h4></section></summary><div class='docblock'>Instruments this type with the <a href="super::Span::current()">current</a> <a href="crate::Span"><code>Span</code></a>, returning an
|
|||
|
<code>Instrumented</code> wrapper. <a>Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
|||
|
<p>That is, this conversion is whatever the implementation of
|
|||
|
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
|||
|
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-IntoServiceFactory%3CSF,+Req%3E-for-SF" class="impl"><a href="#impl-IntoServiceFactory%3CSF,+Req%3E-for-SF" class="anchor">§</a><h3 class="code-header">impl<SF, Req> IntoServiceFactory<SF, Req> for SF<div class="where">where
|
|||
|
SF: ServiceFactory<Req>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into_factory" class="method trait-impl"><a href="#method.into_factory" class="anchor">§</a><h4 class="code-header">fn <a class="fn">into_factory</a>(self) -> SF</h4></section></summary><div class='docblock'>Convert <code>Self</code> to a <code>ServiceFactory</code></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Same-for-T" class="impl"><a class="src rightside" href="https://docs.rs/typenum/1.17.0/src/typenum/type_operators.rs.html#34">source</a><a href="#impl-Same-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html" title="trait typenum::type_operators::Same">Same</a> for T</h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://docs.rs/typenum/1.17.0/typenum/type_operators/trait.Same.html#associatedtype.Output" class="associatedtype">Output</a> = T</h4></section></summary><div class='docblock'>Should always be <code>Self</code></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ServiceFactoryExt%3CReq%3E-for-SF" class="impl"><a href="#impl-ServiceFactoryExt%3CReq%3E-for-SF" class="anchor">§</a><h3 class="code-header">impl<SF, Req> ServiceFactoryExt<Req> for SF<div class="where">where
|
|||
|
SF: ServiceFactory<Req>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.map" class="method trait-impl"><a href="#method.map" class="anchor">§</a><h4 class="code-header">fn <a class="fn">map</a><F, R>(self, f: F) -> MapServiceFactory<Self, F, Req, R><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::Response) -> R + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class='docblock'>Map this service’s output to a different type, returning a new service
|
|||
|
of the resulting type.</div></details><details class="toggle method-toggle" open><summary><section id="method.map_err" class="method trait-impl"><a href="#method.map_err" class="anchor">§</a><h4 class="code-header">fn <a class="fn">map_err</a><F, E>(self, f: F) -> MapErrServiceFactory<Self, Req, F, E><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
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>(Self::Error) -> E + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class='docblock'>Map this service’s error to a different error, returning a new service.</div></details><details class="toggle method-toggle" open><summary><section id="method.map_init_err" class="method trait-impl"><a href="#method.map_init_err" class="anchor">§</a><h4 class="code-header">fn <a class="fn">map_init_err</a><F, E>(self, f: F) -> MapInitErr<Self, F, Req, E><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
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>(Self::InitError) -> E + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h4></section></summary><div class='docblock'>Map this factory’s init error to a different error, returning a new service.</div></details><details class="toggle method-toggle" open><summary><section id="method.and_then" class="method trait-impl"><a href="#method.and_then" class="anchor">§</a><h4 class="code-header">fn <a class="fn">and_then</a><I, SF1>(self, factory: I) -> AndThenServiceFactory<Self, SF1, Req><div class="where">where
|
|||
|
Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,
|
|||
|
Self::Config: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,
|
|||
|
I: IntoServiceFactory<SF1, Self::Response>,
|
|||
|
SF1: ServiceFactory<Self::Response, Config = Self::Config, Error = Self::Error, InitError = Self::InitError>,</div></h4></section></summary><div class='docblock'>Call another service after call to this one has resolved successfully.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-2" class="associatedtype trait-impl"><a href="#associatedtype.Error-2" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
|||
|
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-VZip%3CV%3E-for-T" class="impl"><a href="#impl-VZip%3CV%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<V, T> VZip<V> for T<div class="where">where
|
|||
|
V: MultiLane<T>,</div></h3></section></summary><div class="impl-items"><section id="method.vzip" class="method trait-impl"><a href="#method.vzip" class="anchor">§</a><h4 class="code-header">fn <a class="fn">vzip</a>(self) -> V</h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-WithSubscriber-for-T" class="impl"><a href="#impl-WithSubscriber-for-T" class="anchor">§</a><h3 class="code-header">impl<T> WithSubscriber for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.with_subscriber" class="method trait-impl"><a href="#method.with_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_subscriber</a><S>(self, subscriber: S) -> WithDispatch<Self><div class="where">where
|
|||
|
S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><Dispatch>,</div></h4></section></summary><div class='docblock'>Attaches the provided <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
|||
|
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.with_current_subscriber" class="method trait-impl"><a href="#method.with_current_subscriber" class="anchor">§</a><h4 class="code-header">fn <a class="fn">with_current_subscriber</a>(self) -> WithDispatch<Self></h4></section></summary><div class='docblock'>Attaches the current <a href="crate::dispatcher#setting-the-default-subscriber">default</a> <a href="super::Subscriber"><code>Subscriber</code></a> to this type, returning a
|
|||
|
[<code>WithDispatch</code>] wrapper. <a>Read more</a></div></details></div></details></div></section></div></main></body></html>
|