Moved battery, os docking into a new "v1" module
Added all_info to a module in v1
This commit is contained in:
parent
8169dfd022
commit
1e5bda520a
16 changed files with 18 additions and 16 deletions
28
src/v1/battery/structs.rs
Normal file
28
src/v1/battery/structs.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Clone)]
|
||||
pub enum ChargingStatus {
|
||||
Charging,
|
||||
Battery,
|
||||
UNKNOWN,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Clone)]
|
||||
pub struct BatteryInfo {
|
||||
pub has_battery: bool,
|
||||
pub battery_percent: i8,
|
||||
pub charging_status: ChargingStatus,
|
||||
}
|
||||
|
||||
impl BatteryInfo {
|
||||
pub fn new() -> BatteryInfo {
|
||||
BatteryInfo {
|
||||
has_battery: false,
|
||||
battery_percent: 0,
|
||||
charging_status: ChargingStatus::UNKNOWN
|
||||
}
|
||||
}
|
||||
pub fn to_string(self) -> String {
|
||||
serde_json::to_string(&self).expect("Failed to parse into string")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue