Struct openssh_sftp_client::fs::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> 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,

§

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

§

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