Expand description
mf2-catalog — the .mf2b binary catalog of Rust MF2: one locale’s
messages and locale data, as a lossless encoding of the MF2 data model that the client reads in place.
An application meets one type of this crate: Catalog, a loaded
catalog, which mf2::leptos and mf2::axum load and serve for it and
which mf2_runtime’s formatter formats
from — with its errors (CatalogError, and on the build side
WriteError and ManifestError). Everything else here is the byte
format, which 1.x does not promise (docs/versioning.md: rebuild the
server and the client together), and is hidden from the documentation:
| Part | Feature | Side |
|---|---|---|
Catalog and its views (MsgView, …) — the reader | (always) | client: no_std, no allocation, no panics, no core::fmt |
number, currency, unit — views of the number.*, currency.data and unit.data LOCALE entries (mf2-fn-number reads them) | (always) | client, same rules |
Manifest — manifest.mf2m and manifest_hash | manifest | build |
writer — writer::catalog, writer::single | writer | build |
decode() — the model-rebuilding decoder (for tests) | decode | build |
content_hash — the hash in a catalog’s file name | content-hash | build, native |
The reader is client-path code: Catalog::new takes the fetched buffer
and validates its structure once, in linear time; every accessor is a
bounds-checked O(1) read that never panics; strings are checked as UTF-8
when read; nothing formats. StrRef is opaque and loading is one
function — the two seams kept for catalog text as JS strings.
The byte format is version 1; its constants are in format.
§The user guide
The Rust MF2 book is the user
guide: how the crates fit together, web and native applications, the
command line, and what 2.x promises.
An application starts at
mf2.
Structs§
- Catalog
- A validated
.mf2bcatalog (F2): the fetched buffer and the offsetsnewfound. Share it asRc<Catalog>/Arc<Catalog>. - Cldr
Version - The CLDR version of a catalog’s locale data.
- MsgId
- A message id: which message of a build’s catalogs.
tr!and the generated module make them; an application compares, hashes and passes them, and never builds one from a number.
Enums§
- Catalog
Error - Why
crate::Catalog::newrejected a buffer (F4, F6, F9). - Dir
- Text direction.
- Manifest
Error manifest - Why a manifest file (
manifest.mf2m) or value was rejected. - Write
Error writer - Why the writer refused a catalog (
plans/02-catalog-format.md§2.9).
Constants§
- CONTENT_
HASH_ LEN content-hash - The number of hex digits of
content_hash: the first 8 bytes of the SHA-256.
Functions§
- content_
hash content-hash - The first 16 lowercase hex digits of SHA-256 over a catalog’s bytes.