types/
db.rs

1//! All database related types.
2
3use chrono::DateTime;
4use sqlx::FromRow;
5
6use crate::cv::Gps;
7
8/// A GPS coordinate struct which is used when interacting with the database.
9#[derive(FromRow, Clone)]
10pub struct GPSRow {
11    pub timestamp: i64,
12    pub lat: f64,
13    pub long: f64,
14    pub alt: f64,
15    pub heading: f64,
16}
17
18impl From<GPSRow> for Gps {
19    fn from(val: GPSRow) -> Self {
20        Gps {
21            lat: val.lat,
22            long: val.long,
23            alt: val.alt,
24            heading: val.heading,
25            time: DateTime::from_timestamp_millis(val.timestamp).unwrap(),
26        }
27    }
28}
29
30/// A detected object struct which is used when interacting with the database.
31#[derive(FromRow, Clone)]
32pub struct ObjectRow {
33    pub lat: f64,
34    pub long: f64,
35    pub class: i32,
36    pub max_confidence: f32,
37    pub num_detections: i32,
38    pub original_filepath: String,
39}