1 unstable release
Uses new Rust 2024
| 0.1.0 | Sep 27, 2025 |
|---|
#78 in #mmap
101 downloads per month
Used in 3 crates
(via memmap3)
33KB
560 lines
memmap3-macros
Procedural macros for the memmap3 crate.
⚠️ Note for Users
You should not install this crate directly. This crate contains the procedural macros used by
memmap3 and is automatically included when you add memmap3 to your dependencies.
Installation
Add memmap3 to your Cargo.toml (not this crate):
[dependencies]
memmap3 = "0.1"
What This Crate Provides
This crate implements the #[mmap_struct] attribute macro that transforms regular Rust structs into
memory-mappable types:
use memmap3::prelude::*;
#[mmap_struct] // <- This macro is provided by memmap3-macros
struct Config {
#[mmap(atomic)]
counter: u64,
name: [u8; 32],
}
The macro automatically:
- Adds
#[repr(C)]for predictable memory layout - Transforms atomic fields (e.g.,
u64with#[mmap(atomic)]becomesMmapAtomicU64) - Auto-detects byte arrays as strings (unless marked with
#[mmap(raw)]) - Generates the
StructLayouttrait implementation
Documentation
For complete documentation and examples, see the main memmap3 crate.
License
This project is licensed under the MIT OR Apache-2.0 license.
Dependencies
~150–550KB
~13K SLoC