Skip to main content

Domain

Trait Domain 

Source
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§

Source

fn name(&self) -> &'static str

Domain identifier for Casbin (e.g., “HfModel”)

This is used in policy rules: p, user, HfModel, model:*, infer

Source

fn description(&self) -> &'static str

Human-readable description

Source

fn detect(&self, repo_path: &Path) -> DetectionResult

Detect if a repository belongs to this domain

Returns:

  • Detected(caps) if the repo matches with capabilities
  • NotDetected if the repo doesn’t match (not an error)
  • Error(e) if detection failed (I/O error, invalid structure)

Provided Methods§

Source

fn base_capabilities(&self) -> CapabilitySet

Base capabilities this domain always provides when detected

Override detect() for conditional capabilities.

Implementors§

Source§

impl<T: SimpleDomain> Domain for T

Blanket implementation that converts SimpleDomain::matches to DetectionResult