pub trait ChunkStore:
Debug
+ Send
+ Sync {
// Required methods
fn store(&self, chunk_idx: IVec3, vxl: &Vxl, version: u64);
fn load(&self, chunk_idx: IVec3) -> Option<(Vxl, u64)>;
}Expand description
Pluggable persistence for edited streamed chunks (QE.5a).
The ChunkGenerator contract makes evict + re-stream sound for
pristine chunks (generation is deterministic), but an edited
chunk (chunk_version != 0 — the player dug, built, or a bake
wrote into it) would silently revert to generator output when the
camera walks away and comes back. A ChunkStore closes that hole:
- Eviction (
crate::Scene::pump_streaming/pump_streaming_sync): every evicted chunk whose version is non-zero is handed tostorebefore it is dropped. - Stream-in: before running the generator for a missing chunk,
the streaming layer asks
load; a hit installs the stored chunk (with its persisted edit version) and the generator is not called. A stored chunk wins even whereChunkGenerator::should_generatedeclines the index (edits can materialise chunks the generator never would).
Implementations own the actual storage — an in-memory map, a
save-file region, a database. load runs on the streaming pool’s
background threads under crate::Scene::pump_streaming (so
blocking IO is fine there) but inline under the synchronous
paths (pump_streaming_sync
/ Grid::ensure_chunk_generated);
store always runs inline during the eviction pass — keep it
cheap (e.g. queue bytes for a writer thread).
Note crate::Scene::to_snapshot serialises only materialised
chunks — chunks living solely in the store are the host’s to save
alongside the snapshot.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".