This week is about memory-mapped file manipulation in Rust.
Success Condition
cargo run mine.dat init # Create database mine.datcargo run mine.dat add 1 3 # Add the edge (1,3) to mine.datcargo run mine.dat add 6 7 # Add the edge (6,7) to mine.datcargo run mine.dat show # Show the contents of mine.dat
This should produce
1,3
6,7
Key Crates
There are two crates that you’ll need to understand:
memmap2: Uses virtual memory to map a file into memory
zerocopy: Utilities to reinterpret raw bytes (e.g. from a mapped file) as Rust data types, and to go the other way.
At the end of the hour run cargo package and submit the crate file as a group on Gradescope (I will grade based on whether the crate builds and the “hello world” test from the first slide works).