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

source

pub async fn new<S>(stream: S) -> SftpResult<Self>
where S: AsyncRead + AsyncWrite + Unpin + Send + 'static,

Creates a new session by initializing the protocol and extensions

source

pub async fn set_timeout(&self, secs: u64)

Set the maximum response time in seconds. Default: 10 seconds

source

pub async fn close(&self) -> SftpResult<()>

Closes the inner channel stream.

source

pub async fn open<T: Into<String>>(&self, filename: T) -> SftpResult<File>

Attempts to open a file in read-only mode.

source

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.

source

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

source

pub async fn canonicalize<T: Into<String>>(&self, path: T) -> SftpResult<String>

Requests the remote party for the absolute from the relative path.

source

pub async fn create_dir<T: Into<String>>(&self, path: T) -> SftpResult<()>

Creates a new empty directory.

source

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.

source

pub async fn write<P: Into<String>>( &self, path: P, data: &[u8] ) -> SftpResult<()>

Writes the contents to a file whose path is specified.

source

pub async fn try_exists<P: Into<String>>(&self, path: P) -> SftpResult<bool>

Checks a file or folder exists at the specified path

source

pub async fn read_dir<P: Into<String>>(&self, path: P) -> SftpResult<ReadDir>

Returns an iterator over the entries within a directory.

Reads a symbolic link, returning the file that the link points to.

source

pub async fn remove_dir<P: Into<String>>(&self, path: P) -> SftpResult<()>

Removes the specified folder.

source

pub async fn remove_file<T: Into<String>>(&self, filename: T) -> SftpResult<()>

Removes the specified file.

source

pub async fn rename<O, N>(&self, oldpath: O, newpath: N) -> SftpResult<()>
where O: Into<String>, N: Into<String>,

Rename a file or directory to a new name.

Creates a symlink of the specified target.

source

pub async fn metadata<P: Into<String>>(&self, path: P) -> SftpResult<Metadata>

Queries metadata about the remote file.

source

pub async fn set_metadata<P: Into<String>>( &self, path: P, metadata: Metadata ) -> Result<(), Error>

Sets metadata for a remote file.

source

pub async fn fs_info<P: Into<String>>( &self, path: P ) -> SftpResult<Option<Statvfs>>

Performs a statvfs on the remote file system path. Returns [Ok(None)] if the remote SFTP server does not support statvfs@openssh.com extension v2.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.