1use super::Aether;
2use crate::stdlib;
3
4impl Aether {
5 pub fn load_stdlib_module(&mut self, module_name: &str) -> Result<(), String> {
9 if let Some(code) = stdlib::get_module(module_name) {
10 self.eval(code)?;
11 Ok(())
12 } else {
13 Err(format!("Unknown stdlib module: {}", module_name))
14 }
15 }
16
17 pub fn load_all_stdlib(&mut self) -> Result<(), String> {
19 stdlib::preload_stdlib(self)
20 }
21
22 pub fn with_stdlib_string_utils(mut self) -> Result<Self, String> {
28 if let Some(code) = stdlib::get_module("string_utils") {
29 self.eval(code)?;
30 }
31 Ok(self)
32 }
33
34 pub fn with_stdlib_array_utils(mut self) -> Result<Self, String> {
36 if let Some(code) = stdlib::get_module("array_utils") {
37 self.eval(code)?;
38 }
39 Ok(self)
40 }
41
42 pub fn with_stdlib_validation(mut self) -> Result<Self, String> {
44 if let Some(code) = stdlib::get_module("validation") {
45 self.eval(code)?;
46 }
47 Ok(self)
48 }
49
50 pub fn with_stdlib_datetime(mut self) -> Result<Self, String> {
52 if let Some(code) = stdlib::get_module("datetime") {
53 self.eval(code)?;
54 }
55 Ok(self)
56 }
57
58 pub fn with_stdlib_testing(mut self) -> Result<Self, String> {
60 if let Some(code) = stdlib::get_module("testing") {
61 self.eval(code)?;
62 }
63 Ok(self)
64 }
65
66 pub fn with_stdlib_set(mut self) -> Result<Self, String> {
68 if let Some(code) = stdlib::get_module("set") {
69 self.eval(code)?;
70 }
71 Ok(self)
72 }
73
74 pub fn with_stdlib_queue(mut self) -> Result<Self, String> {
76 if let Some(code) = stdlib::get_module("queue") {
77 self.eval(code)?;
78 }
79 Ok(self)
80 }
81
82 pub fn with_stdlib_stack(mut self) -> Result<Self, String> {
84 if let Some(code) = stdlib::get_module("stack") {
85 self.eval(code)?;
86 }
87 Ok(self)
88 }
89
90 pub fn with_stdlib_heap(mut self) -> Result<Self, String> {
92 if let Some(code) = stdlib::get_module("heap") {
93 self.eval(code)?;
94 }
95 Ok(self)
96 }
97
98 pub fn with_stdlib_sorting(mut self) -> Result<Self, String> {
100 if let Some(code) = stdlib::get_module("sorting") {
101 self.eval(code)?;
102 }
103 Ok(self)
104 }
105
106 pub fn with_stdlib_json(mut self) -> Result<Self, String> {
108 if let Some(code) = stdlib::get_module("json") {
109 self.eval(code)?;
110 }
111 Ok(self)
112 }
113
114 pub fn with_stdlib_csv(mut self) -> Result<Self, String> {
116 if let Some(code) = stdlib::get_module("csv") {
117 self.eval(code)?;
118 }
119 Ok(self)
120 }
121
122 pub fn with_stdlib_functional(mut self) -> Result<Self, String> {
124 if let Some(code) = stdlib::get_module("functional") {
125 self.eval(code)?;
126 }
127 Ok(self)
128 }
129
130 pub fn with_stdlib_cli_utils(mut self) -> Result<Self, String> {
132 if let Some(code) = stdlib::get_module("cli_utils") {
133 self.eval(code)?;
134 }
135 Ok(self)
136 }
137
138 pub fn with_stdlib_text_template(mut self) -> Result<Self, String> {
140 if let Some(code) = stdlib::get_module("text_template") {
141 self.eval(code)?;
142 }
143 Ok(self)
144 }
145
146 pub fn with_stdlib_regex_utils(mut self) -> Result<Self, String> {
148 if let Some(code) = stdlib::get_module("regex_utils") {
149 self.eval(code)?;
150 }
151 Ok(self)
152 }
153}