Skip to main content

faf_rust_sdk/binary/
mod.rs

1//! FAFB Binary Format
2//!
3//! Implementation of the .fafb binary format specification.
4//! Compiles human-readable .faf (YAML) to AI-optimized binary.
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//! - **Memory mapping ready** - Zero-copy loading design
12//!
13//! ## Usage
14//!
15//! ```ignore
16//! use faf_rust_sdk::binary::{FafbHeader, Flags, SectionEntry, SectionTable, SectionType, Priority};
17//!
18//! // Create a new header
19//! let mut header = FafbHeader::with_timestamp();
20//! header.set_source_checksum(yaml_content.as_bytes());
21//! header.section_count = 3;
22//!
23//! // Create section table
24//! let mut table = SectionTable::new();
25//! table.push(SectionEntry::new(SectionType::Meta, 32, 100));
26//! table.push(SectionEntry::new(SectionType::TechStack, 132, 200)
27//!     .with_priority(Priority::high()));
28//!
29//! // Budget-aware loading
30//! let sections = table.entries_within_budget(1000);
31//! ```
32//!
33//! ## Format Version
34//!
35//! Current: v1.0
36//!
37//! See FAFB-BINARY-SPEC.md for full specification.
38
39pub mod compile;
40pub mod error;
41pub mod flags;
42pub mod header;
43pub mod priority;
44pub mod section;
45pub mod section_type;
46
47// Re-exports for convenience
48pub use compile::{compile, decompile, DecompiledFafb};
49pub use error::{FafbError, FafbResult};
50pub use flags::{
51    Flags, FLAG_COMPRESSED, FLAG_EMBEDDINGS, FLAG_MODEL_HINTS, FLAG_SIGNED, FLAG_TOKENIZED,
52    FLAG_WEIGHTED,
53};
54pub use header::{
55    FafbHeader, HEADER_SIZE, MAGIC, MAGIC_U32, MAX_FILE_SIZE, MAX_SECTIONS, VERSION_MAJOR,
56    VERSION_MINOR,
57};
58pub use priority::{
59    Priority, PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_MEDIUM, PRIORITY_OPTIONAL,
60};
61pub use section::{SectionEntry, SectionTable, SECTION_ENTRY_SIZE};
62pub use section_type::{
63    SectionType, SECTION_ARCHITECTURE, SECTION_BISYNC, SECTION_COMMANDS, SECTION_CONTEXT,
64    SECTION_CUSTOM, SECTION_EMBEDDINGS, SECTION_KEY_FILES, SECTION_META, SECTION_MODEL_HINTS,
65    SECTION_TECH_STACK, SECTION_TOKEN_MAP,
66};