This plugin system solves the fundamental tension between modularity and performance in desktop applications. Unlike traditional plugin systems that load everything at runtime, we use a three-tier approach that optimizes for both developer experience and end-user performance.
The registry.json file controls the entire plugin lifecycle:
{
"plugin-name": {
"compiledIn": true, // Include in build?
"defaultEnabled": true // Active by default?
}
}This centralized approach eliminates the configuration drift that plagues distributed plugin systems.
Plugins are conditionally compiled based on Cargo features:
- Why? Zero overhead for unused plugins - they don't exist in the binary
- How? Registry drives Cargo feature flags automatically
- Result: Production builds contain only what's needed
Users can enable/disable compiled-in plugins without rebuilding:
- Disabled plugins have no performance impact (code never loads)
- Settings persist across sessions
- No restart required
Traditional Plugin Systems:
- Load all plugins, disable some at runtime
- Plugin code always present in memory
- Configuration scattered across multiple files
- Runtime discovery overhead
Our Approach:
- Compile only what's needed
- Registry as single configuration source
- Zero-cost abstraction for disabled features
- Predictable, auditable plugin loading
We intentionally chose compile-time inclusion over runtime loading because:
- Security: No arbitrary code execution
- Performance: Dead code elimination at compile time
- Reliability: All plugins verified at build time
- Size: Minimal binary contains only core features
The registry pattern provides:
- Single place to enable/disable features
- Automatic build configuration
- Clear separation between "available" and "active"
- Version-controlled plugin state
registry.json → Cargo features → Binary compilation
↓ ↓
User settings ← Runtime flags ← Compiled plugins
- Registry determines what gets compiled
- Build system reads registry, sets features
- Only compiled plugins can be enabled at runtime
- User preferences stored separately from registry