vein_adapter/cache/
types.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value as JsonValue;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum AssetKind {
6    Gem,
7    Spec,
8}
9
10impl AssetKind {
11    pub fn as_str(&self) -> &'static str {
12        match self {
13            AssetKind::Gem => "gem",
14            AssetKind::Spec => "gemspec",
15        }
16    }
17}
18
19#[derive(Debug, Clone)]
20pub struct AssetKey<'a> {
21    pub kind: AssetKind,
22    pub name: &'a str,
23    pub version: &'a str,
24    pub platform: Option<&'a str>,
25}
26
27#[derive(Debug, Clone)]
28pub struct CachedAsset {
29    pub path: String,
30    pub sha256: String,
31    pub size_bytes: u64,
32    pub last_accessed: String,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
36#[serde(rename_all = "snake_case")]
37pub enum DependencyKind {
38    Runtime,
39    Development,
40    Optional,
41    Unknown,
42}
43
44impl std::str::FromStr for DependencyKind {
45    type Err = ();
46
47    fn from_str(s: &str) -> Result<Self, Self::Err> {
48        Ok(match s {
49            "runtime" => Self::Runtime,
50            "development" => Self::Development,
51            "optional" => Self::Optional,
52            _ => Self::Unknown,
53        })
54    }
55}
56
57#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
58pub struct GemDependency {
59    pub name: String,
60    pub requirement: String,
61    pub kind: DependencyKind,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
65pub struct GemMetadata {
66    pub name: String,
67    pub version: String,
68    pub platform: Option<String>,
69    pub summary: Option<String>,
70    pub description: Option<String>,
71    pub licenses: Vec<String>,
72    pub authors: Vec<String>,
73    pub emails: Vec<String>,
74    pub homepage: Option<String>,
75    pub documentation_url: Option<String>,
76    pub changelog_url: Option<String>,
77    pub source_code_url: Option<String>,
78    pub bug_tracker_url: Option<String>,
79    pub wiki_url: Option<String>,
80    pub funding_url: Option<String>,
81    #[serde(default)]
82    pub metadata: JsonValue,
83    pub dependencies: Vec<GemDependency>,
84    pub executables: Vec<String>,
85    pub extensions: Vec<String>,
86    #[serde(default)]
87    pub native_languages: Vec<String>,
88    pub has_native_extensions: bool,
89    pub has_embedded_binaries: bool,
90    pub required_ruby_version: Option<String>,
91    pub required_rubygems_version: Option<String>,
92    pub rubygems_version: Option<String>,
93    pub specification_version: Option<i64>,
94    pub built_at: Option<String>,
95    pub size_bytes: u64,
96    pub sha256: String,
97    #[serde(default)]
98    pub sbom: Option<JsonValue>,
99}
100
101#[derive(Debug, Clone)]
102pub struct IndexStats {
103    pub total_assets: u64,
104    pub gem_assets: u64,
105    pub spec_assets: u64,
106    pub unique_gems: u64,
107    pub total_size_bytes: u64,
108    pub last_accessed: Option<String>,
109}
110
111#[derive(Debug, Clone, Copy, PartialEq, Eq)]
112pub struct SbomCoverage {
113    pub metadata_rows: u64,
114    pub with_sbom: u64,
115}