Skip to main content

Crate bedrock_leveldb

Crate bedrock_leveldb 

Source
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§

ChunkCoordinates
Chunk coordinates from a Bedrock chunk key.
ChunkKey
Parsed Bedrock chunk key.
Db
Open database handle.
DbStats
Fast or full database statistics.
EntryRef
Raw key/value entry view used by visitor-based scans.
KeyRef
Borrowed or shared key view returned by zero-copy-oriented APIs.
LegacyBiomeSample
A decoded legacy biome column sample from the 1024-byte LegacyTerrain biome tail.
LegacySubChunk
Parsed pre-paletted 16x16x16 subchunk value.
LegacyTerrain
Parsed legacy 16x128x16 terrain value.
OpenOptions
Options used when opening a database directory.
PrefixIterator
Materialized iterator over raw key/value pairs with one prefix.
RawIterator
Materialized iterator over raw key/value pairs.
ReadOptions
Per-read behavior for point lookups and scans.
RepairReport
Summary returned by Db::repair.
ScanCancelFlag
Shared cooperative cancellation flag for long scans.
ScanOutcome
Aggregate information returned after a scan.
ScanPipelineOptions
Bounded pipeline policy used by table scans.
ScanProgress
Progress sample emitted during scans.
ScanProgressSink
Callback sink for scan progress.
Snapshot
Materialized, immutable view of the database at one sequence.
SubChunkIndex
Subchunk index stored after a SubChunkPrefix chunk key tag.
WriteBatch
LevelDB-compatible write batch payload used by the WAL overlay.
WriteOptions
Options used when writing to the overlay and WAL.

Enums§

BedrockKey
Parsed Bedrock LevelDB key.
CachePolicy
Cache behavior for a read operation.
ChecksumMode
Checksum behavior for a read operation.
ChunkRecordTag
Bedrock chunk record tag.
CompressionPolicy
Compression used when this crate writes native LevelDB table blocks.
Dimension
Dimension encoded in a Bedrock chunk key.
ErrorKind
Stable category for a LevelDbError.
LevelDbError
Errors returned while opening, reading, writing, or repairing a database.
ReadStrategy
Value ownership strategy for point reads and visitor callbacks.
ScanMode
Scan execution mode.
SubChunkPayload
Parsed 16x16x16 subchunk value.
ThreadingOptions
How many worker threads a table-parallel scan may use.
ValueRef
Value view used by borrowed-first read APIs.
VisitorControl
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 LegacyTerrain value.
SUBCHUNK_BLOCK_COUNT
Number of block positions in one 16x16x16 subchunk.

Type Aliases§

Result
Crate-wide result type.