spring_ai_rs/ai_interface/callback/drawer/
point.rs1use std::ffi::CString;
2
3use spring_ai_sys::COMMAND_TO_ID_ENGINE;
4
5use crate::ai_interface::callback::{
6 command::{
7 command_data::{
8 drawer::{AddPointDrawCommandData, RemovePointDrawCommandData},
9 CommandData,
10 },
11 command_topic::CommandTopic,
12 },
13 engine::handle_command,
14};
15
16pub struct Point {
17 pub ai_id: i32,
18}
19
20impl Point {
21 pub fn add_point(&self, position: [f32; 3], label: &str) -> Result<(), String> {
22 let mut command_c_data = AddPointDrawCommandData {
23 position,
24 label: CString::new(label).map_err(|e| e.to_string())?,
25 }
26 .c_data();
27
28 handle_command(
29 self.ai_id,
30 COMMAND_TO_ID_ENGINE,
31 -1,
32 CommandTopic::DrawerPointAdd.into(),
33 &mut command_c_data,
34 )?;
35
36 Ok(())
37 }
38 pub fn remove_point(&self, position: [f32; 3]) -> Result<(), String> {
39 let mut command_c_data = RemovePointDrawCommandData { position }.c_data();
40
41 handle_command(
42 self.ai_id,
43 COMMAND_TO_ID_ENGINE,
44 -1,
45 CommandTopic::DrawerPointRemove.into(),
46 &mut command_c_data,
47 )?;
48
49 Ok(())
50 }
51}