feat: Specify (optional) interface name in PartialUserData
This commit is contained in:
@@ -4,6 +4,10 @@ use std::ops::Deref;
|
||||
|
||||
pub trait PartialUserData<T> {
|
||||
fn add_methods<M: mlua::UserDataMethods<T>>(methods: &mut M);
|
||||
|
||||
fn interface_name() -> Option<&'static str> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Device;
|
||||
@@ -15,6 +19,10 @@ where
|
||||
fn add_methods<M: mlua::UserDataMethods<T>>(methods: &mut M) {
|
||||
methods.add_async_method("get_id", async |_lua, this, _: ()| Ok(this.get_id()));
|
||||
}
|
||||
|
||||
fn interface_name() -> Option<&'static str> {
|
||||
Some("DeviceInterface")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OnOff;
|
||||
@@ -34,6 +42,10 @@ where
|
||||
Ok(this.deref().on().await.unwrap())
|
||||
});
|
||||
}
|
||||
|
||||
fn interface_name() -> Option<&'static str> {
|
||||
Some("OnOffInterface")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Brightness;
|
||||
@@ -53,6 +65,10 @@ where
|
||||
Ok(this.brightness().await.unwrap())
|
||||
});
|
||||
}
|
||||
|
||||
fn interface_name() -> Option<&'static str> {
|
||||
Some("BrightnessInterface")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ColorSetting;
|
||||
@@ -77,6 +93,10 @@ where
|
||||
Ok(this.color().await.temperature)
|
||||
});
|
||||
}
|
||||
|
||||
fn interface_name() -> Option<&'static str> {
|
||||
Some("ColorSettingInterface")
|
||||
}
|
||||
}
|
||||
|
||||
pub struct OpenClose;
|
||||
@@ -96,4 +116,8 @@ where
|
||||
Ok(this.open_percent().await.unwrap())
|
||||
});
|
||||
}
|
||||
|
||||
fn interface_name() -> Option<&'static str> {
|
||||
Some("OpenCloseInterface")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user