#file-io #memory-mapped #read-file #abstraction #utilities #reading #access

file_rw

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

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

Download history 12/week @ 2023-12-21 24/week @ 2023-12-28 2/week @ 2024-02-15 3/week @ 2024-02-22 6/week @ 2024-03-07 24/week @ 2024-03-14 36/week @ 2024-03-28 36/week @ 2024-04-04

101 downloads per month

GPL-3.0-or-later

24KB
405 lines

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.3.1"
  • 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", "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