gestura_core_scripting/
runtime.rs1use gestura_core_foundation::error::AppError;
4
5pub struct LuaRuntime;
9
10impl LuaRuntime {
11 pub fn new() -> Result<Self, AppError> {
13 Ok(Self)
15 }
16
17 pub async fn execute(
19 &self,
20 code: &str,
21 ) -> Result<(Option<serde_json::Value>, String, Vec<String>), AppError> {
22 tracing::info!("Executing Lua code: {}", &code[..code.len().min(50)]);
24 tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
25
26 Ok((
27 Some(serde_json::json!({"result": "lua_executed"})),
28 "Lua script executed successfully".to_string(),
29 Vec::new(),
30 ))
31 }
32}
33
34impl Default for LuaRuntime {
35 fn default() -> Self {
36 Self::new().expect("Failed to create Lua runtime")
37 }
38}
39
40pub struct PythonRuntime;
44
45impl PythonRuntime {
46 pub fn new() -> Result<Self, AppError> {
48 Ok(Self)
50 }
51
52 pub async fn execute(
54 &self,
55 code: &str,
56 ) -> Result<(Option<serde_json::Value>, String, Vec<String>), AppError> {
57 tracing::info!("Executing Python code: {}", &code[..code.len().min(50)]);
59 tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
60
61 Ok((
62 Some(serde_json::json!({"result": "python_executed"})),
63 "Python script executed successfully".to_string(),
64 Vec::new(),
65 ))
66 }
67}
68
69impl Default for PythonRuntime {
70 fn default() -> Self {
71 Self::new().expect("Failed to create Python runtime")
72 }
73}
74
75pub struct JavaScriptRuntime;
79
80impl JavaScriptRuntime {
81 pub fn new() -> Result<Self, AppError> {
83 Ok(Self)
85 }
86
87 pub async fn execute(
89 &self,
90 code: &str,
91 ) -> Result<(Option<serde_json::Value>, String, Vec<String>), AppError> {
92 tracing::info!("Executing JavaScript code: {}", &code[..code.len().min(50)]);
94 tokio::time::sleep(tokio::time::Duration::from_millis(10)).await;
95
96 Ok((
97 Some(serde_json::json!({"result": "js_executed"})),
98 "JavaScript executed successfully".to_string(),
99 Vec::new(),
100 ))
101 }
102}
103
104impl Default for JavaScriptRuntime {
105 fn default() -> Self {
106 Self::new().expect("Failed to create JavaScript runtime")
107 }
108}