68 releases (12 stable)
Uses new Rust 2024
| new 1.5.0 | Feb 4, 2026 |
|---|---|
| 1.4.1 | Feb 3, 2026 |
| 1.3.0 | Jan 29, 2026 |
| 1.0.3 | Dec 24, 2025 |
| 1.0.0-beta.5 | Aug 31, 2025 |
#474 in Filesystem
1,883 downloads per month
Used in 20 crates
(18 directly)
75KB
1K
SLoC
High-performance file database for PHP projects.
This crate provides an efficient in-memory database for managing collections of PHP source files. It offers two complementary database types optimized for different access patterns:
Database: Mutable builder optimized for modifications (add, update, delete)ReadDatabase: Immutable snapshot optimized for high-performance reads
Architecture
The database uses a two-phase approach:
- Build Phase: Use
Databaseto load files, make modifications, and track changes - Query Phase: Convert to
ReadDatabaseviaDatabase::read_onlyfor fast lookups
Key Features
- Fast Lookups: O(1) average-time access by ID, name, or filesystem path
- Change Tracking: Record and batch apply file modifications via
ChangeLog - Deterministic Iteration:
ReadDatabaseguarantees consistent iteration order - Parallel Operations: Concurrent file I/O and processing support
- Type Safety: Strong typing with stable
FileIdhandles
Common Workflow
Loading Files
Use loader::DatabaseLoader to scan a project directory:
The loader handles file discovery, exclusion patterns, and parallel loading.
Querying Files
Both database types implement DatabaseReader for uniform access:
Modifying Files
Use ChangeLog to batch modifications:
Changes can be applied to the database and optionally written to disk in parallel.
Performance Characteristics
Database (Mutable)
- Add/Update/Delete: O(1) average
- Lookup by ID/name: O(1) average
- Iteration: Unordered
- Memory: ~2x file count (maps for bidirectional lookup)
ReadDatabase (Immutable)
- Creation: O(n log n) for sorting
- Lookup by ID/name/path: O(1) average
- Iteration: Deterministic, sorted by
FileId - Memory: ~3x file count (vector + 3 index maps)
Thread Safety
Database is not thread-safe and should be used from a single thread during construction.
ReadDatabase can be freely shared across threads for concurrent read access.
Dependencies
~10–24MB
~224K SLoC