Skip to main content

Module binary

Module binary 

Source
Expand description

FAFB Binary Format

Implementation of the .fafb binary format specification. Compiles human-readable .faf (YAML) to AI-optimized binary.

§Features

  • O(1) section lookup - Section table at end for instant access
  • Priority truncation - Smart context window management
  • Pre-computed tokens - No runtime estimation
  • Memory mapping ready - Zero-copy loading design

§Usage

use faf_rust_sdk::binary::{FafbHeader, Flags, SectionEntry, SectionTable, SectionType, Priority};

// Create a new header
let mut header = FafbHeader::with_timestamp();
header.set_source_checksum(yaml_content.as_bytes());
header.section_count = 3;

// Create section table
let mut table = SectionTable::new();
table.push(SectionEntry::new(SectionType::Meta, 32, 100));
table.push(SectionEntry::new(SectionType::TechStack, 132, 200)
    .with_priority(Priority::high()));

// Budget-aware loading
let sections = table.entries_within_budget(1000);

§Format Version

Current: v1.0

See FAFB-BINARY-SPEC.md for full specification.

Re-exports§

pub use compile::compile;
pub use compile::decompile;
pub use compile::DecompiledFafb;
pub use error::FafbError;
pub use error::FafbResult;
pub use flags::Flags;
pub use flags::FLAG_COMPRESSED;
pub use flags::FLAG_EMBEDDINGS;
pub use flags::FLAG_MODEL_HINTS;
pub use flags::FLAG_SIGNED;
pub use flags::FLAG_TOKENIZED;
pub use flags::FLAG_WEIGHTED;
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;
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 section::SectionEntry;
pub use section::SectionTable;
pub use section::SECTION_ENTRY_SIZE;
pub use section_type::SectionType;
pub use section_type::SECTION_ARCHITECTURE;
pub use section_type::SECTION_BISYNC;
pub use section_type::SECTION_COMMANDS;
pub use section_type::SECTION_CONTEXT;
pub use section_type::SECTION_CUSTOM;
pub use section_type::SECTION_EMBEDDINGS;
pub use section_type::SECTION_KEY_FILES;
pub use section_type::SECTION_META;
pub use section_type::SECTION_MODEL_HINTS;
pub use section_type::SECTION_TECH_STACK;
pub use section_type::SECTION_TOKEN_MAP;

Modules§

compile
Compile/decompile API for .faf ↔ .fafb conversion
error
FAFB Error Types
flags
FAFB Feature Flags
header
FAFB Header Implementation
priority
FAFB Priority System
section
FAFB Section Entry and Section Table
section_type
FAFB Section Types