This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdevice.rs
122 lines (94 loc) · 2.93 KB
/
device.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright 2021 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0
use serde_repr::{Deserialize_repr, Serialize_repr};
use zbus::dbus_proxy;
use zbus::zvariant::OwnedValue;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Deserialize_repr, Serialize_repr, OwnedValue)]
#[repr(u32)]
pub enum BatteryState {
Unknown = 0,
Charging = 1,
Discharging = 2,
Empty = 3,
FullyCharged = 4,
PendingCharge = 5,
PendingDischarge = 6,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Deserialize_repr, Serialize_repr, OwnedValue)]
#[repr(u32)]
pub enum BatteryType {
Unknown = 0,
LinePower = 1,
Battery = 2,
Ups = 3,
Monitor = 4,
Mouse = 5,
Keyboard = 6,
Pda = 7,
Phone = 8,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Deserialize_repr, Serialize_repr, OwnedValue)]
#[repr(u32)]
pub enum BatteryLevel {
Unknown = 0,
None = 1,
Low = 3,
Critical = 4,
Normal = 6,
High = 7,
Full = 8,
}
#[dbus_proxy(
interface = "org.freedesktop.UPower.Device",
default_service = "org.freedesktop.UPower",
assume_defaults = false
)]
trait Device {
#[dbus_proxy(property)]
fn battery_level(&self) -> zbus::Result<BatteryLevel>;
#[dbus_proxy(property)]
fn capacity(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn energy(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn energy_empty(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn energy_full(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn energy_full_design(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn has_history(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
fn has_statistics(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
fn icon_name(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
fn is_present(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
fn is_rechargeable(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
fn luminosity(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn model(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
fn native_path(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
fn online(&self) -> zbus::Result<bool>;
#[dbus_proxy(property)]
fn percentage(&self) -> zbus::Result<f64>;
#[dbus_proxy(property)]
fn power_supply(&self) -> zbus::Result<bool>;
fn refresh(&self) -> zbus::Result<()>;
#[dbus_proxy(property)]
fn serial(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
fn state(&self) -> zbus::Result<BatteryState>;
#[dbus_proxy(property)]
fn temperature(&self) -> zbus::Result<f64>;
#[dbus_proxy(property, name = "Type")]
fn type_(&self) -> zbus::Result<BatteryType>;
#[dbus_proxy(property)]
fn vendor(&self) -> zbus::Result<String>;
#[dbus_proxy(property)]
fn voltage(&self) -> zbus::Result<f64>;
}