pub fn move_items_with_progress<P, Q, F>(
    from_items: &[P],
    to: Q,
    options: &CopyOptions,
    progress_handler: F
) -> Result<u64>where
    P: AsRef<Path>,
    Q: AsRef<Path>,
    F: FnMut(TransitProcess) -> TransitProcessResult,
Expand description

Moves a list of directories and files to another place recursively, with information about progress. This function will also copy the permission bits of the original files to destination files (not for directories).


This function will return an error in the following situations, but is not limited to just these case:

  • List from contains file or directory does not exist.

  • List from contains file or directory with invalid name.

  • The current process does not have the permission to access to file from lists from or to.


 extern crate fs_extra;
 use fs_extra::dir::copy;

 let options = dir::CopyOptions::new(); //Initialize default values for CopyOptions
 let handle = |process_info: TransitProcess| {
    println!("{}", process_info.total_bytes);
 // move dir1 and file1.txt to target/dir1 and target/file1.txt
 let mut from_paths = Vec::new();
 move_items_with_progress(&from_paths, "target", &options, handle)?;