Skip to main content

stynx_code_services/plugin_registry/
mod.rs

1use async_trait::async_trait;
2use stynx_code_errors::AppResult;
3use serde::{Deserialize, Serialize};
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct PluginInfo {
7    pub name: String,
8    pub version: String,
9    pub description: String,
10    pub path: String,
11}
12
13#[async_trait]
14pub trait PluginRegistry: Send + Sync {
15    async fn discover(&self) -> Vec<PluginInfo>;
16    async fn load(&self, name: &str) -> AppResult<()>;
17    async fn unload(&self, name: &str);
18}
19
20pub struct StubPluginRegistry;
21
22impl StubPluginRegistry {
23    pub fn new() -> Self {
24        Self
25    }
26}
27
28#[async_trait]
29impl PluginRegistry for StubPluginRegistry {
30    async fn discover(&self) -> Vec<PluginInfo> {
31        tracing::info!("plugin discovery not yet implemented");
32        Vec::new()
33    }
34
35    async fn load(&self, name: &str) -> AppResult<()> {
36        tracing::warn!(name, "plugin loading not yet implemented");
37        Err(anyhow::anyhow!("plugin loading not yet implemented").into())
38    }
39
40    async fn unload(&self, name: &str) {
41        tracing::warn!(name, "plugin unloading not yet implemented");
42    }
43}