Expand description
Storage drivers following Docker’s graphdriver pattern
This module implements a driver-based abstraction for worktree storage optimization, following the proven pattern from Docker’s container filesystem layer management. Just as Docker uses “graphdrivers” to abstract storage backends (overlay2, btrfs, zfs), we use “storage drivers” to abstract worktree optimization mechanisms.
§Design Philosophy (from Docker)
- “Driver” is the term - not “mechanism”, “strategy”, or “backend”
- Drivers are named after the actual technology they use
- Simple string-based selection in configuration
vfsis the universal fallback (plain directories)
§Architecture
Git worktrees are ALWAYS used as the base mechanism. Storage drivers are optional layers that sit UNDERNEATH git worktrees to provide benefits like:
- Copy-on-Write (CoW): ~80% disk space savings
- Isolation: Changes are isolated to an upper layer
- Performance: Faster creation and cleanup
§Example
# In configuration file (Docker-style)
[worktree]
driver = "overlay2" # or "btrfs", "reflink", "vfs", etc.use git2db::storage::{StorageDriver, DriverRegistry};
let registry = DriverRegistry::new();
// Select a driver explicitly
let driver = registry.get_driver(StorageDriver::Overlay2)?;
// Or use vfs as a safe fallback
let driver = registry.get_driver(StorageDriver::Vfs)?;Structs§
- Driver
Factory - Driver factory for plugin discovery
- Driver
Opts - Options for creating a worktree with a driver
- Driver
Registry - Registry of available storage drivers
- Worktree
Handle - Handle to a created worktree
Enums§
- Driver
Error - Driver-specific errors
- Storage
Driver - Storage driver selection
Traits§
- Driver
- Storage driver trait (Docker’s graphdriver interface)