#file-io #file #memory-map #mmap #io #file-lock #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

#216 in Filesystem

Download history 198/week @ 2024-01-01 233/week @ 2024-01-08 643/week @ 2024-01-15 290/week @ 2024-01-22 518/week @ 2024-01-29 483/week @ 2024-02-05 309/week @ 2024-02-12 390/week @ 2024-02-19 348/week @ 2024-02-26 286/week @ 2024-03-04 479/week @ 2024-03-11 482/week @ 2024-03-18 1020/week @ 2024-03-25 782/week @ 2024-04-01 333/week @ 2024-04-08 359/week @ 2024-04-15

2,560 downloads per month
Used in 8 crates (5 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

~4–19MB
~239K SLoC