Skip to main content

aurum_core/provider_platform/
descriptor.rs

1//! Provider descriptors for discovery and preflight (JOE-1933).
2
3use super::id::ProviderId;
4use serde::{Deserialize, Serialize};
5
6/// Whether a provider implementation may perform network I/O.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case")]
9pub enum NetworkRequirement {
10    /// Never contacts the network for inference (downloads may still be gated separately).
11    LocalOnly,
12    /// Requires network for the operation.
13    RequiresNetwork,
14}
15
16/// Stability of a registered provider surface.
17#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
18#[serde(rename_all = "snake_case")]
19pub enum ProviderStability {
20    /// Supported product path.
21    Stable,
22    /// Usable but may change without a major version.
23    Experimental,
24    /// Compiled for tests/fixtures only.
25    TestOnly,
26}
27
28/// Operations a provider factory may expose.
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
30pub struct ProviderOperations {
31    pub stt: bool,
32    pub tts: bool,
33}
34
35impl ProviderOperations {
36    pub const STT_ONLY: Self = Self {
37        stt: true,
38        tts: false,
39    };
40    pub const TTS_ONLY: Self = Self {
41        stt: false,
42        tts: true,
43    };
44    pub const BOTH: Self = Self {
45        stt: true,
46        tts: true,
47    };
48
49    pub fn supports_stt(self) -> bool {
50        self.stt
51    }
52
53    pub fn supports_tts(self) -> bool {
54        self.tts
55    }
56}
57
58/// Immutable description of a registered provider (compile-time / registration-time).
59#[derive(Debug, Clone)]
60pub struct ProviderDescriptor {
61    pub id: ProviderId,
62    pub display_name: &'static str,
63    pub operations: ProviderOperations,
64    pub network: NetworkRequirement,
65    pub stability: ProviderStability,
66}
67
68impl ProviderDescriptor {
69    pub fn new(
70        id: ProviderId,
71        display_name: &'static str,
72        operations: ProviderOperations,
73        network: NetworkRequirement,
74        stability: ProviderStability,
75    ) -> Self {
76        Self {
77            id,
78            display_name,
79            operations,
80            network,
81            stability,
82        }
83    }
84}