#[cfg(not(feature = "std"))]
use alloc::{string::String, vec::Vec};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ExtensionCapability {
TextProcessing,
SyntaxHighlighting,
CodeCompletion,
Linting,
FormatSupport,
CustomCommands,
UserInterface,
ToolIntegration,
EventHandling,
Performance,
}
impl ExtensionCapability {
pub fn description(&self) -> &'static str {
match self {
Self::TextProcessing => "Text processing and transformation",
Self::SyntaxHighlighting => "Syntax highlighting and theming",
Self::CodeCompletion => "Code completion and suggestions",
Self::Linting => "Linting and validation",
Self::FormatSupport => "Import/export format support",
Self::CustomCommands => "Custom commands and shortcuts",
Self::UserInterface => "UI enhancements and widgets",
Self::ToolIntegration => "External tool integration",
Self::EventHandling => "Custom event handling",
Self::Performance => "Performance monitoring",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ExtensionInfo {
pub name: String,
pub version: String,
pub author: String,
pub description: String,
pub capabilities: Vec<ExtensionCapability>,
pub dependencies: Vec<String>,
pub homepage: Option<String>,
pub license: Option<String>,
}
impl ExtensionInfo {
pub fn new(name: String, version: String, author: String, description: String) -> Self {
Self {
name,
version,
author,
description,
capabilities: Vec::new(),
dependencies: Vec::new(),
homepage: None,
license: None,
}
}
pub fn with_capability(mut self, capability: ExtensionCapability) -> Self {
self.capabilities.push(capability);
self
}
pub fn with_capabilities(mut self, capabilities: Vec<ExtensionCapability>) -> Self {
self.capabilities.extend(capabilities);
self
}
pub fn with_dependency(mut self, dependency: String) -> Self {
self.dependencies.push(dependency);
self
}
pub fn with_homepage(mut self, homepage: String) -> Self {
self.homepage = Some(homepage);
self
}
pub fn with_license(mut self, license: String) -> Self {
self.license = Some(license);
self
}
pub fn has_capability(&self, capability: &ExtensionCapability) -> bool {
self.capabilities.contains(capability)
}
}