Skip to main content

termivar_scanner/plugin/
metadata.rs

1use serde::Serialize;
2
3use super::PluginCategory;
4
5#[derive(Clone)]
6pub(super) struct PluginDescriptor {
7    pub(super) id: String,
8    pub(super) name: String,
9    pub(super) version: String,
10    pub(super) description: String,
11    pub(super) author: String,
12    pub(super) category: PluginCategory,
13    pub(super) api_version: String,
14    pub(super) loaded_at: u64,
15}
16
17/// Consistent metadata snapshot from one registry entry.
18#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
19pub struct PluginMetadata {
20    pub(super) id: String,
21    pub(super) name: String,
22    pub(super) version: String,
23    pub(super) description: String,
24    pub(super) author: String,
25    pub(super) category: PluginCategory,
26    pub(super) api_version: String,
27    pub(super) enabled: bool,
28    pub(super) loaded_at: u64,
29    pub(super) execution_count: u64,
30    pub(super) success_count: u64,
31    pub(super) error_count: u64,
32}
33
34impl PluginMetadata {
35    /// Stable plugin identity.
36    pub fn id(&self) -> &str {
37        &self.id
38    }
39
40    /// Human-readable plugin name.
41    pub fn name(&self) -> &str {
42        &self.name
43    }
44
45    /// Plugin implementation version.
46    pub fn version(&self) -> &str {
47        &self.version
48    }
49
50    /// Human-readable description.
51    pub fn description(&self) -> &str {
52        &self.description
53    }
54
55    /// Human-readable author or owner.
56    pub fn author(&self) -> &str {
57        &self.author
58    }
59
60    /// Informational category.
61    pub const fn category(&self) -> PluginCategory {
62        self.category
63    }
64
65    /// Targeted plugin API line.
66    pub fn api_version(&self) -> &str {
67        &self.api_version
68    }
69
70    /// Snapshotted host enable state.
71    pub const fn enabled(&self) -> bool {
72        self.enabled
73    }
74
75    /// Registration timestamp in Unix seconds.
76    pub const fn loaded_at(&self) -> u64 {
77        self.loaded_at
78    }
79
80    /// Invocation attempts that reached execution policy.
81    pub const fn execution_count(&self) -> u64 {
82        self.execution_count
83    }
84
85    /// Cleanly completed invocations.
86    pub const fn success_count(&self) -> u64 {
87        self.success_count
88    }
89
90    /// Failed, timed-out, cancelled, or panicked invocations.
91    pub const fn error_count(&self) -> u64 {
92        self.error_count
93    }
94}