zbus-old
zbus-old copied to clipboard
Controlling the visibility of the struct generated by the #[dbus_proxy] macro
In GitLab by @mominul on Jan 23, 2021, 18:01
Currently the struct and its members generated by the #[dbus_proxy] macro are pub by default.
I think it'd be great if we could control the visibility at least of the generated struct.
The macro would look for a visibility modifier in the trait declaration.
// It will be a public struct.
#[dbus_proxy(interface = "...")]
pub trait Interface {
//...
}
// It will be a internal struct.
#[dbus_proxy(interface = "...")]
trait Interface {
//...
}
// It will be a public in crate struct.
#[dbus_proxy(interface = "...")]
pub(crate) trait Interface {
//...
}
Thanks!
Definitely something we should support. Although keep in mind that we only make it pub in the current module, which means you can easily workaround this by putting your macro call in a module:
mod my_private {
// It will not be public
#[dbus_proxy(interface = "...")]
pub trait Interface {
//...
}
}
In GitLab by @mominul on Jan 24, 2021, 17:03
Oops, I thought that would be caught by the unreachable_pub lint, Sorry! :sweat:
Oops, I thought that would be caught by the
unreachable_publint, Sorry!
Probably you're right but you can always #[allow(..)] them.