use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PluginTemplate {
pub metadata: TemplateMetadata,
pub structure: EnhancedTemplateStructure,
pub parameters: Vec<TemplateParameter>,
pub content: String,
pub dependencies: Vec<String>,
pub features: Vec<String>,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub enum TemplateCategory {
Basic,
Advanced,
Specialized,
Research,
Production,
Experimental,
Educational,
Performance,
Distributed,
Neuromorphic,
Custom,
}
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
pub enum ComplexityLevel {
Beginner,
Intermediate,
Advanced,
Expert,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EnhancedTemplateStructure {
pub name: String,
pub description: String,
pub category: TemplateCategory,
pub complexity: ComplexityLevel,
pub required_features: Vec<String>,
pub optional_features: Vec<String>,
pub file_structure: HashMap<String, String>,
pub config_overrides: HashMap<String, serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplateMetadata {
pub id: String,
pub version: String,
pub author: String,
pub description: String,
pub created_at: chrono::DateTime<chrono::Utc>,
pub modified_at: chrono::DateTime<chrono::Utc>,
pub tags: Vec<String>,
pub rust_versions: Vec<String>,
pub license: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct TemplateParameter {
pub name: String,
pub description: String,
pub param_type: ParameterType,
pub default_value: Option<String>,
pub required: bool,
pub validation: Vec<ParameterValidation>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ParameterType {
String,
Integer,
Float,
Boolean,
Array(Box<ParameterType>),
Object(HashMap<String, ParameterType>),
Enum(Vec<String>),
Custom(String),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ParameterValidation {
MinLength(usize),
MaxLength(usize),
Pattern(String),
Range { min: f64, max: f64 },
OneOf(Vec<String>),
Custom(String),
}
impl TemplateMetadata {
pub fn new(id: String, version: String, author: String, description: String) -> Self {
let now = chrono::Utc::now();
Self {
id,
version,
author,
description,
created_at: now,
modified_at: now,
tags: Vec::new(),
rust_versions: vec!["1.70.0".to_string()],
license: "MIT".to_string(),
}
}
}
impl PluginTemplate {
pub fn new(metadata: TemplateMetadata, structure: EnhancedTemplateStructure) -> Self {
Self {
metadata,
structure,
parameters: Vec::new(),
content: String::new(),
dependencies: Vec::new(),
features: Vec::new(),
}
}
pub fn with_parameter(mut self, parameter: TemplateParameter) -> Self {
self.parameters.push(parameter);
self
}
pub fn with_dependency(mut self, dependency: String) -> Self {
self.dependencies.push(dependency);
self
}
}