Oak VFS
A high-performance Virtual File System (VFS) abstraction for the Oak ecosystem, supporting both disk and memory-based storage.
🎯 Overview
Oak VFS provides a unified interface for file operations, allowing the Oak framework to work seamlessly with physical files on disk or virtual files in memory. This is critical for IDEs and Language Servers where files may be modified in memory before being saved to disk.
✨ Features
- Unified Interface: Single
Vfstrait for all file operations. - Multiple Backends:
DiskVfs: Real-time access to the physical filesystem.MemoryVfs: Ultra-fast, in-memory file storage for unsaved buffers or tests.
- Position Mapping: Built-in support for converting between byte offsets and line/column positions.
- Metadata Support: Track file types, sizes, and modification timestamps.
- Async Ready: Designed to work in asynchronous environments like
tokio.
🚀 Quick Start
Using the MemoryVfs:
use ;
let vfs = new;
vfs.write_file;
if vfs.exists
📋 Examples
Working with Disk VFS
use ;
let vfs = new;
if let Some = vfs.metadata
Position Mapping
use ;
use Position;
let vfs = new;
vfs.write_file;
let pos = vfs.offset_to_position.unwrap;
println!;
🏗️ Integration
Oak VFS is the backbone of:
- Oak LSP: Manages open file buffers and provides source content to parsers.
- Oak Core: Uses VFS-provided sources for building red-green trees.
- Test Suites: Uses
MemoryVfsto simulate file structures without disk I/O.
📊 Performance
- Zero-Copy Reads: Efficiently handles large file contents.
- Fast Lookups: Optimized URI-to-source mapping.
- Minimal Locking: Designed for high-concurrency access.
🤝 Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
Oak VFS - A solid foundation for file management 🚀