Struct libnotcurses_sys::NcFile[][src]

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

A wrapper struct around libc::FILE

The notcurses FILE type FILE_NC a struct imported through bindgen, while the equivalent libc crate FILE (FILE_LIBC) 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

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_initializer)

Determines if this Reader can work with buffers of uninitialized memory. 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 adaptor which will chain this stream with another. Read more

Creates an adaptor 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.

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

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

Performs the conversion.

Performs the conversion.

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.