pub struct Fs { /* private fields */ }
Expand description
A struct used to perform operations on remote filesystem.
Implementations§
Source§impl Fs
impl Fs
Sourcepub async fn open_dir(&mut self, path: impl AsRef<Path>) -> Result<Dir, Error>
pub async fn open_dir(&mut self, path: impl AsRef<Path>) -> Result<Dir, Error>
Open a remote dir
Sourcepub fn dir_builder(&mut self) -> DirBuilder<'_>
pub fn dir_builder(&mut self) -> DirBuilder<'_>
Create a directory builder.
Sourcepub async fn create_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error>
pub async fn create_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error>
Creates a new, empty directory at the provided path.
Sourcepub async fn remove_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error>
pub async fn remove_dir(&mut self, path: impl AsRef<Path>) -> Result<(), Error>
Removes an existing, empty directory.
Sourcepub async fn remove_file(&mut self, path: impl AsRef<Path>) -> Result<(), Error>
pub async fn remove_file(&mut self, path: impl AsRef<Path>) -> Result<(), Error>
Removes a file from remote filesystem.
Sourcepub async fn canonicalize(
&mut self,
path: impl AsRef<Path>,
) -> Result<PathBuf, Error>
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
.
Sourcepub async fn hard_link(
&mut self,
src: impl AsRef<Path>,
dst: impl AsRef<Path>,
) -> Result<(), Error>
pub async fn hard_link( &mut self, src: impl AsRef<Path>, dst: impl AsRef<Path>, ) -> Result<(), Error>
Creates a new hard link on the remote filesystem.
§Precondition
Require extension hardlink
You can check it with Sftp::support_hardlink
.
Sourcepub async fn symlink(
&mut self,
src: impl AsRef<Path>,
dst: impl AsRef<Path>,
) -> Result<(), Error>
pub async fn symlink( &mut self, src: impl AsRef<Path>, dst: impl AsRef<Path>, ) -> Result<(), Error>
Creates a new symlink on the remote filesystem.
Sourcepub async fn rename(
&mut self,
from: impl AsRef<Path>,
to: impl AsRef<Path>,
) -> Result<(), Error>
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.
Sourcepub async fn read_link(
&mut self,
path: impl AsRef<Path>,
) -> Result<PathBuf, Error>
pub async fn read_link( &mut self, path: impl AsRef<Path>, ) -> Result<PathBuf, Error>
Reads a symbolic link, returning the file that the link points to.
Sourcepub async fn set_metadata(
&mut self,
path: impl AsRef<Path>,
metadata: MetaData,
) -> Result<(), Error>
pub async fn set_metadata( &mut self, path: impl AsRef<Path>, metadata: MetaData, ) -> Result<(), Error>
Change the metadata of a file or a directory.
Sourcepub async fn set_permissions(
&mut self,
path: impl AsRef<Path>,
perm: Permissions,
) -> Result<(), Error>
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.
Sourcepub async fn metadata(
&mut self,
path: impl AsRef<Path>,
) -> Result<MetaData, Error>
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.
Sourcepub async fn symlink_metadata(
&mut self,
path: impl AsRef<Path>,
) -> Result<MetaData, Error>
pub async fn symlink_metadata( &mut self, path: impl AsRef<Path>, ) -> Result<MetaData, Error>
Queries the file system metadata for a path.