Expand description
Read-first LevelDB access for Minecraft Bedrock world databases.
bedrock-leveldb can read native Bedrock/LevelDB table, manifest, and WAL
files and exposes lazy point lookups plus visitor-based scans over raw byte
keys and values. The write path appends standard LevelDB write batches to
WAL files and flushes native .ldb tables plus native manifest edits, while
older crate-specific BWLDB... files remain readable for migration.
§Logging
The crate emits low-noise diagnostics through the log facade at
trace, debug, and warn levels. It never installs a global logger and
never writes to stdout or stderr; applications decide whether to connect
env_logger, log4rs, tracing-log, or another logging backend.
§Errors
Errors are returned as LevelDbError. Prefer matching
ErrorKind through LevelDbError::kind and using
LevelDbError::path for path-aware recovery instead of parsing display
strings.
§Bedrock Record Helpers
The crate includes small helpers for Bedrock LevelDB record keys and legacy
terrain payload families. These helpers parse documented storage bytes such
as LegacyTerrain and pre-paletted SubChunkPrefix values, but they do not
interpret NBT, actors, players, or gameplay semantics.
§Features
docs.rs builds this crate with all features enabled. Default builds enable
zlib, snappy, and async. Optional mmap exposes read-only mapped
table scans, while repair-tools and bench are reserved for tooling and
benchmark-only paths.
§Example
use bedrock_leveldb::{Db, OpenOptions, VisitorControl};
let dir = tempfile::tempdir()?;
let db = Db::open(dir.path(), OpenOptions::default())?;
db.put(b"player_1".as_slice(), b"value".as_slice(), Default::default())?;
assert_eq!(db.get(b"player_1")?.as_deref(), Some(b"value".as_slice()));
db.for_each_key(Default::default(), |_key| Ok(VisitorControl::Continue))?;Structs§
- Chunk
Coordinates - Chunk coordinates from a Bedrock chunk key.
- Chunk
Key - Parsed Bedrock chunk key.
- Db
- Open database handle.
- DbStats
- Fast or full database statistics.
- Entry
Ref - Raw key/value entry view used by visitor-based scans.
- KeyRef
- Borrowed or shared key view returned by zero-copy-oriented APIs.
- Legacy
Biome Sample - A decoded legacy biome column sample from the 1024-byte
LegacyTerrainbiome tail. - Legacy
SubChunk - Parsed pre-paletted 16x16x16 subchunk value.
- Legacy
Terrain - Parsed legacy 16x128x16 terrain value.
- Open
Options - Options used when opening a database directory.
- Prefix
Iterator - Materialized iterator over raw key/value pairs with one prefix.
- RawIterator
- Materialized iterator over raw key/value pairs.
- Read
Options - Per-read behavior for point lookups and scans.
- Repair
Report - Summary returned by
Db::repair. - Scan
Cancel Flag - Shared cooperative cancellation flag for long scans.
- Scan
Outcome - Aggregate information returned after a scan.
- Scan
Pipeline Options - Bounded pipeline policy used by table scans.
- Scan
Progress - Progress sample emitted during scans.
- Scan
Progress Sink - Callback sink for scan progress.
- Snapshot
- Materialized, immutable view of the database at one sequence.
- SubChunk
Index - Subchunk index stored after a
SubChunkPrefixchunk key tag. - Write
Batch - LevelDB-compatible write batch payload used by the WAL overlay.
- Write
Options - Options used when writing to the overlay and WAL.
Enums§
- Bedrock
Key - Parsed Bedrock
LevelDBkey. - Cache
Policy - Cache behavior for a read operation.
- Checksum
Mode - Checksum behavior for a read operation.
- Chunk
Record Tag - Bedrock chunk record tag.
- Compression
Policy - Compression used when this crate writes native
LevelDBtable blocks. - Dimension
- Dimension encoded in a Bedrock chunk key.
- Error
Kind - Stable category for a
LevelDbError. - Level
DbError - Errors returned while opening, reading, writing, or repairing a database.
- Read
Strategy - Value ownership strategy for point reads and visitor callbacks.
- Scan
Mode - Scan execution mode.
- SubChunk
Payload - Parsed 16x16x16 subchunk value.
- Threading
Options - How many worker threads a table-parallel scan may use.
- Value
Ref - Value view used by borrowed-first read APIs.
- Visitor
Control - Visitor result used by scan callbacks.
- WriteOp
- One operation inside a
WriteBatch.
Constants§
- LEGACY_
SUBCHUNK_ MIN_ VALUE_ LEN - Byte length of a legacy subchunk value without light arrays.
- LEGACY_
SUBCHUNK_ WITH_ LIGHT_ VALUE_ LEN - Byte length of a legacy subchunk value with sky-light and block-light arrays.
- LEGACY_
TERRAIN_ BLOCK_ COUNT - Number of block positions in a legacy 16x128x16 chunk terrain record.
- LEGACY_
TERRAIN_ VALUE_ LEN - Total byte length of a
LegacyTerrainvalue. - SUBCHUNK_
BLOCK_ COUNT - Number of block positions in one 16x16x16 subchunk.
Type Aliases§
- Result
- Crate-wide result type.