#[cfg(feature = "service")]
use super::Error;
use super::Result;
#[cfg(feature = "service")]
use crate::{ObjectServer, interface, message::Header};
#[cfg(feature = "service")]
pub(crate) struct Introspectable;
#[cfg(feature = "service")]
#[interface(
name = "org.freedesktop.DBus.Introspectable",
introspection_docs = false
)]
impl Introspectable {
async fn introspect(
&self,
#[zbus(object_server)] server: &ObjectServer,
#[zbus(header)] header: Header<'_>,
) -> Result<String> {
let path = header.path().ok_or(crate::Error::MissingField)?;
let root = server.root().read().await;
let node = root
.get_child(path)
.ok_or_else(|| Error::UnknownObject(format!("Unknown object '{path}'")))?;
Ok(node.introspect().await)
}
}
#[cfg(feature = "proxy")]
#[crate::proxy(interface = "org.freedesktop.DBus.Introspectable", default_path = "/")]
pub trait Introspectable {
fn introspect(&self) -> Result<String>;
}