dji_log_parser/record/
recover.rs1use binrw::binread;
2use chrono::{DateTime, Utc};
3use serde::Serialize;
4#[cfg(target_arch = "wasm32")]
5use tsify_next::Tsify;
6
7use crate::layout::details::{Platform, ProductType};
8
9#[binread]
10#[derive(Serialize, Debug)]
11#[serde(rename_all = "camelCase")]
12#[br(little, import {version: u8})]
13#[cfg_attr(target_arch = "wasm32", derive(Tsify))]
14pub struct Recover {
15 #[br(map = |x: u8| ProductType::from(x))]
16 pub product_type: ProductType,
17 #[br(map = |x: u8| Platform::from(x))]
18 pub app_platform: Platform,
19 #[br(map = |x: [u8; 3]| format!("{}.{}.{}", x[0], x[1], x[2]))]
20 pub app_version: String,
21 #[br(count = if version <= 7 { 10 } else { 16 }, map = |s: Vec<u8>| String::from_utf8_lossy(&s).trim_end_matches('\0').to_string())]
22 pub aircraft_sn: String,
23 #[br(count = 32, map = |s: Vec<u8>| String::from_utf8_lossy(&s).trim_end_matches('\0').to_string())]
24 pub aircraft_name: String,
25 #[br(map = |x: i64| DateTime::from_timestamp(x, 0).unwrap_or_default())]
26 #[cfg_attr(target_arch = "wasm32", tsify(type = "string"))]
27 pub timestamp: DateTime<Utc>,
28 #[br(count = if version <= 7 { 10 } else { 16 }, map = |s: Vec<u8>| String::from_utf8_lossy(&s).trim_end_matches('\0').to_string())]
29 pub camera_sn: String,
30 #[br(count = if version <= 7 { 10 } else { 16 }, map = |s: Vec<u8>| String::from_utf8_lossy(&s).trim_end_matches('\0').to_string())]
31 pub rc_sn: String,
32 #[br(count = if version <= 7 { 10 } else { 16 }, map = |s: Vec<u8>| String::from_utf8_lossy(&s).trim_end_matches('\0').to_string())]
33 pub battery_sn: String,
34}