Skip to main content

Crate faf_fafb

Crate faf_fafb 

Source
Expand description

faf-fafb — FAFb v2, the compiled binary form of .faf.

IFF-inspired chunked binary: a string table for section names, a section table at the end for O(1) random access, classification bits (DNA / Context / Pointer), priority-based truncation, and a CRC32 seal over the source .faf.

Closed canonical. The writer emits exactly the canonical chunk set (see canon), in canonical order; non-canonical top-level keys fold into the context chunk. Identical content produces byte-identical output regardless of input key order — so a .fafb is content-addressable: the same project context yields the same hash, everywhere. The reader keeps the IFF rule (skip unknown section names gracefully), so a future minor version can add a chunk without breaking deployed readers.

v2 only. FAFb v1 is pre-release history and is rejected on read (IncompatibleVersion) — re-compile from the .faf source, which is always the source of truth.

Stability — FAFb wire v2 is frozen. The byte layout is immutable, enforced by a byte-exact golden-master test in this crate (compile() must reproduce the vendored .fafb byte-for-byte; any structural change is caught immediately). New capabilities ship only as forward-compatible additions — chunks or flag bits older readers skip; we do not break v2. Because the .faf source is always authoritative, you recompile, never migrate — nothing gets trapped in an old binary.

§Usage

use faf_fafb::{compile, decompile, CompileOptions};

let yaml = "faf_version: 2.5.0\nproject:\n  name: my-project\n";
let opts = CompileOptions { use_timestamp: false };
let bytes = compile(yaml, &opts).unwrap();
let result = decompile(&bytes).unwrap();
let name = result.get_section_string_by_name("project").unwrap();
assert!(name.contains("my-project"));

Re-exports§

pub use canon::CANONICAL_CHUNKS;
pub use canon::CLASSIFICATION_MASK;
pub use canon::CanonicalChunk;
pub use canon::ChunkClassification;
pub use canon::canonical_chunk;
pub use canon::is_canonical;
pub use compile::CompileOptions;
pub use compile::DecompiledFafb;
pub use compile::compile;
pub use compile::decompile;
pub use error::FafbError;
pub use error::FafbResult;
pub use flags::FLAG_COMPRESSED;
pub use flags::FLAG_EMBEDDINGS;
pub use flags::FLAG_MODEL_HINTS;
pub use flags::FLAG_RESOLVED;
pub use flags::FLAG_SIGNED;
pub use flags::FLAG_STRING_TABLE;
pub use flags::FLAG_TOKENIZED;
pub use flags::FLAG_WEIGHTED;
pub use flags::Flags;
pub use header::FafbHeader;
pub use header::HEADER_SIZE;
pub use header::MAGIC;
pub use header::MAGIC_U32;
pub use header::MAX_FILE_SIZE;
pub use header::MAX_SECTIONS;
pub use header::VERSION_MAJOR;
pub use header::VERSION_MINOR;
pub use priority::PRIORITY_CRITICAL;
pub use priority::PRIORITY_HIGH;
pub use priority::PRIORITY_LOW;
pub use priority::PRIORITY_MEDIUM;
pub use priority::PRIORITY_OPTIONAL;
pub use priority::Priority;
pub use section::SECTION_ENTRY_SIZE;
pub use section::SectionEntry;
pub use section::SectionTable;
pub use string_table::StringTable;

Modules§

canon
The canonical chunk table — FAFb v2 is CLOSED CANONICAL.
compile
Compile/decompile API for .faf ↔ .fafb conversion — FAFb v2, closed canonical.
error
FAFB Error Types
flags
FAFB Feature Flags
header
FAFB Header Implementation
priority
FAFB Priority System
section
FAFB Section Entry and Section Table
string_table
FAFb v2 String Table

Constants§

VERSION
Library version