pub trait FileOperations {
// Provided methods
fn read_file_with_context(path: impl AsRef<Path>) -> Result<String> { ... }
fn write_file_with_context(
path: impl AsRef<Path>,
content: impl AsRef<str>,
) -> Result<()> { ... }
fn create_dir_with_context(path: impl AsRef<Path>) -> Result<()> { ... }
fn read_bytes_with_context(path: impl AsRef<Path>) -> Result<Vec<u8>> { ... }
fn write_bytes_with_context(
path: impl AsRef<Path>,
content: impl AsRef<[u8]>,
) -> Result<()> { ... }
fn copy_file_with_context(
from: impl AsRef<Path>,
to: impl AsRef<Path>,
) -> Result<u64> { ... }
fn remove_file_with_context(path: impl AsRef<Path>) -> Result<()> { ... }
fn remove_dir_all_with_context(path: impl AsRef<Path>) -> Result<()> { ... }
fn check_exists_with_context(path: impl AsRef<Path>) -> Result<bool> { ... }
}Expand description
Common file operations with consistent error handling
Provided Methods§
Sourcefn read_file_with_context(path: impl AsRef<Path>) -> Result<String>
fn read_file_with_context(path: impl AsRef<Path>) -> Result<String>
Read a file with appropriate error context
Sourcefn write_file_with_context(
path: impl AsRef<Path>,
content: impl AsRef<str>,
) -> Result<()>
fn write_file_with_context( path: impl AsRef<Path>, content: impl AsRef<str>, ) -> Result<()>
Write to a file with appropriate error context
Sourcefn create_dir_with_context(path: impl AsRef<Path>) -> Result<()>
fn create_dir_with_context(path: impl AsRef<Path>) -> Result<()>
Create a directory with appropriate error context
Sourcefn read_bytes_with_context(path: impl AsRef<Path>) -> Result<Vec<u8>>
fn read_bytes_with_context(path: impl AsRef<Path>) -> Result<Vec<u8>>
Read a file as bytes with appropriate error context
Sourcefn write_bytes_with_context(
path: impl AsRef<Path>,
content: impl AsRef<[u8]>,
) -> Result<()>
fn write_bytes_with_context( path: impl AsRef<Path>, content: impl AsRef<[u8]>, ) -> Result<()>
Write bytes to a file with appropriate error context
Sourcefn copy_file_with_context(
from: impl AsRef<Path>,
to: impl AsRef<Path>,
) -> Result<u64>
fn copy_file_with_context( from: impl AsRef<Path>, to: impl AsRef<Path>, ) -> Result<u64>
Copy a file with appropriate error context
Sourcefn remove_file_with_context(path: impl AsRef<Path>) -> Result<()>
fn remove_file_with_context(path: impl AsRef<Path>) -> Result<()>
Remove a file with appropriate error context
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.