pub trait Domain:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn detect(&self, repo_path: &Path) -> DetectionResult;
// Provided method
fn base_capabilities(&self) -> CapabilitySet { ... }
}Expand description
A domain that provides capabilities for repositories
Domains replace archetypes in the new capability system. Each domain:
- Detects whether a repository belongs to it
- Provides a set of capabilities for that repository
- Can detect additional capabilities based on repository contents
§Example
ⓘ
use hyprstream::archetypes::domain::{Domain, DetectionResult};
use hyprstream::archetypes::capabilities::{CapabilitySet, Infer, Train, Serve};
struct HfModelDomain;
impl Domain for HfModelDomain {
fn name(&self) -> &'static str { "HfModel" }
fn description(&self) -> &'static str { "HuggingFace model" }
fn detect(&self, repo_path: &Path) -> DetectionResult {
let config_path = repo_path.join("config.json");
if !config_path.exists() {
return DetectionResult::NotDetected;
}
// Validate config and build capabilities
let mut caps = CapabilitySet::model();
if repo_path.join("adapters").is_dir() {
caps.insert::<LoraSupport>();
}
DetectionResult::Detected(caps)
}
}Required Methods§
Sourcefn name(&self) -> &'static str
fn name(&self) -> &'static str
Domain identifier for Casbin (e.g., “HfModel”)
This is used in policy rules: p, user, HfModel, model:*, infer
Sourcefn description(&self) -> &'static str
fn description(&self) -> &'static str
Human-readable description
Sourcefn detect(&self, repo_path: &Path) -> DetectionResult
fn detect(&self, repo_path: &Path) -> DetectionResult
Detect if a repository belongs to this domain
Returns:
Detected(caps)if the repo matches with capabilitiesNotDetectedif the repo doesn’t match (not an error)Error(e)if detection failed (I/O error, invalid structure)
Provided Methods§
Sourcefn base_capabilities(&self) -> CapabilitySet
fn base_capabilities(&self) -> CapabilitySet
Base capabilities this domain always provides when detected
Override detect() for conditional capabilities.
Implementors§
impl<T: SimpleDomain> Domain for T
Blanket implementation that converts SimpleDomain::matches to DetectionResult