Struct libnotcurses_sys::NcFile
source · [−]pub struct NcFile { /* private fields */ }Expand description
A wrapper struct around
libc::FILE
The notcurses’ FILE 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
sourceimpl NcFile
impl NcFile
sourcepub const RANDOM_ACCESS_MODE: &'static str
pub const RANDOM_ACCESS_MODE: &'static str
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.
sourcepub const UPDATE: &'static str
pub const UPDATE: &'static str
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
sourcepub const READ_ONLY: &'static str
pub const READ_ONLY: &'static str
Intended to be passed into the CFile::open method. It will only allow reading.
sourcepub const WRITE_ONLY: &'static str
pub const WRITE_ONLY: &'static str
Intended to be passed into the CFile::open method. It will only allow writing.
sourcepub const APPEND_ONLY: &'static str
pub const APPEND_ONLY: &'static str
Intended to be passed into the CFile::open method. It will only allow data to be appended to the end of the file.
sourcepub const APPEND_READ: &'static str
pub const APPEND_READ: &'static str
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.
sourcepub const TRUNCATE_RANDOM_ACCESS_MODE: &'static str
pub const TRUNCATE_RANDOM_ACCESS_MODE: &'static str
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
sourceimpl NcFile
impl NcFile
sourcepub fn as_libc_ptr(&self) -> *mut FILE
pub fn as_libc_ptr(&self) -> *mut FILE
Returns the file pointer in the format expected by the libc crate.
sourcepub fn as_nc_ptr(&self) -> *mut FILE
pub fn as_nc_ptr(&self) -> *mut FILE
Returns the file pointer in the format expected by notcurses.
sourcepub fn current_pos(&self) -> Result<u64, Error>
pub fn current_pos(&self) -> Result<u64, Error>
Returns the current position in the file.
On error Error::Errno(errno) is returned.
Trait Implementations
sourceimpl Read for NcFile
impl Read for NcFile
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
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.
sourcefn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
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.
sourcefn read_to_string(&mut self, strbuf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, strbuf: &mut String) -> Result<usize, Error>
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.
sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
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.
1.36.0 · sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like read, except that it reads into a slice of buffers. Read more
sourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)Determines if this Reader has an efficient read_vectored
implementation. Read more
sourcefn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf)Read the exact number of bytes required to fill buf. Read more
1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Creates a “by reference” adaptor for this instance of Read. Read more
sourceimpl Seek for NcFile
impl Seek for NcFile
sourcefn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
fn seek(&mut self, pos: SeekFrom) -> Result<u64, Error>
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.
1.55.0 · sourcefn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
Auto Trait Implementations
impl RefUnwindSafe for NcFile
impl !Send for NcFile
impl !Sync for NcFile
impl Unpin for NcFile
impl UnwindSafe for NcFile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more