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 metadatasha2- Checksum calculation for index integrityserde- Serialization/deserialization of index structures
Internal Modules:
crate::Result- Error handling typecrate::AirError- Error types
§Dependents
Indexing::Store::StoreEntry- Creates entries for index storageIndexing::Store::UpdateIndex- Updates index stateIndexing::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§
- File
Index - File index structure with comprehensive metadata
- File
Metadata - File metadata with comprehensive information
- Symbol
Info - Symbol information extracted from files for VSCode Outline View
- Symbol
Location - Symbol location for cross-referencing
Enums§
- Symbol
Kind - Symbol kind for VSCode compatibility
Constants§
- MAX_
FILE_ SIZE_ BYTES - Maximum file size allowed for indexing (100MB)
Functions§
- Calculate
Index Checksum - Calculate index checksum for integrity verification
- Create
File Metadata - Create file metadata from raw information
- Create
NewIndex - Create a new empty file index
- Create
Symbol Info - Create symbol info with validation
- Create
Symbol Location - Create symbol location for cross-referencing
- Generate
Index Version - Generate index version string
- GetPermissions
String - Get file permissions as string from metadata
- Validate
File Size - Validate file size against maximum allowed
- Validate
Index Size - Check if index size is within sane limits