ass_editor/extensions/
info.rs1#[cfg(not(feature = "std"))]
7use alloc::{string::String, vec::Vec};
8
9#[derive(Debug, Clone, PartialEq, Eq)]
11pub enum ExtensionCapability {
12 TextProcessing,
14 SyntaxHighlighting,
16 CodeCompletion,
18 Linting,
20 FormatSupport,
22 CustomCommands,
24 UserInterface,
26 ToolIntegration,
28 EventHandling,
30 Performance,
32}
33
34impl ExtensionCapability {
35 pub fn description(&self) -> &'static str {
37 match self {
38 Self::TextProcessing => "Text processing and transformation",
39 Self::SyntaxHighlighting => "Syntax highlighting and theming",
40 Self::CodeCompletion => "Code completion and suggestions",
41 Self::Linting => "Linting and validation",
42 Self::FormatSupport => "Import/export format support",
43 Self::CustomCommands => "Custom commands and shortcuts",
44 Self::UserInterface => "UI enhancements and widgets",
45 Self::ToolIntegration => "External tool integration",
46 Self::EventHandling => "Custom event handling",
47 Self::Performance => "Performance monitoring",
48 }
49 }
50}
51
52#[derive(Debug, Clone, PartialEq, Eq)]
54pub struct ExtensionInfo {
55 pub name: String,
57 pub version: String,
59 pub author: String,
61 pub description: String,
63 pub capabilities: Vec<ExtensionCapability>,
65 pub dependencies: Vec<String>,
67 pub homepage: Option<String>,
69 pub license: Option<String>,
71}
72
73impl ExtensionInfo {
74 pub fn new(name: String, version: String, author: String, description: String) -> Self {
76 Self {
77 name,
78 version,
79 author,
80 description,
81 capabilities: Vec::new(),
82 dependencies: Vec::new(),
83 homepage: None,
84 license: None,
85 }
86 }
87
88 pub fn with_capability(mut self, capability: ExtensionCapability) -> Self {
90 self.capabilities.push(capability);
91 self
92 }
93
94 pub fn with_capabilities(mut self, capabilities: Vec<ExtensionCapability>) -> Self {
96 self.capabilities.extend(capabilities);
97 self
98 }
99
100 pub fn with_dependency(mut self, dependency: String) -> Self {
102 self.dependencies.push(dependency);
103 self
104 }
105
106 pub fn with_homepage(mut self, homepage: String) -> Self {
108 self.homepage = Some(homepage);
109 self
110 }
111
112 pub fn with_license(mut self, license: String) -> Self {
114 self.license = Some(license);
115 self
116 }
117
118 pub fn has_capability(&self, capability: &ExtensionCapability) -> bool {
120 self.capabilities.contains(capability)
121 }
122}