<!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 `File` struct in crate `std`."> <meta name="keywords" content="rust, rustlang, rust-lang, File"> <title>std::fs::File - Rust</title> <link rel="stylesheet" type="text/css" href="../../normalize.css"> <link rel="stylesheet" type="text/css" href="../../rustdoc.css"> <link rel="stylesheet" type="text/css" href="../../main.css"> <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico"> </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"> <a href='../../std/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a> <p class='location'>Struct File</p><div class="block items"><ul><li><a href="#methods">Methods</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='../index.html'>std</a>::<wbr><a href='index.html'>fs</a></p><script>window.sidebarCurrent = {name: 'File', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script> </nav> <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'>std</a>::<wbr><a href='index.html'>fs</a>::<wbr><a class="struct" href=''>File</a></span><span class='out-of-band'><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><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/std/fs.rs.html#87-89' title='goto source code'>[src]</a></span></h1> <pre class='rust struct'>pub struct File { /* fields omitted */ }</pre><div class='docblock'><p>A reference to an open file on the filesystem.</p> <p>An instance of a <code>File</code> can be read and/or written depending on what options it was opened with. Files also implement <code>Seek</code> to alter the logical cursor that the file contains internally.</p> <p>Files are automatically closed when they go out of scope.</p> <h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1> <p>Create a new file and write bytes to it:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="ident">file</span>.<span class="ident">write_all</span>(<span class="string">b"Hello, world!"</span>)<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0Ause%20std%3A%3Aio%3A%3Aprelude%3A%3A*%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20file%20%3D%20File%3A%3Acreate(%22foo.txt%22)%3F%3B%0Afile.write_all(b%22Hello%2C%20world!%22)%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> <p>Read the contents of a file into a <code>String</code>:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">contents</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">new</span>(); <span class="ident">file</span>.<span class="ident">read_to_string</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">contents</span>)<span class="question-mark">?</span>; <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">contents</span>, <span class="string">"Hello, world!"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0Ause%20std%3A%3Aio%3A%3Aprelude%3A%3A*%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20file%20%3D%20File%3A%3Aopen(%22foo.txt%22)%3F%3B%0Alet%20mut%20contents%20%3D%20String%3A%3Anew()%3B%0Afile.read_to_string(%26mut%20contents)%3F%3B%0Aassert_eq!(contents%2C%20%22Hello%2C%20world!%22)%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> <p>It can be more efficient to read the contents of a file with a buffered <a href="../io/trait.Read.html"><code>Read</code></a>er. This can be accomplished with <a href="../io/struct.BufReader.html"><code>BufReader<R></code></a>:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">BufReader</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>; <span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf_reader</span> <span class="op">=</span> <span class="ident">BufReader</span>::<span class="ident">new</span>(<span class="ident">file</span>); <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">contents</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">new</span>(); <span class="ident">buf_reader</span>.<span class="ident">read_to_string</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">contents</span>)<span class="question-mark">?</span>; <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">contents</span>, <span class="string">"Hello, world!"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0Ause%20std%3A%3Aio%3A%3ABufReader%3B%0Ause%20std%3A%3Aio%3A%3Aprelude%3A%3A*%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20file%20%3D%20File%3A%3Aopen(%22foo.txt%22)%3F%3B%0Alet%20mut%20buf_reader%20%3D%20BufReader%3A%3Anew(file)%3B%0Alet%20mut%20contents%20%3D%20String%3A%3Anew()%3B%0Abuf_reader.read_to_string(%26mut%20contents)%3F%3B%0Aassert_eq!(contents%2C%20%22Hello%2C%20world!%22)%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#212-421' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.open' class="method"><span id='open.v' class='invisible'><code>fn <a href='#method.open' class='fnname'>open</a><P: <a class="trait" href="../../std/convert/trait.AsRef.html" title="trait std::convert::AsRef">AsRef</a><<a class="struct" href="../../std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(path: P) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a>></code></span></h4> <div class='docblock'><p>Attempts to open a file in read-only mode.</p> <p>See the <a href="struct.OpenOptions.html#method.open"><code>OpenOptions::open</code></a> method for more details.</p> <h1 id='errors' class='section-header'><a href='#errors'>Errors</a></h1> <p>This function will return an error if <code>path</code> does not already exist. Other errors may also be returned according to <a href="struct.OpenOptions.html#method.open"><code>OpenOptions::open</code></a>.</p> <h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Aopen(%22foo.txt%22)%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.create' class="method"><span id='create.v' class='invisible'><code>fn <a href='#method.create' class='fnname'>create</a><P: <a class="trait" href="../../std/convert/trait.AsRef.html" title="trait std::convert::AsRef">AsRef</a><<a class="struct" href="../../std/path/struct.Path.html" title="struct std::path::Path">Path</a>>>(path: P) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a>></code></span></h4> <div class='docblock'><p>Opens a file in write-only mode.</p> <p>This function will create a file if it does not exist, and will truncate it if it does.</p> <p>See the <a href="struct.OpenOptions.html#method.open"><code>OpenOptions::open</code></a> function for more details.</p> <h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Acreate(%22foo.txt%22)%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.sync_all' class="method"><span id='sync_all.v' class='invisible'><code>fn <a href='#method.sync_all' class='fnname'>sync_all</a>(&self) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Attempts to sync all OS-internal metadata to disk.</p> <p>This function will attempt to ensure that all in-core data reaches the filesystem before returning.</p> <h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="ident">f</span>.<span class="ident">write_all</span>(<span class="string">b"Hello, world!"</span>)<span class="question-mark">?</span>; <span class="ident">f</span>.<span class="ident">sync_all</span>()<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0Ause%20std%3A%3Aio%3A%3Aprelude%3A%3A*%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Acreate(%22foo.txt%22)%3F%3B%0Af.write_all(b%22Hello%2C%20world!%22)%3F%3B%0A%0Af.sync_all()%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.sync_data' class="method"><span id='sync_data.v' class='invisible'><code>fn <a href='#method.sync_data' class='fnname'>sync_data</a>(&self) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>This function is similar to <a href="struct.File.html#method.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="struct.File.html#method.sync_all"><code>sync_all</code></a>.</p> <h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="ident">f</span>.<span class="ident">write_all</span>(<span class="string">b"Hello, world!"</span>)<span class="question-mark">?</span>; <span class="ident">f</span>.<span class="ident">sync_data</span>()<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0Ause%20std%3A%3Aio%3A%3Aprelude%3A%3A*%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Acreate(%22foo.txt%22)%3F%3B%0Af.write_all(b%22Hello%2C%20world!%22)%3F%3B%0A%0Af.sync_data()%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.set_len' class="method"><span id='set_len.v' class='invisible'><code>fn <a href='#method.set_len' class='fnname'>set_len</a>(&self, size: <a class="primitive" href="../primitive.u64.html">u64</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Truncates or extends the underlying file, updating the size of this file to become <code>size</code>.</p> <p>If the <code>size</code> is less than the current file's size, then the file will be shrunk. If it is greater than the current file's size, then the file will be extended to <code>size</code> and have all of the intermediate data filled in with 0s.</p> <h1 id='errors-1' class='section-header'><a href='#errors-1'>Errors</a></h1> <p>This function will return an error if the file is not opened for writing.</p> <h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">create</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="ident">f</span>.<span class="ident">set_len</span>(<span class="number">10</span>)<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Acreate(%22foo.txt%22)%3F%3B%0Af.set_len(10)%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.metadata' class="method"><span id='metadata.v' class='invisible'><code>fn <a href='#method.metadata' class='fnname'>metadata</a>(&self) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="struct" href="../../std/fs/struct.Metadata.html" title="struct std::fs::Metadata">Metadata</a>></code></span></h4> <div class='docblock'><p>Queries metadata about the underlying file.</p> <h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="kw">let</span> <span class="ident">metadata</span> <span class="op">=</span> <span class="ident">f</span>.<span class="ident">metadata</span>()<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Aopen(%22foo.txt%22)%3F%3B%0Alet%20metadata%20%3D%20f.metadata()%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.try_clone' class="method"><span id='try_clone.v' class='invisible'><code>fn <a href='#method.try_clone' class='fnname'>try_clone</a>(&self) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a>></code><div class='since' title='Stable since Rust version 1.9.0'>1.9.0</div></span></h4> <div class='docblock'><p>Creates a new independently owned handle to the underlying file.</p> <p>The returned <code>File</code> is a reference to the same state that this object references. Both handles will read and write with the same cursor position.</p> <h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">f</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="kw">let</span> <span class="ident">file_copy</span> <span class="op">=</span> <span class="ident">f</span>.<span class="ident">try_clone</span>()<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0A%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Alet%20mut%20f%20%3D%20File%3A%3Aopen(%22foo.txt%22)%3F%3B%0Alet%20file_copy%20%3D%20f.try_clone()%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div><h4 id='method.set_permissions' class="method"><span id='set_permissions.v' class='invisible'><code>fn <a href='#method.set_permissions' class='fnname'>set_permissions</a>(&self, perm: <a class="struct" href="../../std/fs/struct.Permissions.html" title="struct std::fs::Permissions">Permissions</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code><div class='since' title='Stable since Rust version 1.16.0'>1.16.0</div></span></h4> <div class='docblock'><p>Changes the permissions on the underlying file.</p> <h1 id='platform-specific-behavior' class='section-header'><a href='#platform-specific-behavior'>Platform-specific behavior</a></h1> <p>This function currently corresponds to the <code>fchmod</code> function on Unix and the <code>SetFileInformationByHandle</code> function on Windows. Note that, this <a href="../io/index.html#platform-specific-behavior">may change in the future</a>.</p> <h1 id='errors-2' class='section-header'><a href='#errors-2'>Errors</a></h1> <p>This function will return an error if the user lacks permission change attributes on the underlying file. It may also return an error in other os-specific unspecified cases.</p> <h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fs</span>::<span class="ident">File</span>; <span class="kw">let</span> <span class="ident">file</span> <span class="op">=</span> <span class="ident">File</span>::<span class="ident">open</span>(<span class="string">"foo.txt"</span>)<span class="question-mark">?</span>; <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">perms</span> <span class="op">=</span> <span class="ident">file</span>.<span class="ident">metadata</span>()<span class="question-mark">?</span>.<span class="ident">permissions</span>(); <span class="ident">perms</span>.<span class="ident">set_readonly</span>(<span class="bool-val">true</span>); <span class="ident">file</span>.<span class="ident">set_permissions</span>(<span class="ident">perms</span>)<span class="question-mark">?</span>;<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Afn%20foo()%20-%3E%20std%3A%3Aio%3A%3AResult%3C()%3E%20%7B%0Ause%20std%3A%3Afs%3A%3AFile%3B%0A%0Alet%20file%20%3D%20File%3A%3Aopen(%22foo.txt%22)%3F%3B%0Alet%20mut%20perms%20%3D%20file.metadata()%3F.permissions()%3B%0Aperms.set_readonly(true)%3B%0Afile.set_permissions(perms)%3F%3B%0AOk(())%0A%7D%0A%7D">Run</a></pre> </div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#438-442' 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='../../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="../../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -> <a class="type" href="../../std/fmt/type.Result.html" title="type std::fmt::Result">Result</a></code></span></h4> <div class='docblock'><p>Formats the value using the given formatter.</p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#445-452' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.read' class="method"><span id='read.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#tymethod.read' class='fnname'>read</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Pull some bytes from this source into the specified buffer, returning how many bytes were read. <a href="../../std/io/trait.Read.html#tymethod.read">Read more</a></p> </div><h4 id='method.read_to_end' class="method"><span id='read_to_end.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.read_to_end' class='fnname'>read_to_end</a>(&mut self, buf: &mut <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="../../std/io/trait.Read.html#method.read_to_end">Read more</a></p> </div><h4 id='method.read_to_string' class="method"><span id='read_to_string.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.read_to_string' class='fnname'>read_to_string</a>(&mut self, buf: &mut <a class="struct" href="../../std/string/struct.String.html" title="struct std::string::String">String</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="../../std/io/trait.Read.html#method.read_to_string">Read more</a></p> </div><h4 id='method.read_exact' class="method"><span id='read_exact.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.read_exact' class='fnname'>read_exact</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></span></h4> <div class='docblock'><p>Read the exact number of bytes required to fill <code>buf</code>. <a href="../../std/io/trait.Read.html#method.read_exact">Read more</a></p> </div><h4 id='method.by_ref' class="method"><span id='by_ref.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> &mut Self <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates a "by reference" adaptor for this instance of <code>Read</code>. <a href="../../std/io/trait.Read.html#method.by_ref">Read more</a></p> </div><h4 id='method.bytes' class="method"><span id='bytes.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.bytes' class='fnname'>bytes</a>(self) -> <a class="struct" href="../../std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Transforms this <code>Read</code> instance to an <code>Iterator</code> over its bytes. <a href="../../std/io/trait.Read.html#method.bytes">Read more</a></p> </div><h4 id='method.chars' class="method"><span id='chars.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.chars' class='fnname'>chars</a>(self) -> <a class="struct" href="../../std/io/struct.Chars.html" title="struct std::io::Chars">Chars</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>io </code><a href="https://github.com/rust-lang/rust/issues/27802">#27802</a>)</summary><p>the semantics of a partial read/write of where errors happen is currently unclear and may change</p> </details></div></div><div class='docblock'><p>Transforms this <code>Read</code> instance to an <code>Iterator</code> over <code>char</code>s. <a href="../../std/io/trait.Read.html#method.chars">Read more</a></p> </div><h4 id='method.chain' class="method"><span id='chain.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.chain' class='fnname'>chain</a><R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a>>(self, next: R) -> <a class="struct" href="../../std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a><Self, R> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates an adaptor which will chain this stream with another. <a href="../../std/io/trait.Read.html#method.chain">Read more</a></p> </div><h4 id='method.take' class="method"><span id='take.v' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.take' class='fnname'>take</a>(self, limit: <a class="primitive" href="../primitive.u64.html">u64</a>) -> <a class="struct" href="../../std/io/struct.Take.html" title="struct std::io::Take">Take</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates an adaptor which will read at most <code>limit</code> bytes from it. <a href="../../std/io/trait.Read.html#method.take">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#454-459' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.write' class="method"><span id='write.v' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#tymethod.write' class='fnname'>write</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Write a buffer into this object, returning how many bytes were written. <a href="../../std/io/trait.Write.html#tymethod.write">Read more</a></p> </div><h4 id='method.flush' class="method"><span id='flush.v' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#tymethod.flush' class='fnname'>flush</a>(&mut self) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Flush this output stream, ensuring that all intermediately buffered contents reach their destination. <a href="../../std/io/trait.Write.html#tymethod.flush">Read more</a></p> </div><h4 id='method.write_all' class="method"><span id='write_all.v' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#method.write_all' class='fnname'>write_all</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Attempts to write an entire buffer into this write. <a href="../../std/io/trait.Write.html#method.write_all">Read more</a></p> </div><h4 id='method.write_fmt' class="method"><span id='write_fmt.v' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#method.write_fmt' class='fnname'>write_fmt</a>(&mut self, fmt: <a class="struct" href="../../std/fmt/struct.Arguments.html" title="struct std::fmt::Arguments">Arguments</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Writes a formatted string into this writer, returning any error encountered. <a href="../../std/io/trait.Write.html#method.write_fmt">Read more</a></p> </div><h4 id='method.by_ref-1' class="method"><span id='by_ref.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> &mut Self <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates a "by reference" adaptor for this instance of <code>Write</code>. <a href="../../std/io/trait.Write.html#method.by_ref">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/io/trait.Seek.html" title="trait std::io::Seek">Seek</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#461-465' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.seek' class="method"><span id='seek.v' class='invisible'><code>fn <a href='../../std/io/trait.Seek.html#tymethod.seek' class='fnname'>seek</a>(&mut self, pos: <a class="enum" href="../../std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.u64.html">u64</a>></code></span></h4> <div class='docblock'><p>Seek to an offset, in bytes, in a stream. <a href="../../std/io/trait.Seek.html#tymethod.seek">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl<'a> <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a> for &'a <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#467-474' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.read-1' class="method"><span id='read.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#tymethod.read' class='fnname'>read</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Pull some bytes from this source into the specified buffer, returning how many bytes were read. <a href="../../std/io/trait.Read.html#tymethod.read">Read more</a></p> </div><h4 id='method.read_to_end-1' class="method"><span id='read_to_end.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.read_to_end' class='fnname'>read_to_end</a>(&mut self, buf: &mut <a class="struct" href="../../std/vec/struct.Vec.html" title="struct std::vec::Vec">Vec</a><<a class="primitive" href="../primitive.u8.html">u8</a>>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="../../std/io/trait.Read.html#method.read_to_end">Read more</a></p> </div><h4 id='method.read_to_string-1' class="method"><span id='read_to_string.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.read_to_string' class='fnname'>read_to_string</a>(&mut self, buf: &mut <a class="struct" href="../../std/string/struct.String.html" title="struct std::string::String">String</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="../../std/io/trait.Read.html#method.read_to_string">Read more</a></p> </div><h4 id='method.read_exact-1' class="method"><span id='read_exact.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.read_exact' class='fnname'>read_exact</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code><div class='since' title='Stable since Rust version 1.6.0'>1.6.0</div></span></h4> <div class='docblock'><p>Read the exact number of bytes required to fill <code>buf</code>. <a href="../../std/io/trait.Read.html#method.read_exact">Read more</a></p> </div><h4 id='method.by_ref-2' class="method"><span id='by_ref.v-2' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> &mut Self <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates a "by reference" adaptor for this instance of <code>Read</code>. <a href="../../std/io/trait.Read.html#method.by_ref">Read more</a></p> </div><h4 id='method.bytes-1' class="method"><span id='bytes.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.bytes' class='fnname'>bytes</a>(self) -> <a class="struct" href="../../std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Transforms this <code>Read</code> instance to an <code>Iterator</code> over its bytes. <a href="../../std/io/trait.Read.html#method.bytes">Read more</a></p> </div><h4 id='method.chars-1' class="method"><span id='chars.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.chars' class='fnname'>chars</a>(self) -> <a class="struct" href="../../std/io/struct.Chars.html" title="struct std::io::Chars">Chars</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>io </code><a href="https://github.com/rust-lang/rust/issues/27802">#27802</a>)</summary><p>the semantics of a partial read/write of where errors happen is currently unclear and may change</p> </details></div></div><div class='docblock'><p>Transforms this <code>Read</code> instance to an <code>Iterator</code> over <code>char</code>s. <a href="../../std/io/trait.Read.html#method.chars">Read more</a></p> </div><h4 id='method.chain-1' class="method"><span id='chain.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.chain' class='fnname'>chain</a><R: <a class="trait" href="../../std/io/trait.Read.html" title="trait std::io::Read">Read</a>>(self, next: R) -> <a class="struct" href="../../std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a><Self, R> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates an adaptor which will chain this stream with another. <a href="../../std/io/trait.Read.html#method.chain">Read more</a></p> </div><h4 id='method.take-1' class="method"><span id='take.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Read.html#method.take' class='fnname'>take</a>(self, limit: <a class="primitive" href="../primitive.u64.html">u64</a>) -> <a class="struct" href="../../std/io/struct.Take.html" title="struct std::io::Take">Take</a><Self> <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates an adaptor which will read at most <code>limit</code> bytes from it. <a href="../../std/io/trait.Read.html#method.take">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl<'a> <a class="trait" href="../../std/io/trait.Write.html" title="trait std::io::Write">Write</a> for &'a <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#476-481' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.write-1' class="method"><span id='write.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#tymethod.write' class='fnname'>write</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Write a buffer into this object, returning how many bytes were written. <a href="../../std/io/trait.Write.html#tymethod.write">Read more</a></p> </div><h4 id='method.flush-1' class="method"><span id='flush.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#tymethod.flush' class='fnname'>flush</a>(&mut self) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Flush this output stream, ensuring that all intermediately buffered contents reach their destination. <a href="../../std/io/trait.Write.html#tymethod.flush">Read more</a></p> </div><h4 id='method.write_all-1' class="method"><span id='write_all.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#method.write_all' class='fnname'>write_all</a>(&mut self, buf: <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Attempts to write an entire buffer into this write. <a href="../../std/io/trait.Write.html#method.write_all">Read more</a></p> </div><h4 id='method.write_fmt-1' class="method"><span id='write_fmt.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#method.write_fmt' class='fnname'>write_fmt</a>(&mut self, fmt: <a class="struct" href="../../std/fmt/struct.Arguments.html" title="struct std::fmt::Arguments">Arguments</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.tuple.html">()</a>></code></span></h4> <div class='docblock'><p>Writes a formatted string into this writer, returning any error encountered. <a href="../../std/io/trait.Write.html#method.write_fmt">Read more</a></p> </div><h4 id='method.by_ref-3' class="method"><span id='by_ref.v-3' class='invisible'><code>fn <a href='../../std/io/trait.Write.html#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> &mut Self <span class="where fmt-newline">where<br> Self: <a class="trait" href="../../std/marker/trait.Sized.html" title="trait std::marker::Sized">Sized</a>, </span></code></span></h4> <div class='docblock'><p>Creates a "by reference" adaptor for this instance of <code>Write</code>. <a href="../../std/io/trait.Write.html#method.by_ref">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl<'a> <a class="trait" href="../../std/io/trait.Seek.html" title="trait std::io::Seek">Seek</a> for &'a <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/fs.rs.html#483-487' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.seek-1' class="method"><span id='seek.v-1' class='invisible'><code>fn <a href='../../std/io/trait.Seek.html#tymethod.seek' class='fnname'>seek</a>(&mut self, pos: <a class="enum" href="../../std/io/enum.SeekFrom.html" title="enum std::io::SeekFrom">SeekFrom</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.u64.html">u64</a>></code></span></h4> <div class='docblock'><p>Seek to an offset, in bytes, in a stream. <a href="../../std/io/trait.Seek.html#tymethod.seek">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/os/unix/io/trait.AsRawFd.html" title="trait std::os::unix::io::AsRawFd">AsRawFd</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/std/sys/unix/ext/io.rs.html#76-80' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.as_raw_fd' class="method"><span id='as_raw_fd.v' class='invisible'><code>fn <a href='../../std/os/unix/io/trait.AsRawFd.html#tymethod.as_raw_fd' class='fnname'>as_raw_fd</a>(&self) -> <a class="type" href="../../std/os/unix/io/type.RawFd.html" title="type std::os::unix::io::RawFd">RawFd</a></code></span></h4> <div class='docblock'><p>Extracts the raw file descriptor. <a href="../../std/os/unix/io/trait.AsRawFd.html#tymethod.as_raw_fd">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/os/unix/io/trait.FromRawFd.html" title="trait std::os::unix::io::FromRawFd">FromRawFd</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.1.0'>1.1.0</div><a class='srclink' href='../../src/std/sys/unix/ext/io.rs.html#82-86' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.from_raw_fd' class="method"><span id='from_raw_fd.v' class='invisible'><code>unsafe fn <a href='../../std/os/unix/io/trait.FromRawFd.html#tymethod.from_raw_fd' class='fnname'>from_raw_fd</a>(fd: <a class="type" href="../../std/os/unix/io/type.RawFd.html" title="type std::os::unix::io::RawFd">RawFd</a>) -> <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span></h4> <div class='docblock'><p>Constructs a new instance of <code>Self</code> from the given raw file descriptor. <a href="../../std/os/unix/io/trait.FromRawFd.html#tymethod.from_raw_fd">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/os/unix/io/trait.IntoRawFd.html" title="trait std::os::unix::io::IntoRawFd">IntoRawFd</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.4.0'>1.4.0</div><a class='srclink' href='../../src/std/sys/unix/ext/io.rs.html#88-92' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.into_raw_fd' class="method"><span id='into_raw_fd.v' class='invisible'><code>fn <a href='../../std/os/unix/io/trait.IntoRawFd.html#tymethod.into_raw_fd' class='fnname'>into_raw_fd</a>(self) -> <a class="type" href="../../std/os/unix/io/type.RawFd.html" title="type std::os::unix::io::RawFd">RawFd</a></code></span></h4> <div class='docblock'><p>Consumes this object, returning the raw underlying file descriptor. <a href="../../std/os/unix/io/trait.IntoRawFd.html#tymethod.into_raw_fd">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../../std/os/unix/fs/trait.FileExt.html" title="trait std::os::unix::fs::FileExt">FileExt</a> for <a class="struct" href="../../std/fs/struct.File.html" title="struct std::fs::File">File</a></code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.15.0'>1.15.0</div><a class='srclink' href='../../src/std/sys/unix/ext/fs.rs.html#59-66' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.read_at' class="method"><span id='read_at.v' class='invisible'><code>fn <a href='../../std/os/unix/fs/trait.FileExt.html#tymethod.read_at' class='fnname'>read_at</a>(&self, buf: <a class="primitive" href="../primitive.slice.html">&mut [</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>, offset: <a class="primitive" href="../primitive.u64.html">u64</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Reads a number of bytes starting from a given offset. <a href="../../std/os/unix/fs/trait.FileExt.html#tymethod.read_at">Read more</a></p> </div><h4 id='method.write_at' class="method"><span id='write_at.v' class='invisible'><code>fn <a href='../../std/os/unix/fs/trait.FileExt.html#tymethod.write_at' class='fnname'>write_at</a>(&self, buf: <a class="primitive" href="../primitive.slice.html">&[</a><a class="primitive" href="../primitive.u8.html">u8</a><a class="primitive" href="../primitive.slice.html">]</a>, offset: <a class="primitive" href="../primitive.u64.html">u64</a>) -> <a class="type" href="../../std/io/type.Result.html" title="type std::io::Result">Result</a><<a class="primitive" href="../primitive.usize.html">usize</a>></code></span></h4> <div class='docblock'><p>Writes a number of bytes starting from a given offset. <a href="../../std/os/unix/fs/trait.FileExt.html#tymethod.write_at">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>?</dt> <dd>Show this help dialog</dd> <dt>S</dt> <dd>Focus the search field</dd> <dt>⇤</dt> <dd>Move up in search results</dd> <dt>⇥</dt> <dd>Move down in search results</dd> <dt>⏎</dt> <dd>Go to active search result</dd> <dt>+</dt> <dd>Collapse/expand 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 = "std"; </script> <script src="../../main.js"></script> <script defer src="../../search-index.js"></script> </body> </html>