|
|
|
|
|
by pornel
1614 days ago
|
|
The exact same approach as C is doing is possible in Rust. There are pointer casts and mem::transmute(). It does require unsafe, since you must be aware of gotchas with alignment, padding, and uninitialized memory. If you want to be fancy, there's https://lib.rs/rkyv deserialization framework that will auto-generate appropriate zero-copy code for you. There's also serde (de)serialization framework and bincode format, which aren't exactly zero-copy, but are fast 1-copy. |
|