| Crates.io | dash-rs |
| lib.rs | dash-rs |
| version | 0.1.1 |
| created_at | 2024-12-27 18:20:08.419953+00 |
| updated_at | 2024-12-27 18:24:12.610977+00 |
| description | A filesystem-engine that handles creating/reading/deleting/write/... files. Also includes an network-manager (dev): Download files. |
| homepage | |
| repository | https://github.com/dino-sh/dash-rs |
| max_upload_size | |
| id | 1496539 |
| size | 8,737 |
A simple library crate that provides utility functions for interacting with the filesystem, including creating, reading, and deleting files.
To add this crate as a dependency in your project, update your Cargo.toml file:
[dependencies]
dash_rs = "0.1.1"
Replace "0.1.1" with the appropriate version if needed.
You can call the functions from the filesystem module to interact with the filesystem. Below are examples for each function.
To create a file, you can use the create_file function:
use dash_engine::filesystem::create_file;
fn main() {
match create_file("path/to/directory", "example.txt") {
Ok(()) => println!("File created successfully!"),
Err(e) => println!("Error creating file: {}", e),
}
}
To read a file, use the read_file function:
use dash_engine::filesystem::read_file;
fn main() {
match read_file("path/to/directory", "example.txt") {
Ok(content) => println!("File content: {}", content),
Err(e) => println!("Error reading file: {}", e),
}
}
To delete a file, use the delete_file function:
use dash_engine::filesystem::delete_file;
fn main() {
match delete_file("path/to/directory", "example.txt") {
Ok(()) => println!("File deleted successfully!"),
Err(e) => println!("Error deleting file: {}", e),
}
}
create_filepub fn create_file(directory: &str, file_name: &str) -> io::Result<()>;
directory: The path to the directory where the file should be created.file_name: The name of the file to create.Ok(()) if the file is created successfully.Err(io::Error) if an error occurs.read_filepub fn read_file(directory: &str, file_name: &str) -> io::Result<String>;
directory: The path to the directory where the file is located.file_name: The name of the file to read.Ok(String) containing the file's content.Err(io::Error) if an error occurs.delete_filepub fn delete_file(directory: &str, file_name: &str) -> io::Result<()>;
directory: The path to the directory where the file is located.file_name: The name of the file to delete.Ok(()) if the file is deleted successfully.Err(io::Error) if an error occurs.This project is licensed under the following license:
create_file function creates the entire directory structure if it doesn't already exist (using fs::create_dir_all).read_file function reads the entire file content into a String.delete_file function removes the specified file.