Skip to main content

vs_core/
models.rs

1use std::path::PathBuf;
2
3use vs_config::Scope;
4use vs_plugin_api::{AvailableVersion, PluginManifest};
5use vs_registry::RegistryEntry;
6
7/// Scope to target when writing tool versions.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum UseScope {
10    /// Persist the version globally.
11    Global,
12    /// Persist the version in the current project.
13    Project,
14    /// Persist the version for the active shell session.
15    Session,
16}
17
18impl UseScope {
19    /// Returns the stable lowercase scope label used by CLI output and plugin hooks.
20    pub fn as_str(self) -> &'static str {
21        match self {
22            Self::Global => "global",
23            Self::Project => "project",
24            Self::Session => "session",
25        }
26    }
27}
28
29/// A currently resolved tool.
30#[derive(Debug, Clone, PartialEq, Eq)]
31pub struct CurrentTool {
32    /// Tool identifier.
33    pub plugin: String,
34    /// Resolved version.
35    pub version: String,
36    /// Resolution scope.
37    pub scope: Scope,
38    /// Backing source file.
39    pub source: PathBuf,
40}
41
42/// A discovered installed version.
43#[derive(Debug, Clone, PartialEq, Eq)]
44pub struct InstalledVersion {
45    /// Tool identifier.
46    pub plugin: String,
47    /// Installed version.
48    pub version: String,
49    /// Installation path.
50    pub install_dir: PathBuf,
51}
52
53/// Summary for `vs info`.
54#[derive(Debug, Clone, PartialEq, Eq)]
55pub struct PluginInfo {
56    /// Registry entry used to resolve the plugin.
57    pub entry: RegistryEntry,
58    /// Static plugin manifest.
59    pub manifest: PluginManifest,
60    /// Available versions exposed by the backend.
61    pub available_versions: Vec<AvailableVersion>,
62    /// Installed versions already present in the local cache.
63    pub installed_versions: Vec<String>,
64}
65
66/// Migration result for `vs migrate`.
67#[derive(Debug, Clone, PartialEq, Eq)]
68pub struct MigrateSummary {
69    /// Source home that was migrated.
70    pub source_home: PathBuf,
71    /// Number of filesystem roots copied.
72    pub copied_roots: usize,
73}
74
75/// Summary for a self-upgrade operation.
76#[derive(Debug, Clone, PartialEq, Eq)]
77pub struct SelfUpgradeSummary {
78    /// Currently running version.
79    pub current_version: String,
80    /// Latest available version discovered from the release feed.
81    pub latest_version: String,
82    /// Whether the binary was replaced.
83    pub updated: bool,
84}