63 lines
2.2 KiB
Rust
63 lines
2.2 KiB
Rust
//! 平台环境数据结构(对齐架构 §5 `PlatformEnv`)
|
||
|
||
use serde::{Deserialize, Serialize};
|
||
|
||
/// 平台环境快照
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||
pub struct PlatformEnv {
|
||
/// os: windows | linux
|
||
pub os: String,
|
||
/// 人类可读的系统版本(如 "Windows 11 24H2 (Build 26100)" / "Ubuntu 24.04 LTS")
|
||
pub os_version: String,
|
||
/// 架构(std::env::consts::ARCH,如 x86_64)
|
||
pub arch: String,
|
||
/// Linux 发行版名称(如 "ubuntu");Windows 为 None。
|
||
/// 架构 §5 原 `distro?: ubuntu + version` 合并字段,本波拆分为
|
||
/// `distro` + `distro_version` 两个字段(总工 Wave 0 🟡)。
|
||
pub distro: Option<String>,
|
||
/// Linux 发行版版本(如 "22.04");Windows 为 None。
|
||
pub distro_version: Option<String>,
|
||
pub shells: Shells,
|
||
pub runtimes: Runtimes,
|
||
/// PATH 条目(Windows 用 ';' 分割,Linux 用 ':')
|
||
pub path_entries: Vec<String>,
|
||
pub capabilities: Capabilities,
|
||
}
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||
pub struct Shells {
|
||
/// Windows PowerShell(5.x)版本
|
||
pub powershell_version: Option<String>,
|
||
/// PowerShell 7+(pwsh)版本
|
||
pub pwsh_version: Option<String>,
|
||
pub bash_available: bool,
|
||
}
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||
pub struct Runtimes {
|
||
pub node: Option<RuntimeInfo>,
|
||
pub npm: Option<RuntimeInfo>,
|
||
pub python: Option<RuntimeInfo>,
|
||
pub uv: Option<RuntimeInfo>,
|
||
pub git: Option<RuntimeInfo>,
|
||
pub winget: Option<RuntimeInfo>,
|
||
pub apt: Option<RuntimeInfo>,
|
||
}
|
||
|
||
/// 单个运行时探测结果
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||
pub struct RuntimeInfo {
|
||
/// installed | not_in_path | permission_denied | exec_failed | version_unparseable
|
||
pub status: String,
|
||
pub version: Option<String>,
|
||
/// 解析到的可执行文件绝对路径(PATH 搜索)
|
||
pub path: Option<String>,
|
||
}
|
||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
|
||
pub struct Capabilities {
|
||
/// ok | missing(Linux 依赖 secret-tool / DBus Secret Service)
|
||
pub keyring: String,
|
||
pub can_elevate: bool,
|
||
}
|