Expand description
Library-first parser for MDict .mdx and .mdd files.
MDX and MDD share one defensive, file-backed parsing core. Opening parses bounded metadata and block indexes; key and record blocks remain lazy.
Physical ordinals preserve duplicate identity. By default, raw-exact lookup
wins before header-normalized fallback. MDX can opt into MatchMode to
include case variants after exact rows. MDD resources can be streamed through
source-bound spans. Per-open limits bound untrusted input and parser work.
MDX callers may optionally build a bounded, source-bound persistent key
index and reopen it through safe lazy positional reads; artifact placement
and publication remain caller-owned.
MDict wire checksum comparisons are controlled by ChecksumPolicy and
default to ChecksumPolicy::Skip for throughput; structural parsing and
decompression validation remain enabled.
Plaintext version 2 dictionaries can be created with MdxBuilder and
MddBuilder, and existing MDX files can be rebuilt with an EditSet
applied through rebuild_mdx. Open version 2 files can also be decoded
and re-encoded wholesale through reencode_mdx and reencode_mdd:
every block is decoded and re-emitted with the same structure, so
uncompressed sources come back byte-identical and zlib sources differ
only inside compressed streams.
§Wire versions
MDict major versions 1 and 2 are both read through this API. The version is resolved once, from the header, and selects one grammar; it never reaches lookup, iteration, ordinal access, record decoding, or MDD streaming. A file that fails one grammar is never retried under the other.
Version 1 support covers unencrypted files using uncompressed or LZO blocks. Encrypted version 1 files and the ISO8859-1 text label are refused with a precise error rather than parsed speculatively.
Structs§
- EditSet
- A set of edits to apply while rebuilding one MDX dictionary.
- Header
- Parsed top-level XML metadata from an MDict file.
- KeyEntry
- An original decoded key paired with its physical ordinal.
- KeyIndex
- Open, source-bound persistent key index.
- KeyIndex
Build - Result of writing one complete persistent key index.
- KeyIndex
Options - Limits and scratch placement for persistent key-index construction and use.
- KeyIndex
Source Identity - Lightweight source identity bound into a persistent key index.
- KeyMatch
Page - A bounded, duplicate-preserving window of physical key matches.
- KeyMatches
- A non-empty, duplicate-preserving set of physical key matches.
- KeyOrdinal
- Zero-based physical key ordinal within one unchanged dictionary file.
- Limits
- Per-open ceilings for file-derived reads, allocations, and retained work.
- MddBuilder
- Builder for plaintext MDict version 2
.mddresource files. - MddFile
- An opened MDD resource dictionary.
- MddResource
- One materialized MDD resource with its physical identity.
- MddResource
Span - A source-bound, lazily readable MDD resource span.
- MdxBuilder
- Builder for plaintext MDict version 2
.mdxdictionaries. - MdxEntry
- One decoded MDX entry with its physical identity.
- MdxFile
- An opened MDX text dictionary.
- Memory
Usage - Accounted parser memory for one open dictionary at a point in time.
- Open
Options - Options used when opening an MDX or MDD file.
- Passcode
- Passcode material for dictionaries with an encrypted keyword header.
- Write
Options - Options controlling how a builder emits a dictionary.
- Write
Summary - What a builder wrote, in physical output terms.
Enums§
- Checksum
Policy - Controls whether MDict wire checksums are calculated and compared.
- Error
- An error reported while configuring, opening, or reading an MDict file or its caller-managed persistent key index.
- KeyIndex
Rejection - Structured reason why a persistent key index could not be trusted.
- Match
Basis - Describes why a key query matched physical dictionary entries.
- Match
Mode - Controls whether an MDX query also returns differently cased headwords.
- Write
Compression - Block compression applied to every emitted key and record block.
- Write
Encoding - Text encoding used for MDX keys, key summaries, and record bodies.
Constants§
- KEY_
INDEX_ FORMAT_ REVISION - Stable on-disk key-index format revision.
- KEY_
INDEX_ NORMALIZATION_ REVISION - Stable header-controlled key-normalization revision encoded by a key index.
- KEY_
INDEX_ PARSER_ REVISION - Stable parser/layout compatibility revision encoded by a key index.
- KEY_
INDEX_ REVISION - Filesystem-safe aggregate revision for persistent key-index cache names.
Functions§
- rebuild_
mdx - Rebuilds
sourcewitheditsapplied and emits the replacement dictionary toout. - reencode_
mdd - Re-encodes an open MDD resource file under the same rules as
reencode_mdx. - reencode_
mdx - Re-encodes an open MDX dictionary: every block is decoded and re-emitted with the same structure and compression tag.
Type Aliases§
- Result
- Result type returned by
mdictliboperations.