1use std::collections::BTreeMap;
4use std::path::PathBuf;
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum Scope {
11 Project,
13 Session,
15 Global,
17 System,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq)]
23pub struct ResolvedToolVersion {
24 pub plugin: String,
26 pub version: String,
28 pub scope: Scope,
30 pub source: PathBuf,
32}
33
34#[derive(Debug, Clone, PartialEq, Eq)]
36pub struct HomeLayout {
37 pub active_home: PathBuf,
39 pub migration_candidates: Vec<PathBuf>,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, Default)]
45#[serde(default, rename_all = "camelCase")]
46pub struct AppConfig {
47 pub proxy: ProxyConfig,
49 pub storage: StorageConfig,
51 pub registry: RegistryConfig,
53 pub legacy_version_file: LegacyVersionFileConfig,
55 pub cache: CacheConfig,
57}
58
59#[derive(Debug, Clone, Serialize, Deserialize, Default)]
61#[serde(default, rename_all = "camelCase")]
62pub struct ProxyConfig {
63 pub enable: bool,
65 pub url: String,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize, Default)]
71#[serde(default, rename_all = "camelCase")]
72pub struct StorageConfig {
73 pub sdk_path: String,
75}
76
77#[derive(Debug, Clone, Serialize, Deserialize, Default)]
79#[serde(default, rename_all = "camelCase")]
80pub struct RegistryConfig {
81 pub address: String,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
87#[serde(default, rename_all = "camelCase")]
88pub struct LegacyVersionFileConfig {
89 pub enable: bool,
91 pub strategy: String,
93}
94
95impl Default for LegacyVersionFileConfig {
96 fn default() -> Self {
97 Self {
98 enable: true,
99 strategy: String::from("specified"),
100 }
101 }
102}
103
104#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(default, rename_all = "camelCase")]
107pub struct CacheConfig {
108 pub available_hook_duration: String,
110}
111
112impl Default for CacheConfig {
113 fn default() -> Self {
114 Self {
115 available_hook_duration: String::from("12h"),
116 }
117 }
118}
119
120#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)]
122pub struct ToolVersions {
123 #[serde(default)]
125 pub tools: BTreeMap<String, String>,
126}