//! # DBus interface proxy for: `org.asuslinux.Gfx` //! //! This code was generated by `zbus-xmlgen` `1.0.0` from DBus introspection data. //! Source: `Interface '/org/supergfxctl/Gfx' from service 'org.asuslinux.Daemon' on system bus`. //! //! You may prefer to adapt it, instead of using it verbatim. //! //! More information can be found in the //! [Writing a client proxy](https://zeenix.pages.freedesktop.org/zbus/client.html) //! section of the zbus documentation. //! //! This DBus object implements //! [standard DBus interfaces](https://dbus.freedesktop.org/doc/dbus-specification.html), //! (`org.freedesktop.DBus.*`) for which the following zbus proxies can be used: //! //! * [`zbus::fdo::PropertiesProxy`] //! * [`zbus::fdo::IntrospectableProxy`] //! * [`zbus::fdo::PeerProxy`] //! //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. use std::sync::mpsc::{Sender}; use zbus::{dbus_proxy, Connection, Message, Result}; use crate::{ gfx_vendors::{GfxPower, GfxRequiredUserAction, GfxVendors}, DBUS_IFACE_PATH, }; #[dbus_proxy(interface = "org.supergfxctl.Daemon")] trait Daemon { /// Power method fn power(&self) -> zbus::Result; /// SetVendor method fn set_vendor(&self, vendor: &GfxVendors) -> zbus::Result; /// Vendor method fn vendor(&self) -> zbus::Result; /// NotifyAction signal #[dbus_proxy(signal)] fn notify_action(&self, action: GfxRequiredUserAction) -> zbus::Result<()>; /// NotifyGfx signal #[dbus_proxy(signal)] fn notify_gfx(&self, vendor: GfxVendors) -> zbus::Result<()>; } pub struct GfxProxy<'a>(pub DaemonProxy<'a>); impl<'a> GfxProxy<'a> { #[inline] pub fn new(conn: &Connection) -> Result { let proxy = DaemonProxy::new_for(conn, "org.supergfxctl.Daemon", DBUS_IFACE_PATH)?; Ok(GfxProxy(proxy)) } #[inline] pub fn new_for(conn: &Connection, destination: &'a str, path: &'a str) -> Result { let proxy = DaemonProxy::new_for(conn, destination, path)?; Ok(GfxProxy(proxy)) } #[inline] pub fn new_for_owned(conn: Connection, destination: String, path: String) -> Result { let proxy = DaemonProxy::new_for_owned(conn, destination, path)?; Ok(GfxProxy(proxy)) } #[inline] pub fn proxy(&self) -> &DaemonProxy<'a> { &self.0 } #[inline] pub fn gfx_get_pwr(&self) -> Result { self.0.power() } #[inline] pub fn gfx_get_mode(&self) -> Result { self.0.vendor() } #[inline] pub fn gfx_write_mode(&self, vendor: &GfxVendors) -> Result { self.0.set_vendor(vendor) } #[inline] pub fn connect_notify_action( &self, send: Sender, ) -> zbus::fdo::Result<()> { self.0.connect_notify_action(move |data| { send.send(data) .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; Ok(()) }) } #[inline] pub fn connect_notify_gfx(&self, send: Sender) -> zbus::fdo::Result<()> { self.0.connect_notify_gfx(move |data| { send.send(data) .map_err(|err| zbus::fdo::Error::Failed(err.to_string()))?; Ok(()) }) } #[inline] pub fn next_signal(&self) -> Result> { self.0.next_signal() } }