brainwires_code_interpreters/
lib.rs1#![deny(missing_docs)]
2mod executor;
33mod languages;
34mod types;
35
36#[cfg(feature = "docker")]
37pub mod docker;
38
39#[cfg(feature = "wasm")]
40mod wasm_bindings;
41
42pub use executor::Executor;
43pub use types::*;
44
45pub mod lang {
47 #[cfg(feature = "rhai")]
48 pub use crate::languages::rhai::RhaiExecutor;
49
50 #[cfg(feature = "lua")]
51 pub use crate::languages::lua::LuaExecutor;
52
53 #[cfg(feature = "javascript")]
54 pub use crate::languages::javascript::JavaScriptExecutor;
55
56 #[cfg(feature = "python")]
57 pub use crate::languages::python::PythonExecutor;
58}
59
60#[allow(clippy::vec_init_then_push)]
62pub fn supported_languages() -> Vec<Language> {
63 let mut languages = Vec::new();
64
65 #[cfg(feature = "rhai")]
66 languages.push(Language::Rhai);
67
68 #[cfg(feature = "lua")]
69 languages.push(Language::Lua);
70
71 #[cfg(feature = "javascript")]
72 languages.push(Language::JavaScript);
73
74 #[cfg(feature = "python")]
75 languages.push(Language::Python);
76
77 languages
78}
79
80pub fn is_language_supported(language: Language) -> bool {
82 match language {
83 #[cfg(feature = "rhai")]
84 Language::Rhai => true,
85
86 #[cfg(feature = "lua")]
87 Language::Lua => true,
88
89 #[cfg(feature = "javascript")]
90 Language::JavaScript => true,
91
92 #[cfg(feature = "python")]
93 Language::Python => true,
94
95 #[allow(unreachable_patterns)]
96 _ => false,
97 }
98}