SftpFs

Struct SftpFs 

Source
pub struct SftpFs<S>
where S: SshSession,
{ /* private fields */ }
Expand description

Sftp “filesystem” client

Implementations§

Source§

impl SftpFs<LibSsh2Session>

Source

pub fn libssh2(opts: SshOpts) -> Self

Available on crate feature libssh2 only.

Constructs a new SftpFs instance with the libssh2 backend.

Source§

impl SftpFs<LibSshSession>

Source

pub fn libssh(opts: SshOpts) -> Self

Available on crate feature libssh only.

Constructs a new SftpFs instance with the libssh backend.

Source§

impl<S> SftpFs<S>
where S: SshSession,

Source

pub fn session(&mut self) -> Option<&mut S>

Get a reference to current session value.

Source

pub fn sftp(&mut self) -> Option<&mut S::Sftp>

Get a reference to current sftp value.

Trait Implementations§

Source§

impl From<SshOpts> for SftpFs<LibSsh2Session>

Source§

fn from(opts: SshOpts) -> Self

Converts to this type from the input type.
Source§

impl From<SshOpts> for SftpFs<LibSshSession>

Source§

fn from(opts: SshOpts) -> Self

Converts to this type from the input type.
Source§

impl<S> RemoteFs for SftpFs<S>
where S: SshSession,

Source§

fn connect(&mut self) -> RemoteResult<Welcome>

Connect to the remote server and authenticate. Can return banner / welcome message on success. If client has already established connection, then RemoteErrorType::AlreadyConnected error is returned.
Source§

fn disconnect(&mut self) -> RemoteResult<()>

Disconnect from the remote server
Source§

fn is_connected(&mut self) -> bool

Gets whether the client is connected to remote
Source§

fn pwd(&mut self) -> RemoteResult<PathBuf>

Get working directory
Source§

fn change_dir(&mut self, dir: &Path) -> RemoteResult<PathBuf>

Change working directory. Returns the realpath of new directory
Source§

fn list_dir(&mut self, path: &Path) -> RemoteResult<Vec<File>>

List directory entries at specified path
Source§

fn stat(&mut self, path: &Path) -> RemoteResult<File>

Stat file at specified path and return File
Source§

fn setstat(&mut self, path: &Path, metadata: Metadata) -> RemoteResult<()>

Set metadata for file at specified path
Source§

fn exists(&mut self, path: &Path) -> RemoteResult<bool>

Returns whether file at specified path exists.
Source§

fn remove_file(&mut self, path: &Path) -> RemoteResult<()>

Remove file at specified path. Fails if is not a file or doesn’t exist
Source§

fn remove_dir(&mut self, path: &Path) -> RemoteResult<()>

Remove directory at specified path Directory is removed only if empty
Source§

fn remove_dir_all(&mut self, path: &Path) -> RemoteResult<()>

Removes a directory at this path, after removing all its contents. Use carefully! Read more
Source§

fn create_dir(&mut self, path: &Path, mode: UnixPex) -> RemoteResult<()>

Create a directory at path with specified mode. Read more
Create a symlink at path pointing at target
Source§

fn copy(&mut self, src: &Path, dest: &Path) -> RemoteResult<()>

Copy src to dest
Source§

fn mov(&mut self, src: &Path, dest: &Path) -> RemoteResult<()>

move file/directory from src to dest
Source§

fn exec(&mut self, cmd: &str) -> RemoteResult<(u32, String)>

Execute a command on remote host if supported by host. Returns command exit code and output (stdout)
Source§

fn append( &mut self, path: &Path, metadata: &Metadata, ) -> RemoteResult<WriteStream>

Open file at path for appending data. If the file doesn’t exist, the file is created. Read more
Source§

fn create( &mut self, path: &Path, metadata: &Metadata, ) -> RemoteResult<WriteStream>

Create file at path for write. If the file already exists, its content will be overwritten Read more
Source§

fn open(&mut self, path: &Path) -> RemoteResult<ReadStream>

Open file at specified path for read.
Source§

fn append_file( &mut self, path: &Path, metadata: &Metadata, reader: Box<dyn Read + Send>, ) -> RemoteResult<u64>

Blocking implementation of RemoteFs::append This method SHOULD be implemented ONLY when streams are not supported by the current file transfer. The developer using the client should FIRST try with create followed by on_written If the function returns error of kind RemoteErrorType::UnsupportedFeature, then he should call this function. In case of success, returns the amount of bytes written to the remote file Read more
Source§

fn create_file( &mut self, path: &Path, metadata: &Metadata, reader: Box<dyn Read + Send>, ) -> RemoteResult<u64>

Blocking implementation of RemoteFs::create This method SHOULD be implemented ONLY when streams are not supported by the current file transfer. The developer using the client should FIRST try with create followed by on_written If the function returns error of kind RemoteErrorType::UnsupportedFeature, then he should call this function. In case of success, returns the amount of bytes written to the remote file Read more
Source§

fn open_file( &mut self, src: &Path, dest: Box<dyn Write + Send>, ) -> RemoteResult<u64>

Blocking implementation of RemoteFs::open This method SHOULD be implemented ONLY when streams are not supported by the current file transfer. (since it would work thanks to the default implementation) The developer using the client should FIRST try with RemoteFs::open followed by RemoteFs::on_read If the function returns error of kind RemoteErrorType::UnsupportedFeature, then he should call this function. In case of success, returns the amount of bytes written to the local stream Read more
Source§

fn on_written(&mut self, _writable: WriteStream) -> Result<(), RemoteError>

Finalize RemoteFs::create and RemoteFs::append methods. This method must be implemented only if necessary; in case you don’t need it, just return Ok The purpose of this method is to finalize the connection with the peer when writing data. This is necessary for some protocols such as FTP. You must call this method each time you want to finalize the write of the remote file. Read more
Source§

fn on_read(&mut self, _readable: ReadStream) -> Result<(), RemoteError>

Finalize RemoteFs::open method. This method must be implemented only if necessary; in case you don’t need it, just return Ok The purpose of this method is to finalize the connection with the peer when reading data. This might be necessary for some protocols. You must call this method each time you want to finalize the read of the remote file. Read more
Source§

fn find(&mut self, search: &str) -> Result<Vec<File>, RemoteError>

Find files from current directory (in all subdirectories) whose name matches the provided search Search supports wildcards (‘?’, ‘*’)
Search recursively in dir for file matching the wildcard. Read more

Auto Trait Implementations§

§

impl<S> Freeze for SftpFs<S>
where S: Freeze, <S as SshSession>::Sftp: Freeze,

§

impl<S> !RefUnwindSafe for SftpFs<S>

§

impl<S> Send for SftpFs<S>
where S: Send, <S as SshSession>::Sftp: Send,

§

impl<S> Sync for SftpFs<S>
where S: Sync, <S as SshSession>::Sftp: Sync,

§

impl<S> Unpin for SftpFs<S>
where S: Unpin, <S as SshSession>::Sftp: Unpin,

§

impl<S> !UnwindSafe for SftpFs<S>

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>,

Source§

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>,

Source§

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.