Skip to main content

kernel/install/
provider.rs

1//! The install-provider identity and availability types.
2
3use serde::{Deserialize, Serialize};
4
5/// Which install backend fetches a model: Hugging Face or Ollama.
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
7#[serde(transparent)]
8pub struct InstallProviderId(String);
9
10impl InstallProviderId {
11    /// The Hugging Face provider.
12    pub fn huggingface() -> Self {
13        Self("huggingface".to_owned())
14    }
15
16    /// The Ollama provider.
17    pub fn ollama() -> Self {
18        Self("ollama".to_owned())
19    }
20
21    /// The underlying identifier string.
22    pub fn as_str(&self) -> &str {
23        &self.0
24    }
25}
26
27impl From<&str> for InstallProviderId {
28    fn from(value: &str) -> Self {
29        Self(value.to_owned())
30    }
31}
32
33impl std::fmt::Display for InstallProviderId {
34    fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35        formatter.write_str(&self.0)
36    }
37}
38
39/// Whether an install provider can run right now.
40#[derive(Debug, Clone, PartialEq, Eq, Hash)]
41pub enum InstallAvailability {
42    /// Ready to install.
43    Ready,
44    /// Not usable, with a reason to show the user.
45    Unavailable {
46        /// Why the provider can't be used.
47        hint: String,
48    },
49}