ic/iris/unclassified/
flat.rs

1use derive_more::Constructor;
2
3use crate::UnclassifiedIris;
4
5#[derive(serde::Deserialize, Constructor, Clone, Copy, Debug, PartialEq, tabled::Tabled)]
6pub struct FlatUnclassifiedIris {
7    pub sepal_length: f32,
8    pub sepal_width: f32,
9    pub petal_length: f32,
10    pub petal_width: f32,
11}
12
13// CRUD-C: Constructors
14impl From<[f32; 4]> for FlatUnclassifiedIris {
15    fn from([sepal_length, sepal_width, petal_length, petal_width]: [f32; 4]) -> Self {
16        Self {
17            sepal_length,
18            sepal_width,
19            petal_length,
20            petal_width,
21        }
22    }
23}
24// CRUD-C: Conversions
25impl From<UnclassifiedIris> for FlatUnclassifiedIris {
26    fn from(unclassified_iris: UnclassifiedIris) -> Self {
27        let [sepal_length, sepal_width, petal_length, petal_width] = unclassified_iris.into();
28        Self {
29            sepal_length,
30            sepal_width,
31            petal_length,
32            petal_width,
33        }
34    }
35}
36// CRUD-D: Deconstructors
37impl From<FlatUnclassifiedIris> for [f32; 4] {
38    fn from(record: FlatUnclassifiedIris) -> Self {
39        [
40            record.sepal_length,
41            record.sepal_width,
42            record.petal_length,
43            record.petal_width,
44        ]
45    }
46}