spring_ai_rs/ai_interface/callback/command/command_data/
lua.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use std::ffi::CString;

use spring_ai_sys::{SCallLuaRulesCommand, SCallLuaUICommand};

use crate::ai_interface::callback::command::command_data::{CData, CommandData};

// Call Lua Rules data
pub struct CallLuaRulesCommandData {
    pub in_data: CString,
    pub in_size: i32,
    pub out_data: CString,
}

impl CommandData for CallLuaRulesCommandData {
    type CDataType = SCallLuaRulesCommand;

    fn c_data(&mut self) -> Self::CDataType {
        SCallLuaRulesCommand {
            inData: self.in_data.as_ptr(),
            inSize: self.in_size,
            ret_outData: self.out_data.clone().into_raw(),
        }
    }
}

impl CData for SCallLuaRulesCommand {}

// Call Lua UI data
pub struct CallLuaUICommandData {
    pub in_data: CString,
    pub in_size: i32,
    pub out_data: CString,
}

impl CommandData for CallLuaUICommandData {
    type CDataType = SCallLuaUICommand;

    fn c_data(&mut self) -> Self::CDataType {
        SCallLuaUICommand {
            inData: self.in_data.as_ptr(),
            inSize: self.in_size,
            ret_outData: self.out_data.clone().into_raw(),
        }
    }
}

impl CData for SCallLuaUICommand {}