embedded-pod-storage
Storing POD(Plain Old Data) in embedded systems.
Overview
embedded-pod-storage is a no-std Rust library designed for storing Plain Old Data (POD) types in embedded systems' flash memory. It provides two different storage strategies optimized for different use cases:
- Alternate Storage (
AlternateStorage) - A power-fail protected storage solution that uses two flash pages to implement wear leveling and safe updates. This approach prevents data loss during power failures and extends flash memory life through garbage collection.
Features
- No-std compatible: Designed for embedded environments without standard library support
- Generic over POD types: Works with any type that implements the
bytemuck::Podtrait - Flash-optimized: Efficiently uses flash memory with appropriate flagging and alignment
- Wear leveling: The alternate storage implementation spreads writes across two pages to extend flash life
- Power-fail protection: Alternate storage provides protection against data corruption during power failures
Usage
Add this to your Cargo.toml:
[]
= "*"
= { = "1.25", = ["derive"] }
Alternate Storage Example
use ;
use AlternateStorage;
// Define your POD data structure
// Initialize alternate storage (flash, page0 start, page1 start, page size, data type, version)
let flash = new_blocking;
let mut cfg_storage = new;
let mut cfg = new;
// Read and write operations are similar to SingleStorage
match cfg_storage.read
match cfg_storage.write
Dependencies
embedded-storage- Provides the flash storage traitsbytemuck- For safe casting between POD types and byte arrays
License
This project is licensed under the MIT License.