dji_log_parser/record/
custom.rs

1use binrw::binread;
2use chrono::{DateTime, Datelike, Utc};
3use serde::Serialize;
4#[cfg(target_arch = "wasm32")]
5use tsify_next::Tsify;
6
7#[binread]
8#[derive(Serialize, Debug)]
9#[serde(rename_all = "camelCase")]
10#[br(little)]
11#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
12pub struct Custom {
13    #[br(temp)]
14    _camera_shoot: u8,
15    #[br(temp)]
16    _video_shoot: u8,
17    pub h_speed: f32,
18    pub distance: f32,
19    #[br(
20        map = |x: i64| DateTime::from_timestamp(x / 1000, (x % 1000 * 1000000) as u32).unwrap_or_default(),
21        // We ensure the year is between 2010 and 2100 to avoid invalid data
22        assert(update_timestamp.year() > 2010 && update_timestamp.year() < 2100)
23    )]
24    #[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
25    pub update_timestamp: DateTime<Utc>,
26}