Skip to content

Commit 7e05854

Browse files
committed
docs: complete crates.io API documentation
1 parent 1c8d651 commit 7e05854

17 files changed

Lines changed: 908 additions & 25 deletions

.github/workflows/publish.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ jobs:
5555
run: cargo test --no-default-features
5656
- name: Docs
5757
run: cargo doc --all-features --no-deps
58+
- name: Public API docs
59+
run: cargo rustdoc --all-features -- -D missing_docs
5860
- name: Dry run
5961
run: cargo publish --dry-run
60-
- name: Publish
61-
env:
62-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
63-
run: cargo publish --no-verify
62+
# Publishing is intentionally disabled until the release owner configures
63+
# crates.io publishing outside this repository.
64+
# - name: Publish
65+
# env:
66+
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
67+
# run: cargo publish --no-verify

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ All notable changes to `bedrock-world` are tracked here.
66

77
### Changed
88

9+
- Added docs.rs all-features metadata, crate-level feature guidance, and
10+
README sections describing hosted docs, feature behavior, and package
11+
contents.
12+
- Added complete public API rustdoc coverage and enabled the release workflow's
13+
missing-docs gate for all-feature rustdoc builds.
914
- Prepared the crate for publishing by removing `publish = false` and declaring
1015
the optional `bedrock-leveldb` backend as a versioned `0.2.1` dependency while
1116
retaining the local `../bedrock-leveldb` path for repository development.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ include = [
3030
name = "bedrock_world"
3131
path = "src/bedrock_world.rs"
3232

33+
[package.metadata.docs.rs]
34+
all-features = true
35+
3336
[features]
3437
default = ["async", "backend-bedrock-leveldb"]
3538
async = ["dep:tokio"]

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,32 @@ This crate focuses on complete parsing behavior. The
3131
`db/CURRENT` worlds as LevelDB, marks early `StorageVersion <= 4` worlds as
3232
`WorldFormat::LevelDbLegacyTerrain`, and opens pre-LevelDB `chunks.dat` worlds
3333
as `WorldFormat::PocketChunksDat`.
34+
- `OpenOptions::default()` is read-only. Any world-record write must reopen the
35+
world with `OpenOptions { read_only: false, ..OpenOptions::default() }`.
36+
Read-only worlds return `BedrockWorldErrorKind::ReadOnly` from high-level
37+
writes before touching storage.
3438
- Use category APIs for UI and tools:
3539
`classify_keys_blocking`, `list_players_blocking`,
3640
`list_chunk_positions_blocking`, `parse_chunk_blocking`,
3741
`parse_subchunk_blocking`, `scan_entities_blocking`,
3842
`scan_block_entities_blocking`, `scan_items_blocking`, `scan_maps_blocking`,
3943
`scan_villages_blocking`, and `scan_globals_blocking`.
40-
- Use typed v0.2 edit APIs for BedrockLevelFormat records:
41-
`read_map_record_blocking`, `scan_map_records_blocking`,
42-
`write_map_record_blocking`, `read_global_record_blocking`,
43-
`scan_global_records_blocking`, `put_hsa_for_chunk_blocking`,
44-
`block_entities_in_chunk_blocking`, `edit_block_entity_at_blocking`,
45-
`actors_in_chunk_blocking`, and `put_actor_blocking`.
44+
- Use typed v0.2 BedrockLevelFormat write APIs on a writable world:
45+
`write_map_record_blocking`, `delete_map_record_blocking`,
46+
`write_global_record_blocking`, `delete_global_record_blocking`,
47+
`put_heightmap_blocking`, `put_biome_storage_blocking`,
48+
`put_hsa_for_chunk_blocking`, `delete_hsa_for_chunk_blocking`,
49+
`put_block_entities_blocking`, `edit_block_entity_at_blocking`,
50+
`delete_block_entity_at_blocking`, `put_actor_blocking`,
51+
`delete_actor_blocking`, and `move_actor_blocking`. Matching async wrappers
52+
are available behind the default `async` feature.
53+
- High-level writes serialize and parse records back before commit. Actor writes
54+
update `digp -> actorprefix` records in one transaction. Block-entity writes
55+
validate coordinates against the target chunk. `PocketChunksDatStorage`
56+
remains read-only.
57+
- `bedrock-world` stops at Bedrock key/value semantics. Post-write refresh,
58+
invalidation, and presentation policy belong to downstream applications or
59+
adapter crates.
4660
- Async wrappers use `tokio::task::spawn_blocking`, so disk and decode work does
4761
not block the foreground async runtime.
4862
- `WorldScanOptions` controls threading, cancellation, and progress callbacks.
@@ -275,6 +289,22 @@ Latest local Criterion and large-fixture results are tracked in
275289
is intentionally separate from Criterion because multi-million-entry scans
276290
should not be repeated inside microbenchmarks.
277291

292+
## Features And docs.rs
293+
294+
docs.rs builds with all features enabled, so the hosted API reference includes
295+
async wrappers and the optional `bedrock-leveldb` backend.
296+
297+
| Feature | Default | Meaning |
298+
| --- | --- | --- |
299+
| `async` | yes | Adds async wrappers that delegate blocking filesystem, LevelDB, and NBT work to `tokio::task::spawn_blocking` |
300+
| `backend-bedrock-leveldb` | yes | Enables opening native Bedrock LevelDB worlds through `bedrock-leveldb` |
301+
| `leveldb-mmap` | no | Enables the backend and forwards the `bedrock-leveldb/mmap` feature |
302+
303+
Disable default features when a tool only needs pure parsing, in-memory storage,
304+
`level.dat`, or NBT helpers. The crates.io package includes the English and
305+
Chinese READMEs, guide documents under `docs/`, the changelog, licenses,
306+
source, tests, fixture documentation, and benchmarks.
307+
278308
## Completeness
279309

280310
| Area | Status |

README.zh-CN.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,29 @@ terrain record 的 chunk/subchunk 解析、实体和方块实体解析、物品
1919
时打开 LevelDB,`StorageVersion <= 4` 的早期世界会标记为
2020
`WorldFormat::LevelDbLegacyTerrain`;只有 `chunks.dat` 时打开
2121
`WorldFormat::PocketChunksDat`
22+
- `OpenOptions::default()` 是只读模式。任何世界记录写入都必须用
23+
`OpenOptions { read_only: false, ..OpenOptions::default() }` 重新打开
24+
world。只读 world 的高层写入会在访问 storage 前返回
25+
`BedrockWorldErrorKind::ReadOnly`
2226
- UI 和工具应优先使用分类 API:
2327
`classify_keys_blocking``list_players_blocking`
2428
`list_chunk_positions_blocking``parse_chunk_blocking`
2529
`parse_subchunk_blocking``scan_entities_blocking`
2630
`scan_block_entities_blocking``scan_items_blocking``scan_maps_blocking`
2731
`scan_villages_blocking``scan_globals_blocking`
28-
- BedrockLevelFormat 记录编辑使用 v0.2 typed API:
29-
`read_map_record_blocking``scan_map_records_blocking`
30-
`write_map_record_blocking``read_global_record_blocking`
31-
`scan_global_records_blocking``put_hsa_for_chunk_blocking`
32-
`block_entities_in_chunk_blocking``edit_block_entity_at_blocking`
33-
`actors_in_chunk_blocking``put_actor_blocking`
32+
- BedrockLevelFormat 记录写入使用 v0.2 typed API,并且必须在可写 world 上执行:
33+
`write_map_record_blocking``delete_map_record_blocking`
34+
`write_global_record_blocking``delete_global_record_blocking`
35+
`put_heightmap_blocking``put_biome_storage_blocking`
36+
`put_hsa_for_chunk_blocking``delete_hsa_for_chunk_blocking`
37+
`put_block_entities_blocking``edit_block_entity_at_blocking`
38+
`delete_block_entity_at_blocking``put_actor_blocking`
39+
`delete_actor_blocking``move_actor_blocking`。默认 `async` feature 下有同名 async wrapper。
40+
- 高层写入会先 serialize,再 parse 回来校验,然后才提交。actor 写入在一个 transaction
41+
中同步维护 `digp -> actorprefix`;方块实体写入会校验坐标仍属于目标 chunk。
42+
`PocketChunksDatStorage` 继续只读。
43+
- `bedrock-world` 只负责 Bedrock key/value 语义。写入后的刷新、失效和展示策略属于
44+
下游应用或适配 crate。
3445
- async wrapper 使用 `tokio::task::spawn_blocking`,磁盘 I/O 和解析不会阻塞前台 async runtime。
3546
- `WorldScanOptions` 控制线程、取消和进度回调。
3647
- `WorldPipelineOptions` 进一步控制有界 pipeline 的队列深度、chunk batch 大小、
@@ -229,6 +240,21 @@ players.count=290
229240
[`docs/BENCHMARKS.md`](docs/BENCHMARKS.md)。大型 fixture harness 与 Criterion
230241
分离,因为多百万 entry 扫描不应该在 microbenchmark 中反复运行。
231242

243+
## Features 和 docs.rs
244+
245+
docs.rs 会启用全部 features 构建,因此托管 API 文档会包含 async wrapper 和可选的
246+
`bedrock-leveldb` 后端。
247+
248+
| Feature | 默认 | 含义 |
249+
| --- | --- | --- |
250+
| `async` || 添加 async wrapper,并把阻塞的文件系统、LevelDB 和 NBT 工作交给 `tokio::task::spawn_blocking` |
251+
| `backend-bedrock-leveldb` || 通过 `bedrock-leveldb` 打开原生 Bedrock LevelDB 世界 |
252+
| `leveldb-mmap` || 启用后端并转发 `bedrock-leveldb/mmap` feature |
253+
254+
只需要纯解析、内存 storage、`level.dat` 或 NBT helper 的工具可以关闭默认 features。
255+
crates.io 包包含英文/中文 README、`docs/` 下的指南、changelog、许可证、源码、
256+
测试、fixture 文档和 benchmark。
257+
232258
## 完整度
233259

234260
| 范围 | 状态 |

docs/API.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ bytes by parsing them back before replacing the file.
2222

2323
`BedrockWorld::open(path, OpenOptions::default())` opens a world in read-only
2424
mode and auto-detects `db/CURRENT` LevelDB worlds or old Pocket Edition
25-
`chunks.dat` worlds. `BedrockWorld::open_blocking` exposes the same detection
26-
for CLI tools and examples. Use targeted APIs instead of full-world parsing for
27-
UI flows:
25+
`chunks.dat` worlds. Open with `OpenOptions { read_only: false, ..Default::default() }`
26+
only for explicit edit flows; high-level writes call `ensure_writable` and
27+
return `BedrockWorldErrorKind::ReadOnly` on read-only handles before any storage
28+
mutation. `BedrockWorld::open_blocking` exposes the same detection for CLI tools
29+
and examples. Use targeted APIs instead of full-world parsing for UI flows:
2830

2931
- `list_players_blocking`
3032
- `classify_keys_blocking`
@@ -154,7 +156,10 @@ old 82,176-byte `chunks.dat` terrain payload to an 83,200-byte virtual
154156
v0.2 adds typed APIs for BedrockLevelFormat records that map editors usually
155157
need without forcing a full-world parse. The storage boundary remains raw
156158
key/value: `bedrock-world` owns Bedrock key classification, NBT codecs,
157-
coordinate validation, and write roundtrip checks.
159+
coordinate validation, and write roundtrip checks. This crate does not decide
160+
how callers refresh or invalidate their presentation state after a write;
161+
downstream applications and adapter crates map these semantic writes to their
162+
own update model.
158163

159164
Key helpers:
160165

@@ -195,7 +200,17 @@ Chunk payload helpers:
195200
All high-level writes validate the serialized value by parsing it back before
196201
committing. Actor writes update `actorprefix` and `digp` in one transaction.
197202
Block-entity writes reject coordinates outside the target chunk. `chunks.dat`
198-
backends stay read-only.
203+
backends stay read-only. Write examples should therefore open a writable world:
204+
205+
```rust
206+
let world = bedrock_world::BedrockWorld::open_blocking(
207+
"world",
208+
bedrock_world::OpenOptions {
209+
read_only: false,
210+
..bedrock_world::OpenOptions::default()
211+
},
212+
)?;
213+
```
199214

200215
## Parsing Modes
201216

docs/TESTING.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ block, overlay/water context when present, and
4343
`RenderLoadStats::raw_height_mismatch_columns` is non-zero. Raw heightmap
4444
behavior belongs in `RenderChunkRequest::RawHeightMap` tests.
4545

46+
Typed write tests should cover the storage-layer contract only:
47+
48+
- `OpenOptions::default()` remains read-only and every high-level write returns
49+
`BedrockWorldErrorKind::ReadOnly` before mutating storage.
50+
- Writable worlds are opened with
51+
`OpenOptions { read_only: false, ..OpenOptions::default() }`.
52+
- map/global/HSA/heightmap/biome/block-entity writes serialize, parse back, and
53+
read back with semantic equivalence.
54+
- actor writes update `digp -> actorprefix` records in one transaction.
55+
- `PocketChunksDatStorage` rejects `put`, `delete`, and batch writes.
56+
57+
Do not add presentation-layer invalidation assertions here. Post-write refresh
58+
and scheduling behavior is a downstream responsibility.
59+
4660
## Benchmarks
4761

4862
Run the v0.2 benchmark set with:

src/bedrock_world.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111
//! [`BedrockWorld::parse_chunk_blocking`], or [`BedrockWorld::scan_items_blocking`].
1212
//! Async wrappers use `tokio::task::spawn_blocking` so `LevelDB` and NBT work does
1313
//! not run on foreground async tasks.
14+
//!
15+
//! # Features
16+
//!
17+
//! docs.rs builds this crate with all features enabled. Default builds enable
18+
//! `async` and the `bedrock-leveldb` backend. Disable default features for
19+
//! pure parsing, in-memory storage, `level.dat`, and NBT workflows that should
20+
//! not depend on a database backend.
1421
22+
#![deny(missing_docs)]
1523
#![allow(
1624
clippy::cast_possible_truncation,
1725
clippy::cast_possible_wrap,

0 commit comments

Comments
 (0)