Fake repl/env via mmap ser-de-able objects

Question: Is there a way to construct structs that are easy to serialize / deserialize to mmap-ed memory?

Context:

  1. I know about https://crates.io/search?q=repl . I am trying a different approach.

  2. One of the difficulties of using Rust for "interactive" programming is that in repl based languages, we often have an in-memory-persistent environment mapping variables to data.

  3. Question here is if we can create structs that are ultra fast to serialize to / deserialize from mmaped memory. This way, small pieces of Rust code can be written as:

fn main() {
  load_env("somefile.bin");
  do rust tasks;
  save_env("somefile.bin");
}

This is not quite a repl, but if the serialization/serialization is fast enough, we get environments 'for free'