Skip to main content

airsim_client/types/
simulation.rs

1use msgpack_rpc::{message::Response, Value};
2
3#[derive(Debug, Clone)]
4/// List containing all the names of objects in the simulation scene
5pub struct SceneObjects(pub Vec<String>);
6
7impl From<Response> for SceneObjects {
8    fn from(msgpack: Response) -> Self {
9        let mut objects = vec![];
10
11        match msgpack.result {
12            Ok(res) => {
13                let payload: &Vec<Value> = res.as_array().unwrap();
14                for s in payload {
15                    let s = s.as_str().unwrap().to_string();
16                    objects.push(s);
17                }
18            }
19            Err(_) => panic!("Could not decode result from SceneObjects msgpack"),
20        };
21
22        SceneObjects(objects)
23    }
24}