Struct russh_sftp::client::SftpSession
source · pub struct SftpSession { /* private fields */ }
Expand description
High-level SFTP implementation for easy interaction with a remote file system. Contains most methods similar to the native filesystem
Implementations§
source§impl SftpSession
impl SftpSession
sourcepub async fn new<S>(stream: S) -> SftpResult<Self>
pub async fn new<S>(stream: S) -> SftpResult<Self>
Creates a new session by initializing the protocol and extensions
sourcepub async fn set_timeout(&self, secs: u64)
pub async fn set_timeout(&self, secs: u64)
Set the maximum response time in seconds. Default: 10 seconds
sourcepub async fn close(&self) -> SftpResult<()>
pub async fn close(&self) -> SftpResult<()>
Closes the inner channel stream.
sourcepub async fn open<T: Into<String>>(&self, filename: T) -> SftpResult<File>
pub async fn open<T: Into<String>>(&self, filename: T) -> SftpResult<File>
Attempts to open a file in read-only mode.
sourcepub async fn create<T: Into<String>>(&self, filename: T) -> SftpResult<File>
pub async fn create<T: Into<String>>(&self, filename: T) -> SftpResult<File>
Opens a file in write-only mode.
This function will create a file if it does not exist, and will truncate it if it does.
sourcepub async fn open_with_flags<T: Into<String>>(
&self,
filename: T,
flags: OpenFlags
) -> SftpResult<File>
pub async fn open_with_flags<T: Into<String>>( &self, filename: T, flags: OpenFlags ) -> SftpResult<File>
Attempts to open or create the file in the specified mode
sourcepub async fn canonicalize<T: Into<String>>(&self, path: T) -> SftpResult<String>
pub async fn canonicalize<T: Into<String>>(&self, path: T) -> SftpResult<String>
Requests the remote party for the absolute from the relative path.
sourcepub async fn create_dir<T: Into<String>>(&self, path: T) -> SftpResult<()>
pub async fn create_dir<T: Into<String>>(&self, path: T) -> SftpResult<()>
Creates a new empty directory.
sourcepub async fn read<P: Into<String>>(&self, path: P) -> SftpResult<Vec<u8>>
pub async fn read<P: Into<String>>(&self, path: P) -> SftpResult<Vec<u8>>
Reads the contents of a file located at the specified path to the end.
sourcepub async fn write<P: Into<String>>(
&self,
path: P,
data: &[u8]
) -> SftpResult<()>
pub async fn write<P: Into<String>>( &self, path: P, data: &[u8] ) -> SftpResult<()>
Writes the contents to a file whose path is specified.
sourcepub async fn try_exists<P: Into<String>>(&self, path: P) -> SftpResult<bool>
pub async fn try_exists<P: Into<String>>(&self, path: P) -> SftpResult<bool>
Checks a file or folder exists at the specified path
sourcepub async fn read_dir<P: Into<String>>(&self, path: P) -> SftpResult<ReadDir>
pub async fn read_dir<P: Into<String>>(&self, path: P) -> SftpResult<ReadDir>
Returns an iterator over the entries within a directory.
sourcepub async fn read_link<P: Into<String>>(&self, path: P) -> SftpResult<String>
pub async fn read_link<P: Into<String>>(&self, path: P) -> SftpResult<String>
Reads a symbolic link, returning the file that the link points to.
sourcepub async fn remove_dir<P: Into<String>>(&self, path: P) -> SftpResult<()>
pub async fn remove_dir<P: Into<String>>(&self, path: P) -> SftpResult<()>
Removes the specified folder.
sourcepub async fn remove_file<T: Into<String>>(&self, filename: T) -> SftpResult<()>
pub async fn remove_file<T: Into<String>>(&self, filename: T) -> SftpResult<()>
Removes the specified file.
sourcepub async fn rename<O, N>(&self, oldpath: O, newpath: N) -> SftpResult<()>
pub async fn rename<O, N>(&self, oldpath: O, newpath: N) -> SftpResult<()>
Rename a file or directory to a new name.
sourcepub async fn symlink<P, T>(&self, path: P, target: T) -> SftpResult<()>
pub async fn symlink<P, T>(&self, path: P, target: T) -> SftpResult<()>
Creates a symlink of the specified target.
sourcepub async fn metadata<P: Into<String>>(&self, path: P) -> SftpResult<Metadata>
pub async fn metadata<P: Into<String>>(&self, path: P) -> SftpResult<Metadata>
Queries metadata about the remote file.
sourcepub async fn set_metadata<P: Into<String>>(
&self,
path: P,
metadata: Metadata
) -> Result<(), Error>
pub async fn set_metadata<P: Into<String>>( &self, path: P, metadata: Metadata ) -> Result<(), Error>
Sets metadata for a remote file.