vs_core/models.rs
1//! Core data models returned by application services.
2
3use std::path::PathBuf;
4
5use vs_config::Scope;
6use vs_plugin_api::{AvailableVersion, PluginManifest};
7use vs_registry::RegistryEntry;
8
9/// Scope to target when writing tool versions.
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum UseScope {
12 /// Persist the version globally.
13 Global,
14 /// Persist the version in the current project.
15 Project,
16 /// Persist the version for the active shell session.
17 Session,
18}
19
20impl UseScope {
21 /// Returns the stable lowercase scope label used by CLI output and plugin hooks.
22 pub fn as_str(self) -> &'static str {
23 match self {
24 Self::Global => "global",
25 Self::Project => "project",
26 Self::Session => "session",
27 }
28 }
29}
30
31/// A currently resolved tool.
32#[derive(Debug, Clone, PartialEq, Eq)]
33pub struct CurrentTool {
34 /// Tool identifier.
35 pub plugin: String,
36 /// Resolved version.
37 pub version: String,
38 /// Resolution scope.
39 pub scope: Scope,
40 /// Backing source file.
41 pub source: PathBuf,
42}
43
44/// A discovered installed version.
45#[derive(Debug, Clone, PartialEq, Eq)]
46pub struct InstalledVersion {
47 /// Tool identifier.
48 pub plugin: String,
49 /// Installed version.
50 pub version: String,
51 /// Installation path.
52 pub install_dir: PathBuf,
53}
54
55/// Summary for `vs info`.
56#[derive(Debug, Clone, PartialEq, Eq)]
57pub struct PluginInfo {
58 /// Registry entry used to resolve the plugin.
59 pub entry: RegistryEntry,
60 /// Static plugin manifest.
61 pub manifest: PluginManifest,
62 /// Available versions exposed by the backend.
63 pub available_versions: Vec<AvailableVersion>,
64 /// Installed versions already present in the local cache.
65 pub installed_versions: Vec<String>,
66}
67
68/// Result from an uninstall operation.
69#[derive(Debug, Clone, PartialEq, Eq)]
70pub struct UninstallResult {
71 /// Whether the version was actually removed.
72 pub removed: bool,
73 /// When the uninstalled version was active, the version auto-switched to (if any).
74 pub auto_switched: Option<String>,
75}
76
77/// Migration result for `vs migrate`.
78#[derive(Debug, Clone, PartialEq, Eq)]
79pub struct MigrateSummary {
80 /// Source home that was migrated.
81 pub source_home: PathBuf,
82 /// Number of filesystem roots copied.
83 pub copied_roots: usize,
84}
85
86/// Version and build metadata for the current `vs` binary.
87#[derive(Debug, Clone, PartialEq, Eq)]
88pub struct VersionInfo {
89 /// Currently running version.
90 pub current_version: String,
91 /// Build target triple compiled into the current binary.
92 pub build_target: String,
93 /// Release variant compiled into the current binary.
94 pub build_variant: String,
95 /// Release archive extension expected for this binary.
96 pub archive_extension: String,
97}
98
99/// Summary for a self-upgrade operation.
100#[derive(Debug, Clone, PartialEq, Eq)]
101pub struct SelfUpgradeSummary {
102 /// Currently running version.
103 pub current_version: String,
104 /// Latest available version discovered from the release feed.
105 pub latest_version: String,
106 /// Whether the binary was replaced.
107 pub updated: bool,
108}