| Crates.io | cadi-extensions |
| lib.rs | cadi-extensions |
| version | 2.0.0 |
| created_at | 2026-01-12 06:41:18.295256+00 |
| updated_at | 2026-01-12 06:41:18.295256+00 |
| description | Plugin system for CADI extensions |
| homepage | https://cadi.dev |
| repository | https://github.com/cadi-project/cadi |
| max_upload_size | |
| id | 2037113 |
| size | 64,070 |
The plugin system that makes CADI infinitely extensible.
CADI Extensions enable developers to extend CADI's capabilities with custom:
Extensions are dynamically loaded plugins that implement well-defined traits:
#[async_trait]
pub trait Extension: Send + Sync {
fn metadata(&self) -> ExtensionMetadata;
async fn initialize(&mut self, context: &ExtensionContext) -> Result<()>;
async fn shutdown(&mut self) -> Result<()>;
}
#[async_trait]
pub trait AtomizerExtension: Extension {
fn language(&self) -> &str;
async fn extract_atoms(&self, source: &str) -> Result<Vec<AtomicChunk>>;
async fn resolve_imports(&self, source: &str) -> Result<Vec<ResolvedImport>>;
}
#[async_trait]
pub trait BuildBackendExtension: Extension {
fn target_formats(&self) -> Vec<&str>;
async fn build(&self, chunk: &AtomicChunk, target: &str) -> Result<BuildArtifact>;
}
#[async_trait]
pub trait RegistryExtension: Extension {
async fn store(&self, chunk: &AtomicChunk) -> Result<String>;
async fn retrieve(&self, id: &str) -> Result<Option<AtomicChunk>>;
async fn search(&self, query: &SearchQuery) -> Result<Vec<AtomicChunk>>;
}
#[no_mangle]
pub extern "C" fn cadi_extension_create() -> *mut dyn Extension {
Box::into_raw(Box::new(MyExtension::new()))
}
extension.toml):
[extension]
name = "my-extension"
version = "1.0.0"
type = "atomizer"
description = "Atomizer for MyLanguage"
[dependencies]
cadi-core = "2.0"
Extensions can be loaded from:
./extensions/cadi install my-extension/usr/local/lib/cadi/extensions/let loader = ExtensionLoader::new()
.with_search_paths(vec!["./extensions".into()])
.load_all()
.await?;
Extensions are distributed as:
cargo install cadi-atomizer-javacadi install my-extensionPremium extensions are available through CADI Pro/Enterprise:
# Build the extensions crate
cargo build
# Run tests
cargo test
# Build example extension
cd examples/java-atomizer
cargo build --release