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
use super::{DESTINATION, PATH};
use crate::Error;
/// The interface provides information about the user-selected system-wide power profile, to sandboxed applications.
/// It is not a portal in the strict sense, since it does not involve user interaction.
///
/// via a library API such as the GLib [`gio::PowerProfileMonitor`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/struct.PowerProfileMonitor.html) interface.
///
/// Wrapper of the DBus interface: [`org.freedesktop.portal.PowerProfileMonitor`](https://flatpak.github.io/xdg-desktop-portal/index.html#gdbus-org.freedesktop.portal.PowerProfileMonitor).
#[derive(Debug)]
#[doc(alias = "org.freedesktop.portal.PowerProfileMonitor")]
pub struct PowerProfileMonitorProxy<'a>(zbus::Proxy<'a>);
impl<'a> PowerProfileMonitorProxy<'a> {
/// Create a new instance of [`PowerProfileMonitorProxy`].
pub async fn new(connection: &zbus::Connection) -> Result<PowerProfileMonitorProxy<'a>, Error> {
let proxy = zbus::ProxyBuilder::new_bare(connection)
.interface("org.freedesktop.portal.PowerProfileMonitor")?
.path(PATH)?
.destination(DESTINATION)?
.build()
.await?;
Ok(Self(proxy))
}
/// Get a reference to the underlying Proxy.
pub fn inner(&self) -> &zbus::Proxy<'_> {
&self.0
}
/// Whether the power saver is enabled.
#[doc(alias = "power-saver-enabled")]
pub async fn is_enabled(&self) -> Result<bool, Error> {
self.inner()
.get_property::<bool>("power-saver-enabled")
.await
.map_err(From::from)
}
}