1use crate::*;
2use azure_kinect_sys::k4a::*;
3use std::fmt::{Display, Formatter};
4
5#[derive(Copy, Clone, Debug, Default)]
6pub struct Dimension {
7 pub width: i32,
8 pub height: i32,
9}
10
11#[derive(Copy, Clone, Debug, Default)]
12pub struct Range<T> {
13 pub min: T,
14 pub max: T,
15}
16
17#[derive(Copy, Clone, Debug, Default)]
18pub struct Version {
19 pub(crate) value: k4a_version_t,
20}
21
22impl Version {
23 #[doc = "< Major version; represents a breaking change."]
24 pub fn major(&self) -> u32 {
25 self.value.major
26 }
27 #[doc = "< Minor version; represents additional features, no regression from lower versions with same major version."]
28 pub fn minor(&self) -> u32 {
29 self.value.minor
30 }
31 #[doc = "< Reserved."]
32 pub fn iteration(&self) -> u32 {
33 self.value.iteration
34 }
35}
36
37impl Display for Version {
38 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
39 write!(f, "{}.{}.{}", self.major(), self.minor(), self.iteration())
40 }
41}
42
43#[derive(Copy, Clone, Debug, Default)]
44pub struct HardwareVersion {
45 pub(crate) value: k4a_hardware_version_t,
46}
47
48impl HardwareVersion {
49 #[doc = "< Color camera firmware version."]
50 pub fn rgb(&self) -> Version {
51 Version {
52 value: self.value.rgb,
53 }
54 }
55 #[doc = "< Depth camera firmware version."]
56 pub fn depth(&self) -> Version {
57 Version {
58 value: self.value.depth,
59 }
60 }
61 #[doc = "< Audio device firmware version."]
62 pub fn audio(&self) -> Version {
63 Version {
64 value: self.value.audio,
65 }
66 }
67 #[doc = "< Depth sensor firmware version."]
68 pub fn depth_sensor(&self) -> Version {
69 Version {
70 value: self.value.depth_sensor,
71 }
72 }
73 #[doc = "< Build type reported by the firmware."]
74 pub fn firmware_build(&self) -> FirmwareBuildType {
75 FirmwareBuildType::from_primitive(self.value.firmware_build)
76 }
77 #[doc = "< Signature type of the firmware."]
78 pub fn firmware_signature(&self) -> FirmwareSignatureType {
79 FirmwareSignatureType::from_primitive(self.value.firmware_signature)
80 }
81}
82
83impl Display for HardwareVersion {
84 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
85 write!(f, "rgb: {}, depth: {}, audio: {}, depth_sensor: {}, firmware_build: {:?}, firmware_signature: {:?}",
86 self.rgb(), self.depth(), self.audio(), self.depth_sensor(), self.firmware_build(), self.firmware_signature())
87 }
88}