Skip to main content

Crate mf2_catalog

Crate mf2_catalog 

Source
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:

PartFeatureSide
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_hashmanifestbuild
writer — writer::catalog, writer::singlewriterbuild
decode() — the model-rebuilding decoder (for tests)decodebuild
content_hash — the hash in a catalog’s file namecontent-hashbuild, 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 .mf2b catalog (F2): the fetched buffer and the offsets new found. Share it as Rc<Catalog> / Arc<Catalog>.
CldrVersion
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§

CatalogError
Why crate::Catalog::new rejected a buffer (F4, F6, F9).
Dir
Text direction.
ManifestErrormanifest
Why a manifest file (manifest.mf2m) or value was rejected.
WriteErrorwriter
Why the writer refused a catalog (plans/02-catalog-format.md §2.9).

Constants§

CONTENT_HASH_LENcontent-hash
The number of hex digits of content_hash: the first 8 bytes of the SHA-256.

Functions§

content_hashcontent-hash
The first 16 lowercase hex digits of SHA-256 over a catalog’s bytes.