- Library entrypoint in
src/lib.rswith shared traits insrc/traits.rs; format parsers live insrc/dict/(mdict, stardict, zim, bgl, dsl). - Indexing code is in
src/index/; compression/encoding and test helpers live insrc/util/. - Tests sit in
src/tests/(unit, integration, concurrent, performance, error, utils); examples inexamples/; C++ reference implementations inreferences/. Keep build output intarget/out of git.
cargo buildorcargo build --all-featurescompile the crate;cargo doc --all-features --no-depsinspects APIs.cargo testruns the suite; add--features criterion performance_testsfor perf harnesses;cargo bench --all-featureswhen Criterion is installed.cargo fmt --checkandcargo clippy --all-targets --all-features -D warningsgate PRs; runcargo auditwhen available;cargo run --example basic_dict_loadingfor a quick demo.
- Rust 2021 with rustfmt defaults (4-space indent, trailing commas); keep modules small and document invariants where they are not obvious.
- Module/file names stay snake_case; types/traits in UpperCamelCase; functions/variables snake_case; feature flags match
Cargo.toml(cli,rayon,high_performance). - Use the shared
Result<T>/DictErrorfromtraits.rs; prefer?andFromconversions instead of manual error mapping.
- Existing tests rely on mock dictionaries from
util::test_utils; when changing parsers or index bounds add fixtures with real dictionaries (seeTASKS.md). - Add new cases under
src/tests/with descriptive names (e.g.,should_validate_offsets); extend concurrent/performance suites for threading or timing-sensitive work. - Use
cargo test -- --nocapturefor debugging; property-style cases can useproptestto exercise malformed headers and compression windows.
- Commit subjects should be short, imperative, and optionally scoped (
dict: tighten offset checks,tests: add mdict fixture); never committarget/or generated binaries. - PRs need a problem/solution summary, linked issue or task, commands run, and notes on fixture coverage or benchmark deltas; add screenshots only when CLI output changes materially.
- Project remains experimental; parsers still lean on placeholder builders, so treat outputs as non-production and avoid trusting unvetted dictionaries.
- For format/compression changes, add offset/length validation, sanitize CLI/log output, and test against corrupted fixtures; run
cargo auditbefore releases.