Expand description
This module provides functions for performing CRUD (Create, Read, Update, Delete) operations on files in the Rust programming language.
This module simplifies file operations in Rust, making it easy to manage and manipulate files in your applications.
It offers a simple and efficient way to work with files, allowing you to create, read, update, and delete files with ease.
Contents
- Create a file with the given content.
- Read a file given its path and filename.
- Update an existing file with new content.
- Delete a file given its path and filename.
Examples
In this example we create a file, then read it and update it.
use dev_utils::files::*;
let path = "test/"; // Specify the path where the file should be created.
let filename = "example.txt"; // Also specify the file format & path.
let content = "Hello, Rust!"; // Specify the content to write to the file.
let result = create_file(path, filename, content); // Create the file.
assert!(result.is_ok()); // Check if the file was created successfully.
let result = read_file(path, filename); // Read the file.
assert_eq!(result.unwrap(), "Hello, Rust!"); // Check if the file content is correct.
let content = "Updated content!"; // Specify the new content to write to the file.
let result = update_file(path, filename, content); // Update the file.Functions
- Creates a file with the given content.
- Deletes a file given its path and filename.
- Reads a file given its path and filename.
- Updates an existing file with new content.