pub struct NcFile { /* private fields */ }
Expand description

A wrapper struct around libc::FILE

The notcursesFILE type is a transparent struct, while the equivalent libc’s FILE is an opaque enum.

Several methods are provided to cast back and forth between both types, in order to allow both rust libc operations and notcurses file operations over the same underlying *FILE.

Implementations§

Intended to be passed into the CFile::open method. It will open the file in a way that will allow reading and writing, including overwriting old data. It will not create the file if it does not exist.

Intended to be passed into the CFile::open method. It will open the file in a way that will allow reading and writing, including overwriting old data

Intended to be passed into the CFile::open method. It will only allow reading.

Intended to be passed into the CFile::open method. It will only allow writing.

Intended to be passed into the CFile::open method. It will only allow data to be appended to the end of the file.

Intended to be passed into the CFile::open method. It will allow data to be appended to the end of the file, and data to be read from the file. It will create the file if it doesn’t exist.

Intended to be passed into the CFile::open method. It will open the file in a way that will allow reading and writing, including overwriting old data. It will create the file if it doesn’t exist

NcFile constructor from a file produced by notcurses.

NcFile constructor from a file produced by the libc crate.

Returns the file pointer in the format expected by the libc crate.

Returns the file pointer in the format expected by notcurses.

Returns the current position in the file.

On error Error::Errno(errno) is returned.

Reads the file from start to end. Convenience method.

Trait Implementations§

Formats the value using the given formatter. Read more

Ensures the file stream is closed before abandoning the data.

Reads exactly the number of bytes required to fill buf.

If the end of the file is reached before buf is filled, Err(EndOfFile(bytes_read)) will be returned. The data that was read before that will still have been placed into buf.

Upon some other error, Err(Errno(errno)) will be returned.

Reads the entire file starting from the current_position expanding buf as needed.

On a successful read, this function will return Ok(bytes_read).

If an error occurs during reading, some varient of error will be returned.

Reads the entire file from the beginning and stores it in a string.

On a successful read, this function will return Ok(bytes_read).

If an error occurs during reading, some varient of error will be returned.

Reads exactly the number of bytes required to fill buf.

If the end of the file is reached before buf is filled, Err(EndOfFile(bytes_read)) will be returned. The data that was read before that will still have been placed into buf.

Upon some other error, Err(Errno(errno)) will be returned.

Like read, except that it reads into a slice of buffers. Read more
🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
🔬This is a nightly-only experimental API. (read_buf)
Read the exact number of bytes required to fill cursor. Read more
Creates a “by reference” adaptor for this instance of Read. Read more
Transforms this Read instance to an Iterator over its bytes. Read more
Creates an adapter which will chain this stream with another. Read more
Creates an adapter which will read at most limit bytes from it. Read more

Changes the current position in the file using the SeekFrom enum.

To set relative to the beginning of the file (i.e. index is 0 + offset):

SeekFrom::Start(offset)

To set relative to the end of the file (i.e. index is file_lenth - 1 - offset):

SeekFrom::End(offset)

To set relative to the current position:

SeekFrom::End(offset)

On error Error::Errno(errno) is returned.

Rewind to the beginning of a stream. Read more
🔬This is a nightly-only experimental API. (seek_stream_len)
Returns the length of this stream (in bytes). Read more
Returns the current seek position from the start of the stream. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.