sea_core/parser/
profiles.rs1use std::collections::HashSet;
2use std::sync::OnceLock;
3
4#[derive(Debug, Clone)]
5pub struct Profile {
6 name: String,
7 description: String,
8 allowed_features: HashSet<String>,
9}
10
11impl Profile {
12 pub fn new(name: &str, description: &str, features: &[&str]) -> Self {
13 Self {
14 name: name.to_string(),
15 description: description.to_string(),
16 allowed_features: features.iter().map(|s| s.to_string()).collect(),
17 }
18 }
19
20 pub fn is_feature_allowed(&self, feature: &str) -> bool {
21 self.allowed_features.contains(feature)
22 }
23
24 pub fn name(&self) -> &str {
25 &self.name
26 }
27
28 pub fn description(&self) -> &str {
29 &self.description
30 }
31
32 pub fn allowed_features(&self) -> &HashSet<String> {
33 &self.allowed_features
34 }
35}
36
37pub struct ProfileRegistry {
38 profiles: Vec<Profile>,
39}
40
41impl ProfileRegistry {
42 fn new() -> Self {
43 let profiles = vec![
44 Profile::new(
46 "default",
47 "Standard SEA DSL profile with all core features",
48 &["core", "cloud", "data"],
49 ),
50 Profile::new("cloud", "Cloud infrastructure modeling", &["core", "cloud"]),
52 Profile::new("data", "Data modeling and governance", &["core", "data"]),
54 ];
55
56 Self { profiles }
57 }
58
59 pub fn get(&self, name: &str) -> Option<&Profile> {
60 self.profiles.iter().find(|p| p.name == name)
61 }
62
63 pub fn list_names(&self) -> Vec<&str> {
64 self.profiles.iter().map(|p| p.name.as_str()).collect()
65 }
66
67 pub fn global() -> &'static ProfileRegistry {
68 static REGISTRY: OnceLock<ProfileRegistry> = OnceLock::new();
69 REGISTRY.get_or_init(ProfileRegistry::new)
70 }
71}