Struct path_abs::FileEdit [] [src]

pub struct FileEdit(_);

A read/write file handle with path() attached and improved error messages. Contains methods and trait implements for both readable and writeable files.

Examples

use std::io::{Read, Seek, Write, SeekFrom};
use path_abs::FileEdit;

let example = "example.txt";

let expected = "foo\nbar";
let mut edit = FileEdit::create(example)?;

let mut s = String::new();
edit.write_all(expected.as_bytes())?;
edit.seek(SeekFrom::Start(0))?;
edit.read_to_string(&mut s)?;

assert_eq!(expected, s);

Methods

impl FileEdit
[src]

[src]

Open the file with the given OpenOptions but always sets read and write to true.

[src]

Open the file in editing mode, truncating it first if it exists and creating it otherwise.

[src]

Open the file for appending, creating it if it doesn't exist.

[src]

Open the file for editing (reading and writing) but do not create it if it doesn't exist.

[src]

Attempts to sync all OS-internal metadata to disk.

This function will attempt to ensure that all in-core data reaches the filesystem before returning.

This function is identical to std::fs::File::sync_all except it has error messages which include the action and the path.

[src]

This function is similar to sync_all, except that it may not synchronize file metadata to the filesystem.

This function is identical to std::fs::File::sync_data except it has error messages which include the action and the path.

[src]

Truncates or extends the underlying file, updating the size of this file to become size.

This function is identical to std::fs::File::set_len except:

  • It has error messages which include the action and the path.
  • It takes &mut self instead of &self.

[src]

Changes the permissions on the underlying file.

This function is identical to std::fs::File::set_permissions except:

  • It has error messages which include the action and the path.
  • It takes &mut self instead of &self.

[src]

Read what remains of the file to a String.

[src]

Shortcut to self.write_all(s.as_bytes()) with slightly improved error message.

[src]

std::io::File::flush buth with the new error type.

Methods from Deref<Target = FileOpen>

[src]

Get the path associated with the open file.

[src]

Queries metadata about the underlying file.

This function is identical to std::fs::File::metadata except it has error messages which include the action and the path.

[src]

Creates a new independently owned handle to the underlying file.

This function is identical to std::fs::File::try_clone except it has error messages which include the action and the path and it returns a FileOpen object.

Trait Implementations

impl Debug for FileEdit
[src]

[src]

Formats the value using the given formatter. Read more

impl Read for FileEdit
[src]

[src]

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more

[src]

🔬 This is a nightly-only experimental API. (read_initializer)

Determines if this Reader can work with buffers of uninitialized memory. Read more

1.0.0
[src]

Read all bytes until EOF in this source, placing them into buf. Read more

1.0.0
[src]

Read all bytes until EOF in this source, appending them to buf. Read more

1.6.0
[src]

Read the exact number of bytes required to fill buf. Read more

Important traits for &'a mut W
1.0.0
[src]

Creates a "by reference" adaptor for this instance of Read. Read more

Important traits for Bytes<R>
1.0.0
[src]

Transforms this Read instance to an [Iterator] over its bytes. Read more

Important traits for Chars<R>
[src]

🔬 This is a nightly-only experimental API. (io)

the semantics of a partial read/write of where errors happen is currently unclear and may change

Transforms this Read instance to an [Iterator] over [char]s. Read more

Important traits for Chain<T, U>
1.0.0
[src]

Creates an adaptor which will chain this stream with another. Read more

Important traits for Take<T>
1.0.0
[src]

Creates an adaptor which will read at most limit bytes from it. Read more

impl Write for FileEdit
[src]

[src]

Write a buffer into this object, returning how many bytes were written. Read more

[src]

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

1.0.0
[src]

Attempts to write an entire buffer into this write. Read more

1.0.0
[src]

Writes a formatted string into this writer, returning any error encountered. Read more

Important traits for &'a mut W
1.0.0
[src]

Creates a "by reference" adaptor for this instance of Write. Read more

impl Seek for FileEdit
[src]

[src]

Seek to an offset, in bytes, in a stream. Read more

impl Deref for FileEdit
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl Into<File> for FileEdit
[src]

Important traits for &'a File
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for FileEdit

impl Sync for FileEdit