Read, query, write, and merge the Erigon 3 seg state file format: .kv (seg-compressed words), .bt (B-tree / Elias-Fano index), and .kvei (existence/bloom filter).
//! Small shared helpers.
usestd::path::Path;usememmap2::Mmap;usecrate::error::{Error,Result};/// Read-only memory-map of a file, treated as immutable for the map's lifetime.
pub(crate)fnmmap_file(path:&Path)->Result<Mmap>{let f =std::fs::File::open(path).map_err(|e|Error::io(path, e))?;// SAFETY: we only ever read through the map and document that callers must not
// mutate the underlying file while a reader is open. memmap2 requires `unsafe`
// here purely because that invariant cannot be expressed in the type system.
#[allow(unsafe_code)]let mmap =unsafe{Mmap::map(&f)}.map_err(|e|Error::io(path, e))?;Ok(mmap)}