Skip to main content

faf_rust_sdk/binary/
mod.rs

1//! FAFB Binary Format — Unified Specification
2//!
3//! Compiles human-readable .faf (YAML) to AI-optimized binary.
4//! String table for unlimited section names, classification bits for DNA/Context/Pointer.
5//!
6//! ## Features
7//!
8//! - **O(1) section lookup** - Section table at end for instant access
9//! - **Priority truncation** - Smart context window management
10//! - **Pre-computed tokens** - No runtime estimation
11//! - **String table** - Unlimited section names (up to 256)
12//! - **Classification** - DNA / Context / Pointer chunk types
13//!
14//! ## Usage
15//!
16//! ```ignore
17//! use faf_rust_sdk::binary::{compile, decompile, CompileOptions};
18//!
19//! let yaml = "faf_version: 2.5.0\nproject:\n  name: my-project\n";
20//! let opts = CompileOptions { use_timestamp: false };
21//! let bytes = compile(yaml, &opts).unwrap();
22//! let result = decompile(&bytes).unwrap();
23//! let name = result.get_section_string_by_name("project").unwrap();
24//! ```
25//!
26//! See FAFB-SPEC-UNIFIED.md for full specification.
27
28pub mod chunk_registry;
29pub mod compile;
30pub mod error;
31pub mod flags;
32pub mod header;
33pub mod priority;
34pub mod section;
35pub mod section_type;
36pub mod string_table;
37
38// Re-exports for convenience
39pub use chunk_registry::{
40    classify_key, ChunkClassification, CLASSIFICATION_MASK, DNA_KEYS, POINTER_KEY,
41};
42pub use compile::{compile, decompile, CompileOptions, DecompiledFafb};
43pub use error::{FafbError, FafbResult};
44pub use flags::{
45    Flags, FLAG_COMPRESSED, FLAG_EMBEDDINGS, FLAG_MODEL_HINTS, FLAG_RESOLVED, FLAG_SIGNED,
46    FLAG_STRING_TABLE, FLAG_TOKENIZED, FLAG_WEIGHTED,
47};
48pub use header::{
49    FafbHeader, HEADER_SIZE, MAGIC, MAGIC_U32, MAX_FILE_SIZE, MAX_SECTIONS, VERSION_MAJOR,
50    VERSION_MINOR,
51};
52pub use priority::{
53    Priority, PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_MEDIUM, PRIORITY_OPTIONAL,
54};
55pub use section::{SectionEntry, SectionTable, SECTION_ENTRY_SIZE};
56pub use section_type::{
57    SectionType, SECTION_ARCHITECTURE, SECTION_BISYNC, SECTION_COMMANDS, SECTION_CONTEXT,
58    SECTION_CUSTOM, SECTION_EMBEDDINGS, SECTION_KEY_FILES, SECTION_META, SECTION_MODEL_HINTS,
59    SECTION_TECH_STACK, SECTION_TOKEN_MAP,
60};
61pub use string_table::StringTable;