Struct Sftp

Source
pub struct Sftp { /* private fields */ }
Expand description

A handle to a remote filesystem over SFTP.

Instances are created through the sftp method on a Session.

Implementations§

Source§

impl Sftp

Source

pub fn open_mode<T: AsRef<Path>>( &self, filename: T, flags: OpenFlags, mode: i32, open_type: OpenType, ) -> Result<File, Error>

Open a handle to a file.

The mode will represent the permissions for the file (Wikipedia).

Source

pub fn open<T: AsRef<Path>>(&self, filename: T) -> Result<File, Error>

Helper to open a file in the Read mode.

Source

pub fn create(&self, filename: &Path) -> Result<File, Error>

Helper to create a file in write-only mode with truncation.

Source

pub fn opendir<T: AsRef<Path>>(&self, dirname: T) -> Result<File, Error>

Helper to open a directory for reading its contents.

Source

pub fn readdir<T: AsRef<Path>>( &self, dirname: T, ) -> Result<Vec<(PathBuf, FileStat)>, Error>

Convenience function to read the files in a directory.

The returned paths are all joined with dirname when returned, and the paths . and .. are filtered out of the returned list.

Source

pub fn mkdir(&self, filename: &Path, mode: i32) -> Result<(), Error>

Create a directory on the remote file system.

The mode will set the permissions of the new directory (Wikipedia).

Source

pub fn rmdir(&self, filename: &Path) -> Result<(), Error>

Remove a directory from the remote file system.

Source

pub fn stat(&self, filename: &Path) -> Result<FileStat, Error>

Get the metadata for a file, performed by stat(2)

Source

pub fn lstat(&self, filename: &Path) -> Result<FileStat, Error>

Get the metadata for a file, performed by lstat(2)

Source

pub fn setstat(&self, filename: &Path, stat: FileStat) -> Result<(), Error>

Set the metadata for a file.

Create a symlink at target pointing at path.

Read a symlink at path.

Source

pub fn realpath(&self, path: &Path) -> Result<PathBuf, Error>

Resolve the real path for path.

Source

pub fn rename( &self, src: &Path, dst: &Path, flags: Option<RenameFlags>, ) -> Result<(), Error>

Rename a filesystem object on the remote filesystem.

The semantics of this command typically include the ability to move a filesystem object between folders and/or filesystem mounts. If the Overwrite flag is not set and the destfile entry already exists, the operation will fail.

Use of the other flags (Native or Atomic) indicate a preference (but not a requirement) for the remote end to perform an atomic rename operation and/or using native system calls when possible.

If no flags are specified then all flags are used.

Remove a file on the remote filesystem

Trait Implementations§

Auto Trait Implementations§

§

impl Freeze for Sftp

§

impl !RefUnwindSafe for Sftp

§

impl Unpin for Sftp

§

impl !UnwindSafe for Sftp

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.