Memory buffers with platform-specific protections and automatic zeroization.
This crate provides buffer implementations that combine automatic zeroization with platform-specific memory protection capabilities.
Buffer Types
PortableBuffer
Cross-platform buffer that works everywhere:
- Uses standard heap allocation
- Automatic zeroization on drop
- No platform-specific protections
- Available on all platforms
PageBuffer (Unix only)
Platform-specific buffer with memory protection:
- Uses
mmapfor allocation - Optional
mlockto prevent swapping to disk - Optional
mprotectto make pages read-only when not in use - Automatic zeroization on drop
- Only available on Unix platforms
Protection Strategies
PageBuffer supports two protection strategies:
- MemProtected: Uses
mprotectto make pages read-only by default. Data can only be accessed through closures that temporarily unprotect the page. - MemNonProtected: Pages remain readable/writable. Data can be accessed directly through slices.
Example: PortableBuffer
use ;
# example.unwrap;
Example: PageBuffer with Protection
#
# example.unwrap;
License
GPL-3.0-only