pub struct File<'s> { /* private fields */ }
Expand description

A reference to the remote file.

Cloning File instance would return a new one that shares the same underlying file handle as the existing File instance, while reads, writes and seeks can be performed independently.

If you want a file that implements tokio::io::AsyncRead and tokio::io::AsyncWrite, checkout TokioCompatFile.

Implementations

Close the File, send the close request if this is the last reference.

Cancel Safety

This function is cancel safe.

Return the underlying sftp.

Change the metadata of a file or a directory.

Cancel Safety

This function is cancel safe.

Truncates or extends the underlying file, updating the size of this file to become size.

If the size is less than the current file’s size, then the file will be shrunk.

If it is greater than the current file’s size, then the file will be extended to size and have all of the intermediate data filled in with 0s.

Cancel Safety

This function is cancel safe.

Attempts to sync all OS-internal metadata to disk.

This function will attempt to ensure that all in-core data reaches the filesystem before returning.

Cancel Safety

This function is cancel safe.

Changes the permissions on the underlying file.

Cancel Safety

This function is cancel safe.

Queries metadata about the underlying file.

  • n - number of bytes to read in

If the File has reached EOF or n == 0, then None is returned.

Write data into the file.

Write from multiple buffer at once.

Zero copy write.

  • n - number of bytes to read in.

If n == 0 or EOF is reached, then buffer is returned unchanged.

Cancel Safety

This function is cancel safe.

Write entire buf.

Cancel Safety

This function is cancel safe.

Write entire buf.

Cancel Safety

This function is cancel safe.

Write entire buf.

Cancel Safety

This function is cancel safe.

Return the offset of the file.

Copy n bytes of data from self to dst.

The server MUST copy the data exactly as if the data is copied using a series of read and write.

There are no protocol restictions on this operation; however, the server MUST ensure that the user does not exceed quota, etc. The server is, as always, free to complete this operation out of order if it is too large to complete immediately, or to refuse a request that is too large.

After a successful function call, the offset of self and dst are increased by n.

Precondition

Requires extension copy_data. For openssh-portable, this is available from V_9_0_P1.

If the extension is not supported by the server, this function would fail with Error::UnsupportedExtension.

Copy data from self to dst until EOF is encountered.

The server MUST copy the data exactly as if the data is copied using a series of read and write.

There are no protocol restictions on this operation; however, the server MUST ensure that the user does not exceed quota, etc. The server is, as always, free to complete this operation out of order if it is too large to complete immediately, or to refuse a request that is too large.

After a successful function call, the offset of self and dst are unchanged.

Precondition

Requires extension copy_data. For openssh-portable, this is available from V_9_0_P1.

If the extension is not supported by the server, this function would fail with Error::UnsupportedExtension.

Trait Implementations

start_seek only adjust local offset since sftp protocol does not provides a seek function.

Instead, offset is provided when sending read/write requests, thus errors are reported at read/write.

This function is a no-op, it simply return the offset.

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Creates a future which will seek an IO object, and then yield the new position in the object and the object itself. Read more
Creates a future which will rewind to the beginning of the stream. Read more
Creates a future which will return the current seek position from the start of the stream. 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 resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
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.