pub struct Catalog { /* private fields */ }Expand description
A validated .mf2b catalog (F2): the fetched buffer and the offsets
new found. Share it as Rc<Catalog> / Arc<Catalog>.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn new(
bytes: Vec<u8>,
expect_manifest: u64,
) -> Result<Catalog, CatalogError>
pub fn new( bytes: Vec<u8>, expect_manifest: u64, ) -> Result<Catalog, CatalogError>
Takes ownership of a fetched .mf2b buffer and validates its
structure once: magic, version (F9), manifest_hash (F6), the section
table, INDEX bounds and monotonicity, and the NAMES, FUNCS, FALLBACK,
LOCALE (with its plural entries) and IDS tables. Strings are checked
when read (F4). Linear in the buffer; allocates nothing; no copy (F2).
Sourcepub fn from_static(
bytes: &'static [u8],
expect_manifest: u64,
) -> Result<Catalog, CatalogError>
Available on crate feature static-bytes only.
pub fn from_static( bytes: &'static [u8], expect_manifest: u64, ) -> Result<Catalog, CatalogError>
static-bytes only.As Catalog::new, over bytes that live as long as the program —
a catalog embedded with include_bytes! — without copying them
(feature static-bytes).
Sourcepub fn manifest_hash(&self) -> u64
pub fn manifest_hash(&self) -> u64
The manifest hash this catalog was compiled against (F6).
Sourcepub fn cldr_version(&self) -> Option<CldrVersion>
pub fn cldr_version(&self) -> Option<CldrVersion>
The CLDR version of the locale data, if any.
Sourcepub fn message_count(&self) -> u32
pub fn message_count(&self) -> u32
The number of ids in the manifest (INDEX entries).
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Gives the buffer back (a copy, for a catalog over static bytes).