# Trait std::os::windows::fs::FileExt 1.15.0[−][src]

    pub trait FileExt {
        fn seek_read(&self, buf: &mut [u8], offset: u64) -> Result<usize>;
        fn seek_write(&self, buf: &[u8], offset: u64) -> Result<usize>;
    }

This is supported on Windows only.

Windows-specific extensions to `File`.

## Required Methods

### `fn seek_read(&self, buf: &mut [u8], offset: u64) -> Result<usize>`

This is supported on Windows only.

Seeks to a given position and reads a number of bytes.

Returns the number of bytes read.

The offset is relative to the start of the file and thus independent from the current cursor. The current cursor is affected by this function, it is set to the end of the read.

Reading beyond the end of the file will always return with a length of 0.

Note that similar to `File::read`, it is not an error to return with a short read. When returning from such a short read, the file pointer is still updated.

# Examples

    use std::io;
    use std::fs::File;
    use std::os::windows::prelude::*;

    fn main() -> io::Result<()> {
        let mut file = File::open("foo.txt")?;
        let mut buffer = [0; 10];

        // Read 10 bytes, starting 72 bytes from the
        // start of the file.
        file.seek_read(&mut buffer[..], 72)?;
        Ok(())
    }Run

### `fn seek_write(&self, buf: &[u8], offset: u64) -> Result<usize>`

This is supported on Windows only.

Seeks to a given position and writes a number of bytes.

Returns the number of bytes written.

The offset is relative to the start of the file and thus independent from the current cursor. The current cursor is affected by this function, it is set to the end of the write.

When writing beyond the end of the file, the file is appropriately extended and the intermediate bytes are left uninitialized.

Note that similar to `File::write`, it is not an error to return a short write. When returning from such a short write, the file pointer is still updated.

# Examples

    use std::fs::File;
    use std::os::windows::prelude::*;

    fn main() -> std::io::Result<()> {
        let mut buffer = File::create("foo.txt")?;

        // Write a byte string starting 72 bytes from
        // the start of the file.
        buffer.seek_write(b"some bytes", 72)?;
        Ok(())
    }Run

## Implementors

- `impl FileExt for File` | [src]

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)