file_operation/delete/async/fn.rs
1use crate::*;
2
3/// Asynchronously deletes a file at the given path.
4///
5/// # Arguments
6///
7/// - `&str` - The file path to delete.
8///
9/// # Returns
10///
11/// - `Result<(), std::io::Error>` - Ok if the file was deleted successfully, Err with error details otherwise.
12pub async fn async_delete_file(path: &str) -> Result<(), Error> {
13 tokio::fs::remove_file(path).await
14}
15
16/// Asynchronously deletes a directory and all its contents.
17///
18/// # Arguments
19///
20/// - `&str` - The directory path to delete.
21///
22/// # Returns
23///
24/// - `Result<(), std::io::Error>` - Ok if the directory was deleted successfully, Err with error details otherwise.
25pub async fn async_delete_dir(path: &str) -> Result<(), Error> {
26 let dir_path: &Path = Path::new(path);
27 tokio::fs::remove_dir_all(dir_path).await?;
28 Ok(())
29}