#file-io #file #io #mmap #memory-map #async-io #file-lock

fmmap

A flexible and convenient high-level mmap for zero-copy file I/O

13 releases

0.3.3 Sep 18, 2023
0.3.2 Oct 3, 2022
0.3.0 Jul 3, 2022
0.2.6 Jun 30, 2022
0.1.0 Dec 9, 2021

#323 in Filesystem

Download history 888/week @ 2024-07-21 996/week @ 2024-07-28 1441/week @ 2024-08-04 990/week @ 2024-08-11 794/week @ 2024-08-18 1242/week @ 2024-08-25 788/week @ 2024-09-01 1646/week @ 2024-09-08 1114/week @ 2024-09-15 1314/week @ 2024-09-22 1152/week @ 2024-09-29 1023/week @ 2024-10-06 1441/week @ 2024-10-13 1005/week @ 2024-10-20 1109/week @ 2024-10-27 865/week @ 2024-11-03

4,486 downloads per month
Used in 12 crates (6 directly)

MIT/Apache

555KB
8K SLoC

fmmap

A flexible and convenient high-level mmap for zero-copy file I/O.

English | 简体中文

github Build codecov

docs.rs crates.io rustc

license-apache license-mit

Design

The design of this crate is inspired by Dgraph's mmap file implementation in Stretto.

All of file-backed memory map has the potential for Undefined Behavior (UB) if the underlying file is subsequently modified (e.g. the file is deleted by another process), in or out of process, this crate tries to avoid this situation by provide file lock APIs.

This crate supports std and popular async runtime(tokio, async-std, smol), and thanks to macro in Rust, it is super easy to support any new async runtime. For details, please see the implementation for tokio, async-std, smol of the source code.

Features

  • dozens of file I/O util functions
  • file-backed memory maps
  • synchronous and asynchronous flushing
  • copy-on-write memory maps
  • read-only memory maps
  • stack support (MAP_STACK on unix)
  • executable memory maps
  • file locks.
  • tokio
  • smol
  • async-std

Installation

  • std

    [dependencies]
    fmmap = 0.2 
    
  • tokio

    [dependencies]
    fmmap = { version = "0.3", features = ["tokio-async"] }
    
  • async-std

    [dependencies]
    fmmap = { version = "0.3", features = ["std-async"] }
    
  • smol

    [dependencies]
    fmmap = { version = "0.3", features = ["smol-async"] }
    

Examples

This crate is 100% documented, see documents for examples.

TODO

  • add benchmarks

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~5–20MB
~254K SLoC