Skip to main content

FileOperations

Trait FileOperations 

Source
pub trait FileOperations {
    // Required methods
    fn rename_file<P: AsRef<Path>>(
        &self,
        path: P,
        pattern: &RenamePattern,
    ) -> Result<PathBuf>;
    fn rename_files<P: AsRef<Path>>(
        &self,
        paths: &[P],
        pattern: &RenamePattern,
    ) -> Result<Vec<PathBuf>>;
    fn organize_by_date<P: AsRef<Path>, Q: AsRef<Path>>(
        &self,
        path: P,
        target_dir: Q,
        date_format: &str,
    ) -> Result<PathBuf>;
    fn organize<P: AsRef<Path>>(
        &self,
        path: P,
        options: &OrganizeOptions,
    ) -> Result<PathBuf>;
    fn create_metadata_backup<P: AsRef<Path>, Q: AsRef<Path>>(
        &self,
        source: P,
        backup_path: Q,
    ) -> Result<()>;
    fn restore_from_backup<P: AsRef<Path>, Q: AsRef<Path>>(
        &self,
        backup: P,
        target: Q,
    ) -> Result<()>;
}
Expand description

文件操作 trait

Required Methods§

Source

fn rename_file<P: AsRef<Path>>( &self, path: P, pattern: &RenamePattern, ) -> Result<PathBuf>

重命名单个文件

Source

fn rename_files<P: AsRef<Path>>( &self, paths: &[P], pattern: &RenamePattern, ) -> Result<Vec<PathBuf>>

批量重命名文件

Source

fn organize_by_date<P: AsRef<Path>, Q: AsRef<Path>>( &self, path: P, target_dir: Q, date_format: &str, ) -> Result<PathBuf>

按日期组织文件到目录

Source

fn organize<P: AsRef<Path>>( &self, path: P, options: &OrganizeOptions, ) -> Result<PathBuf>

根据元数据组织文件

Source

fn create_metadata_backup<P: AsRef<Path>, Q: AsRef<Path>>( &self, source: P, backup_path: Q, ) -> Result<()>

生成元数据备份文件 (.mie 格式)

Source

fn restore_from_backup<P: AsRef<Path>, Q: AsRef<Path>>( &self, backup: P, target: Q, ) -> Result<()>

从备份恢复元数据

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§