file_rw 0.1.5

A library for high-performance, memory-mapped file I/O utilities.
Documentation

file_rw

file_rw is a Rust crate for high-performance, memory-mapped file I/O utilities.

Crates.io GNU GPLv3 licensed Build Status docs.rs

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.1.5"
  • Run the following Cargo command to automatically do so:
cargo add file_rw

Modules

  • file: File operations
  • read: File reading capabilities
  • write: 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", &"r", 1); //Hulro
writer.find_replace(&"o", &"ooooooo"); //Hulrooooooo
writer.find_replace_all(&"o", &"d"); //Hulrddddddd
let reader = FileReader::open(&test_path);
let content = reader.read_to_string();
assert_eq!(content, "Hulrddddddd");