Struct path_abs::FileRead [] [src]

pub struct FileRead(_);

A read-only file handle with path() attached and improved error messages. Contains only the methods and trait implementations which are allowed by a read-only file.

Examples

use std::io::Read;
use path_abs::{PathFile, FileRead};

let example = "example.txt";
let file = PathFile::create(example)?;

let expected = "foo\nbar";
file.write_str(expected)?;

let mut read = FileRead::read(example)?;
let mut s = String::new();
read.read_to_string(&mut s)?;
assert_eq!(expected, s);

Methods

impl FileRead
[src]

[src]

Open the file as read-only.

[src]

Read what remains of the file to a String.

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 FileRead
[src]

[src]

Formats the value using the given formatter. Read more

impl Read for FileRead
[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 Seek for FileRead
[src]

[src]

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

impl Deref for FileRead
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl Into<File> for FileRead
[src]

Important traits for &'a File
[src]

Performs the conversion.

Auto Trait Implementations

impl Send for FileRead

impl Sync for FileRead