Module CreateState

Module CreateState 

Source
Expand description

§CreateState

§File: Indexing/State/CreateState.rs

§Role in Air Architecture

Provides state creation functions for the File Indexer service, including the construction of index entries, symbols, and related data structures used throughout the indexing system.

§Primary Responsibility

Create and initialize index state structures including FileIndex, FileMetadata, SymbolInfo, and related types.

§Secondary Responsibilities

  • Generate index version strings
  • Calculate index checksums for integrity verification
  • Create new empty indexes
  • Backup corrupted indexes

§Dependencies

External Crates:

  • chrono - Timestamp generation for index metadata
  • sha2 - Checksum calculation for index integrity
  • serde - Serialization/deserialization of index structures

Internal Modules:

  • crate::Result - Error handling type
  • crate::AirError - Error types

§Dependents

  • Indexing::Store::StoreEntry - Creates entries for index storage
  • Indexing::Store::UpdateIndex - Updates index state
  • Indexing::mod::FileIndexer - Main file indexer implementation

§VSCode Pattern Reference

Inspired by VSCode’s indexer state creation in src/vs/workbench/services/search/common/

§Security Considerations

  • Checksums prevent tampering with index data
  • Version tracking enables corruption detection
  • Path traversal protection applied during validation

§Performance Considerations

  • Lightweight state creation operations
  • Hash calculations are amortized across index operations
  • Memory-efficient data structures for large indexes

§Error Handling Strategy

State creation operations use result types and propagate errors up with clear messages about what failed during creation or validation.

§Thread Safety

State structures are designed to be moved into Arc<RwLock<>> for thread-safe shared access across indexing and search operations.

Structs§

FileIndex
File index structure with comprehensive metadata
FileMetadata
File metadata with comprehensive information
SymbolInfo
Symbol information extracted from files for VSCode Outline View
SymbolLocation
Symbol location for cross-referencing

Enums§

SymbolKind
Symbol kind for VSCode compatibility

Constants§

MAX_FILE_SIZE_BYTES
Maximum file size allowed for indexing (100MB)

Functions§

CalculateIndexChecksum
Calculate index checksum for integrity verification
CreateFileMetadata
Create file metadata from raw information
CreateNewIndex
Create a new empty file index
CreateSymbolInfo
Create symbol info with validation
CreateSymbolLocation
Create symbol location for cross-referencing
GenerateIndexVersion
Generate index version string
GetPermissionsString
Get file permissions as string from metadata
ValidateFileSize
Validate file size against maximum allowed
ValidateIndexSize
Check if index size is within sane limits