Skip to main content

Crate mdictlib

Crate mdictlib 

Source
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.
KeyIndexBuild
Result of writing one complete persistent key index.
KeyIndexOptions
Limits and scratch placement for persistent key-index construction and use.
KeyIndexSourceIdentity
Lightweight source identity bound into a persistent key index.
KeyMatchPage
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 .mdd resource files.
MddFile
An opened MDD resource dictionary.
MddResource
One materialized MDD resource with its physical identity.
MddResourceSpan
A source-bound, lazily readable MDD resource span.
MdxBuilder
Builder for plaintext MDict version 2 .mdx dictionaries.
MdxEntry
One decoded MDX entry with its physical identity.
MdxFile
An opened MDX text dictionary.
MemoryUsage
Accounted parser memory for one open dictionary at a point in time.
OpenOptions
Options used when opening an MDX or MDD file.
Passcode
Passcode material for dictionaries with an encrypted keyword header.
WriteOptions
Options controlling how a builder emits a dictionary.
WriteSummary
What a builder wrote, in physical output terms.

Enums§

ChecksumPolicy
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.
KeyIndexRejection
Structured reason why a persistent key index could not be trusted.
MatchBasis
Describes why a key query matched physical dictionary entries.
MatchMode
Controls whether an MDX query also returns differently cased headwords.
WriteCompression
Block compression applied to every emitted key and record block.
WriteEncoding
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 source with edits applied and emits the replacement dictionary to out.
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 mdictlib operations.