Module offset_format

Module offset_format 

Source
Expand description

Offset-based binary format for zero-copy memory mapping

This module re-exports the binary format structures from matchy-paraglob. The canonical definitions live in matchy-paraglob::offset_format to ensure a single source of truth for all #[repr(C)] binary format structures.

§What This Module Provides

  • ParaglobHeader - Main header (112 bytes, v5)
  • PatternDataMapping - Pattern-to-data offset mapping
  • GlobSegmentIndex, GlobSegmentHeader, CharClassItemEncoded - Glob segment structures
  • MAGIC, MATCHY_FORMAT_VERSION* - Format constants
  • Helper functions for reading structures from byte buffers

§Why Re-exports?

Binary format structures are defined once in matchy-paraglob and re-exported here to avoid duplication. This prevents drift between identical #[repr(C)] structs that must remain byte-for-byte compatible.

Structs§

CharClassItemEncoded
Encoded character class item (12 bytes, 4-byte aligned)
GlobSegmentHeader
Glob segment header (12 bytes, 4-byte aligned)
GlobSegmentIndex
Glob segment index entry (8 bytes, 4-byte aligned)
ParaglobHeader
Main header for serialized Paraglob database (112 bytes, 4-byte aligned)
PatternDataMapping
Pattern-to-data mapping entry (12 bytes, 4-byte aligned)

Constants§

MAGIC
Magic bytes identifying Paraglob binary format
MATCHY_FORMAT_VERSION
Current format version (v5: serialized glob segments for zero-copy loading)
MATCHY_FORMAT_VERSION_V1
Previous format version (v1: patterns only, no data)
MATCHY_FORMAT_VERSION_V2
Previous format version (v2: adds data section support)
MATCHY_FORMAT_VERSION_V3
Previous format version (v3: adds AC literal mapping for zero-copy loading)
MATCHY_FORMAT_VERSION_V4
Previous format version (v4: uses ACNodeHot for 50% memory reduction)

Functions§

read_cstring
Helper to read a null-terminated UTF-8 string from buffer
read_cstring_with_len
Helper to read a UTF-8 string from buffer with known length (FAST PATH)
read_str_checked
Helper to read a UTF-8 string from buffer with known length (SAFE PATH - validates UTF-8)
read_str_unchecked
Helper to read a UTF-8 string from buffer with known length (ULTRA-FAST PATH - NO UTF-8 VALIDATION)
read_struct
Helper to safely read a struct from a byte buffer at an offset
read_struct_slice
Helper to safely read a slice of structs from a byte buffer