openssh_sftp_client::fs

Struct Fs

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

A struct used to perform operations on remote filesystem.

Implementations§

Source§

impl Fs

Source

pub fn cwd(&self) -> &Path

Return current working dir.

Source

pub fn set_cwd(&mut self, cwd: impl Into<PathBuf>)

Set current working dir.

  • cwd - Can include ~. If it is empty, then it is set to use the default directory set by the remote sftp-server.
Source§

impl Fs

Source

pub async fn open_dir(&mut self, path: impl AsRef<Path>) -> Result<Dir, Error>

Open a remote dir

Source

pub fn dir_builder(&mut self) -> DirBuilder<'_>

Create a directory builder.

Source

pub async fn create_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error>

Creates a new, empty directory at the provided path.

Source

pub async fn remove_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error>

Removes an existing, empty directory.

Source

pub async fn remove_file(&mut self, path: impl AsRef<Path>) -> Result<(), Error>

Removes a file from remote filesystem.

Source

pub async fn canonicalize( &mut self, path: impl AsRef<Path>, ) -> Result<PathBuf, Error>

Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.

If the remote server supports the expand-path extension, then this method will also expand tilde characters (“~”) in the path. You can check it with Sftp::support_expand_path.

Creates a new hard link on the remote filesystem.

§Precondition

Require extension hardlink

You can check it with Sftp::support_hardlink.

Creates a new symlink on the remote filesystem.

Source

pub async fn rename( &mut self, from: impl AsRef<Path>, to: impl AsRef<Path>, ) -> Result<(), Error>

Renames a file or directory to a new name, replacing the original file if to already exists.

If the server supports the posix-rename extension, it will be used. You can check it with Sftp::support_posix_rename.

This will not work if the new name is on a different mount point.

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

Source

pub async fn set_metadata( &mut self, path: impl AsRef<Path>, metadata: MetaData, ) -> Result<(), Error>

Change the metadata of a file or a directory.

Source

pub async fn set_permissions( &mut self, path: impl AsRef<Path>, perm: Permissions, ) -> Result<(), Error>

Changes the permissions found on a file or a directory.

Source

pub async fn metadata( &mut self, path: impl AsRef<Path>, ) -> Result<MetaData, Error>

Given a path, queries the file system to get information about a file, directory, etc.

Queries the file system metadata for a path.

Source

pub async fn read(&mut self, path: impl AsRef<Path>) -> Result<BytesMut, Error>

Reads the entire contents of a file into a bytes.

Source

pub async fn write( &mut self, path: impl AsRef<Path>, content: impl AsRef<[u8]>, ) -> Result<(), Error>

Open/Create a file for writing and write the entire contents into it.

Trait Implementations§

Source§

impl Clone for Fs

Source§

fn clone(&self) -> Fs

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Fs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Fs

§

impl !RefUnwindSafe for Fs

§

impl Send for Fs

§

impl Sync for Fs

§

impl Unpin for Fs

§

impl !UnwindSafe for Fs

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more