6 releases

0.3.0 Oct 11, 2023
0.2.0 Sep 13, 2023
0.1.3 Sep 11, 2023
0.1.0 Aug 30, 2023

#9 in #dirty

Download history 96/week @ 2024-12-09 167/week @ 2024-12-16 18/week @ 2024-12-23 14/week @ 2024-12-30 15/week @ 2025-01-06 34/week @ 2025-01-13 67/week @ 2025-01-20 35/week @ 2025-01-27 67/week @ 2025-02-03 54/week @ 2025-02-10 41/week @ 2025-02-17 15/week @ 2025-02-24 40/week @ 2025-03-03 92/week @ 2025-03-10 81/week @ 2025-03-17 313/week @ 2025-03-24

529 downloads per month
Used in 5 crates (via piecrust)

MPL-2.0 license

31KB
544 lines

Crumbles

Repository Build Status Documentation

Crumbles is a Rust library designed for creating and managing copy-on-write memory-mapped regions. This allows for efficient memory handling by tracking changes at page level. It's particularly suitable for scenarios where memory snapshots and reverting to previous states are required.

Usage

The core fuctionality of Crumbles is provided by the Mmap struct. This struct offers methods to manage memory regions, create snapshots and revert/apply changes.

Add crumbles as a dependency to your contract project:

cargo add crumbles

To make use of crumbles, import the dependency in your project. Example:

use crumbles::Mmap;
use std::io;

fn main() -> io::Result<()> {
    let mut mmap = Mmap::new(65536, 65536)?;

    // When first created, the mmap is not dirty.
    assert_eq!(mmap.dirty_pages().count(), 0);

    mmap[24] = 42;

    // After writing a single byte, the page it's on is dirty.
    assert_eq!(mmap.dirty_pages().count(), 1);

    Ok(())
}

Build and Test

To build and test the crate you will need a Rust toolchain. Use the following commands to run the tests:

cargo test

Release History

To see the release history for this crate, please see the CHANGELOG file.

License

This code is licensed under the Mozilla Public License Version 2.0 (MPL-2.0). Please see the LICENSE for further details.

Contribute

If you want to contribute to this project, please check the CONTRIBUTING file.

Dependencies

~260KB