12 releases
0.3.1 | Dec 30, 2023 |
---|---|
0.3.0 | Dec 28, 2023 |
0.2.3 | Dec 28, 2023 |
0.1.5 | Dec 23, 2023 |
#233 in Concurrency
101 downloads per month
24KB
405 lines
file_rw
file_rw
is a Rust crate for high-performance, memory-mapped file I/O utilities.
Features
- High-performance file reading and writing capabilities
- Memory-mapped files for efficient access and manipulation
- High-level, efficient abstractions of common operations on file contents
Installation
You can include the crate in your Rust project by either:
- Adding the following to your
Cargo.toml
file:
[dependencies]
file_rw = "0.3.1"
- Run the following Cargo command to automatically do so:
cargo add file_rw
Modules
file
: File operationsread
: File reading capabilitieswrite
: File writing capabilities
Re-exports
The crate re-exports the FileReader
and FileWriter
structs for external use. These structs contain the aforementioned utilities.
Examples
use file_rw::{FileReader, FileWriter};
use tempfile::tempdir;
let tempdir = tempdir().unwrap();
let tempdir_path = tempdir.path();
let test_path = tempdir_path.join("test.txt");
let mut writer = FileWriter::open(&test_path);
writer.append("Hello World!"); //Hello World!
writer.overwrite("Hello"); //Hello
writer.write("Hullo"); //Hullo
writer.find_replace_nth("l", "y", 0); //Huylo
writer.find_replace("u", "e"); //Heylo
writer.find_replace("lo", "yyy"); //Heyyyy
writer.find_replace_all("y", "i"); //Heiiii
writer.find_replace("e", "i"); //Hiiiii
let reader = writer.to_reader();
let content = reader.read_to_string();
assert_eq!(content, "Hiiiii");
Dependencies
~2.5MB
~30K SLoC