static_memory_rs 0.1.0

A fixed-capacity, no_std-friendly memory region with typed read/write access, runtime bounds checks, and alignment verification — ideal for embedded and systems programming.
Documentation
  • Coverage
  • 75%
    6 out of 8 items documented0 out of 7 items with examples
  • Size
  • Source code size: 4.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 890.49 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • WebAppEnjoyer

Region — Fixed‑Size Typed Memory Access for no_std

A small, panic‑checked static memory region that provides safe, typed reads and writes with runtime bounds and alignment verification.
Useful in no_std and embedded contexts where you need manual layout control without the unpredictability of the global allocator.

Features

  • #![no_std] compatible
  • Compile‑time fixed capacity
  • Runtime bounds & alignment checks
  • Simple API for typed load/store

Example (no_std)

#![no_std]
#![no_main]

use core::mem::{align_of, size_of};
use my_region_crate::Region;

#[repr(C)]
#[derive(Copy, Clone, Debug)]
struct Header {
    id: u32,
    flags: u16,
}

#[no_mangle]
pub extern "C" fn main() -> ! {
    let mut reg: Region<64> = Region::new();

    // Safe write — offset is aligned to 4 for u32
    reg.write::<u32>(0, 0xDEADBEEF);

    // Safe write — offset is aligned to 4 (Header's max field align)
    reg.write::<Header>(4, Header { id: 42, flags: 3 });

    // Safe read back
    let hdr: Header = reg.read::<Header>(4);
    assert_eq!(hdr.id, 42);

    loop {}
}