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.tomlfile:
[]
= "0.6.4"
- Running the following Cargo command to automatically do so:
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
The following are examples of using methods from the FileReader and FileWriter structs.
The examples are separated based on the crate features required to run them.
Simple Read and Write
use ;
use tempdir;
let tempdir = tempdir.unwrap;
let tempdir_path = tempdir.path;
let test_path = tempdir_path.join;
let mut writer = open.unwrap;
writer.append;
assert_eq!;
writer.overwrite;
assert_eq!;
writer.write;
assert_eq!;
Search and Replace
Use the search feature to enable search and replace capabilities.
use ;
use tempdir;
let tempdir = tempdir.unwrap;
let tempdir_path = tempdir.path;
let test_path = tempdir_path.join;
let mut writer = open.unwrap;
writer.overwrite;
Hashing
Use the hash feature to enable hash capabilities - these methods require providing a
Digest to hash with.
use ;
use tempdir;
let tempdir = tempdir.unwrap;
let tempdir_path = tempdir.path;
let test_path = tempdir_path.join;
let mut writer = open.unwrap;
writer.overwrite;
let reader = writer.as_reader.unwrap;
SHA3_256 Hashing
Use the sha3_256 feature to enable SHA3_256 hash capabilities - this also enables the
hash feature, but provides convenience methods that don't require manually providing a Digest.
use ;
use tempdir;
let tempdir = tempdir.unwrap;
let tempdir_path = tempdir.path;
let test_path = tempdir_path.join;
let mut writer = open.unwrap;
writer.overwrite;
let reader = writer.as_reader.unwrap;