Struct ssh2_patched::File
source · [−]pub struct File { /* private fields */ }
Expand description
A file handle to an SFTP connection.
Files behave similarly to std::old_io::File
in that they are readable and
writable and support operations like stat and seek.
Files are created through open
, create
, and open_mode
on an instance
of Sftp
.
Implementations
sourceimpl File
impl File
sourcepub fn setstat(&mut self, stat: FileStat) -> Result<(), Error>
pub fn setstat(&mut self, stat: FileStat) -> Result<(), Error>
Set the metadata for this handle.
pub fn statvfs(&mut self) -> Result<LIBSSH2_SFTP_STATVFS, Error>
sourcepub fn readdir(&mut self) -> Result<(PathBuf, FileStat), Error>
pub fn readdir(&mut self) -> Result<(PathBuf, FileStat), Error>
Reads a block of data from a handle and returns file entry information for the next entry, if any.
Note that this provides raw access to the readdir
function from
libssh2. This will return an error when there are no more files to
read, and files such as .
and ..
will be included in the return
values.
Also note that the return paths will not be absolute paths, they are the filenames of the files in this directory.
Trait Implementations
sourceimpl Read for File
impl Read for File
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
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>
read
, except that it reads into a slice of buffers. Read moresourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · sourcefn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
buf
. Read more1.0.0 · sourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresourcefn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)sourcefn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Read
. Read moresourceimpl Seek for File
impl Seek for File
sourcefn seek(&mut self, how: SeekFrom) -> Result<u64>
fn seek(&mut self, how: SeekFrom) -> Result<u64>
Move the file handle’s internal pointer to an arbitrary location.
libssh2 implements file pointers as a localized concept to make file access appear more POSIX like. No packets are exchanged with the server during a seek operation. The localized file pointer is simply used as a convenience offset during read/write operations.
You MUST NOT seek during writing or reading a file with SFTP, as the internals use outstanding packets and changing the “file position” during transit will results in badness.
1.55.0 · sourcefn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
sourceimpl Write for File
impl Write for File
sourcefn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
sourcefn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
sourcefn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector
)1.0.0 · sourcefn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
sourcefn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored
)