fmmap

A flexible and convenient high-level mmap for zero-copy file I/O. English | [简体中文](README-zh_CN.md) [github][Github-url] [Build][CI-url] [codecov][codecov-url] [docs.rs][doc-url] [crates.io][crates-url] [rustc][rustc-url] [license-apache][license-apache-url] [license-mit][license-mit-url]
## Design The design of this crate is inspired by Dgraph's mmap file implementation in [Stretto](https://github.com/dgraph-io/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 - [x] dozens of file I/O util functions - [x] file-backed memory maps - [x] synchronous and asynchronous flushing - [x] copy-on-write memory maps - [x] read-only memory maps - [x] stack support (`MAP_STACK` on unix) - [x] executable memory maps - [x] file locks. - [x] [tokio][tokio] - [x] [smol][smol] - [x] [async-std][async-std] ## Installation - std ```toml [dependencies] fmmap = 0.2 ``` - [tokio][tokio] ```toml [dependencies] fmmap = { version = "0.3", features = ["tokio-async"] } ``` - [async-std][async-std] ```toml [dependencies] fmmap = { version = "0.3", features = ["std-async"] } ``` - [smol][smol] ```toml [dependencies] fmmap = { version = "0.3", features = ["smol-async"] } ``` ## Examples This crate is 100% documented, see [documents][doc-url] 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. [Github-url]: https://github.com/al8n/fmmap/ [CI-url]: https://github.com/al8n/fmmap/actions/workflows/rust.yml [doc-url]: https://docs.rs/fmmap [crates-url]: https://crates.io/crates/fmmap [codecov-url]: https://app.codecov.io/gh/al8n/fmmap/ [license-url]: https://opensource.org/licenses/Apache-2.0 [rustc-url]: https://github.com/rust-lang/rust/blob/master/RELEASES.md [license-apache-url]: https://opensource.org/licenses/Apache-2.0 [license-mit-url]: https://opensource.org/licenses/MIT [tokio]: https://crates.io/crates/tokio [smol]: https://crates.io/crates/smol [async-std]: https://crates.io/crates/async-std