Skip to main content

huawei_dongle_api/models/
device.rs

1//! Device information models
2
3use super::enums::DeviceControlType;
4use serde::{Deserialize, Serialize};
5
6/// Device information response
7#[derive(Debug, Clone, Serialize, Deserialize)]
8#[serde(rename = "response")]
9pub struct DeviceInformation {
10    #[serde(rename = "DeviceName")]
11    pub device_name: String,
12
13    #[serde(rename = "SerialNumber")]
14    pub serial_number: String,
15
16    #[serde(rename = "Imei")]
17    pub imei: String,
18
19    #[serde(rename = "Imsi")]
20    pub imsi: Option<String>,
21
22    #[serde(rename = "Iccid")]
23    pub iccid: Option<String>,
24
25    #[serde(rename = "Msisdn")]
26    pub msisdn: Option<String>,
27
28    #[serde(rename = "HardwareVersion")]
29    pub hardware_version: String,
30
31    #[serde(rename = "SoftwareVersion")]
32    pub software_version: String,
33
34    #[serde(rename = "WebUIVersion")]
35    pub webui_version: Option<String>,
36
37    #[serde(rename = "MacAddress1")]
38    pub mac_address1: Option<String>,
39
40    #[serde(rename = "MacAddress2")]
41    pub mac_address2: Option<String>,
42
43    #[serde(rename = "ProductFamily")]
44    pub product_family: Option<String>,
45
46    #[serde(rename = "Classify")]
47    pub classify: Option<String>,
48
49    #[serde(rename = "supportmode")]
50    pub support_mode: Option<String>,
51
52    #[serde(rename = "workmode")]
53    pub work_mode: Option<String>,
54}
55
56/// Device control request for operations like reboot
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(rename = "request")]
59pub struct DeviceControlRequest {
60    #[serde(rename = "Control")]
61    pub control: DeviceControlType,
62}
63
64impl DeviceControlRequest {
65    /// Create a reboot request
66    pub fn reboot() -> Self {
67        Self {
68            control: DeviceControlType::Reboot,
69        }
70    }
71
72    /// Create a power off request  
73    pub fn power_off() -> Self {
74        Self {
75            control: DeviceControlType::PowerOff,
76        }
77    }
78
79    /// Create a factory reset request
80    pub fn factory_reset() -> Self {
81        Self {
82            control: DeviceControlType::FactoryReset,
83        }
84    }
85
86    /// Create a backup configuration request
87    pub fn backup_configuration() -> Self {
88        Self {
89            control: DeviceControlType::BackupConfiguration,
90        }
91    }
92}