skip to content
< back
27 dec 2025

zero-copy deserialization

zero-copy deserialization doesn't convert bytes into values. instead, it reinterprets an existing byte buffer as a typed struct using a reference. the data is never copied; the struct is simply a view over raw memory. this is fast, but unsafe. the compiler assumes the bytes already satisfy all invariants of the type: correct layout, correct alignment, correct padding, and valid values. none of these are checked at runtime. if any assumption is violated—such as a misaligned `u64`—the behavior is undefined and may crash immediately on strict architectures like bpf. because of this, zero-copy is only viable when copying is too expensive and the memory layout is fully controlled. systems like blockchains, kernels, and databases rely on it to avoid copying large state, but they pay for it with rigid layouts, explicit byte fields, and heavy safety discipline.