omni_director/providers/
mod.rs1pub mod registry;
7pub mod loader;
8pub mod metadata;
9pub mod context;
10pub mod feature_registry;
11pub mod event_registry;
12
13pub use registry::*;
14pub use loader::*;
15pub use metadata::*;
16pub use context::*;
17pub use feature_registry::*;
18pub use event_registry::*;
19
20use std::collections::HashMap;
21use serde_json::Value;
22use thiserror::Error;
23
24#[derive(Error, Debug)]
26pub enum ProviderError {
27 #[error("Provider not found: {0}")]
28 NotFound(String),
29
30 #[error("Provider loading failed: {0}")]
31 LoadingFailed(String),
32
33 #[error("Provider initialization failed: {0}")]
34 InitializationFailed(String),
35
36 #[error("Provider execution failed: {0}")]
37 ExecutionFailed(String),
38
39 #[error("Feature not supported: {feature} in provider {provider}")]
40 FeatureNotSupported { provider: String, feature: String },
41
42 #[error("Operation not supported: {operation} in {provider}/{feature}")]
43 OperationNotSupported { provider: String, feature: String, operation: String },
44
45 #[error("Invalid arguments: {0}")]
46 InvalidArguments(String),
47
48 #[error("Invalid route: {0}")]
49 InvalidRoute(String),
50
51 #[error("IO error: {0}")]
52 Io(#[from] std::io::Error),
53
54 #[error("Library loading error: {0}")]
55 LibraryError(#[from] libloading::Error),
56}
57
58pub type ProviderResult<T> = Result<T, ProviderError>;
60
61pub trait Provider: Send + Sync {
63 fn name(&self) -> &str;
65
66 fn version(&self) -> &str;
68
69 fn features(&self) -> Vec<String>;
71
72 fn supports_feature(&self, feature: &str) -> bool {
74 self.features().contains(&feature.to_string())
75 }
76
77 fn feature_operations(&self, feature: &str) -> ProviderResult<Vec<String>>;
79
80 fn execute_operation(
82 &self,
83 feature: &str,
84 operation: &str,
85 args: HashMap<String, Value>,
86 context: &dyn ProviderContext,
87 ) -> ProviderResult<Value>;
88
89 fn initialize(&mut self, context: &dyn ProviderContext) -> ProviderResult<()>;
91
92 fn shutdown(&mut self, context: &dyn ProviderContext) -> ProviderResult<()>;
94}