use super::{DESTINATION, PATH};
use crate::{helpers::receive_signal, Error};
#[derive(Debug)]
#[doc(alias = "org.freedesktop.portal.MemoryMonitor")]
pub struct MemoryMonitorProxy<'a>(zbus::Proxy<'a>);
impl<'a> MemoryMonitorProxy<'a> {
pub async fn new(connection: &zbus::Connection) -> Result<MemoryMonitorProxy<'a>, Error> {
let proxy = zbus::ProxyBuilder::new_bare(connection)
.interface("org.freedesktop.portal.MemoryMonitor")?
.path(PATH)?
.destination(DESTINATION)?
.build()
.await?;
Ok(Self(proxy))
}
pub fn inner(&self) -> &zbus::Proxy<'_> {
&self.0
}
#[doc(alias = "LowMemoryWarning")]
pub async fn receive_low_memory_warning(&self) -> Result<i32, Error> {
receive_signal(self.inner(), "LowMemoryWarning").await
}
}