Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions zbus_xmlgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,22 @@ impl<'i> Display for GenTrait<'i> {
props.sort_by(|a, b| a.name().partial_cmp(&b.name()).unwrap());
for p in props {
let name = to_identifier(&to_snakecase(p.name().as_str()));
let fn_attribute = if pascal_case(&name) != p.name().as_str() {
format!(" #[dbus_proxy(property, name = \"{}\")]", p.name())
} else {
" #[dbus_proxy(property)]".to_string()
};

writeln!(f)?;
writeln!(f, " /// {} property", p.name())?;
if pascal_case(&name) != p.name().as_str() {
writeln!(f, " #[dbus_proxy(property, name = \"{}\")]", p.name())?;
} else {
writeln!(f, " #[dbus_proxy(property)]")?;
}

Comment thread
zeenix marked this conversation as resolved.
if p.access().read() {
writeln!(f, "{}", fn_attribute)?;
let output = to_rust_type(p.ty(), false, false);
writeln!(f, " fn {name}(&self) -> zbus::Result<{output}>;",)?;
}

if p.access().write() {
writeln!(f, "{}", fn_attribute)?;
let input = to_rust_type(p.ty(), true, true);
writeln!(
f,
Expand Down
1 change: 1 addition & 0 deletions zbus_xmlgen/tests/data/sample_object0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ trait SampleInterface0 {
/// Bar property
#[dbus_proxy(property)]
fn bar(&self) -> zbus::Result<u8>;
#[dbus_proxy(property)]
fn set_bar(&self, value: u8) -> zbus::Result<()>;
}