#file #mmap #memory-map #io #memmapix

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

#207 in Filesystem

Download history 317/week @ 2023-11-01 487/week @ 2023-11-08 404/week @ 2023-11-15 471/week @ 2023-11-22 543/week @ 2023-11-29 327/week @ 2023-12-06 495/week @ 2023-12-13 300/week @ 2023-12-20 303/week @ 2023-12-27 186/week @ 2024-01-03 602/week @ 2024-01-10 519/week @ 2024-01-17 278/week @ 2024-01-24 677/week @ 2024-01-31 491/week @ 2024-02-07 502/week @ 2024-02-14

2,030 downloads per month
Used in 7 crates (4 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–19MB
~244K SLoC