zbus-old
zbus-old copied to clipboard
xmlgen to generate service-side (interface) code
If we want xmlgen to be as useful as similar tools (e.g gdbus-codegen), it needs to be able to generate service-side code as well (i-e dbus_interface). Unlike proxy, this will be mostly a template for user to fill in the implementation.
Unlike proxy, this will be mostly a template for user to fill in the implementation.
This would be the simpler route but it won't suffice if we want xmlgen to grow into a reusable tool that generates code as part of a build so its output can be used as is.
The better way would be to generate a trait (e.g OurInterface) and impl<T: OurInterface> zbus::Interface for T and then user can implement the generated OurInterface in their code. If we go this route, it'd be worthwhile to also look into making this work with dbus_interface itself. Many times you've the client and service in the same code base, so this would allow users to declare their API once (either in their XML or in the code):
#[dbus_interface(interface = "org.blah")]
#[dbus_proxy(interface = "org.blah")]
trait Blah {
fn blah(&self, arg: &str) -> Result<usize>;
}
// xmlgen can generate the above part.
struct BlahImpl;
impl Blah for BlahImpl {
fn blah(&self, arg: &str) -> Result<usize> {
Ok(arg.len())
}
}
Created #236 for the macros part.