typed_shmem

Exposes shared memory on *nix and Windows using mapped files. This work is heavily inspired on the sharedmemory crate, but instead of being just a copy cat, typedshmem provides a typed mapping into the shared memory region.

Usage

First, a process must create the shared region: ```rust use typedshmem as sh; use typedshmem::error::ShMemErr; use typed_shmem::common::ShMemOps;

fn main() -> Result<(), ShMemErr> { let mut mem = sh::ShMemCfg::::default() .setowner() .onfile("test_program") .build()?;

//Writing
unsafe { *mem.get_t_mut() = 10; }

//Reading
let val = unsafe { mem.get_t() };
assert_eq!(*val, 10);

loop {} //Used to keep the process alive, thus the allocated shared memory too.

Ok(())

```

Then, any other process can join the same region: ```rust use typedshmem as sh; use typedshmem::error::ShMemErr; use typed_shmem::common::ShMemOps;

fn main() -> Result<(), ShMemErr> { let mut mem = sh::ShMemCfg::::default() .onfile("testprogram") .build()?;

let val = unsafe { mem.get_t() };
assert_eq!(*val, 10);

Ok(())

} ```

To-Do (no specific order)

Contributions

All contributions to this project will be under Apache-2.0 license.