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
use ffi;
#[derive(Clone, Debug, PartialEq)]
pub struct Floorplan {
pub elements: Vec<FloorplanElement>,
}
#[derive(Clone, Debug, PartialEq)]
pub struct FloorplanElement {
pub id: String,
pub area: f64,
}
pub unsafe fn new(raw: &ffi::Floorplan_t) -> Floorplan {
let mut elements = vec![];
let mut cursor = raw.ElementsList.First;
for _ in 0..raw.ElementsList.Size {
assert!(!cursor.is_null());
elements.push(new_element(&(*cursor).Data));
cursor = (*cursor).Next;
}
Floorplan { elements: elements }
}
unsafe fn new_element(raw: &ffi::FloorplanElement_t) -> FloorplanElement {
FloorplanElement { id: c_str_to_string!(raw.Id), area: raw.Area }
}