use super::Aether;
use crate::stdlib;
impl Aether {
pub fn load_stdlib_module(&mut self, module_name: &str) -> Result<(), String> {
if let Some(code) = stdlib::get_module(module_name) {
self.eval(code)?;
Ok(())
} else {
Err(format!("Unknown stdlib module: {}", module_name))
}
}
pub fn load_all_stdlib(&mut self) -> Result<(), String> {
stdlib::preload_stdlib(self)
}
pub fn with_stdlib_string_utils(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("string_utils") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_array_utils(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("array_utils") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_validation(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("validation") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_datetime(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("datetime") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_testing(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("testing") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_set(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("set") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_queue(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("queue") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_stack(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("stack") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_heap(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("heap") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_sorting(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("sorting") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_json(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("json") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_csv(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("csv") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_functional(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("functional") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_cli_utils(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("cli_utils") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_text_template(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("text_template") {
self.eval(code)?;
}
Ok(self)
}
pub fn with_stdlib_regex_utils(mut self) -> Result<Self, String> {
if let Some(code) = stdlib::get_module("regex_utils") {
self.eval(code)?;
}
Ok(self)
}
}