feat!: Use type alias instead of generic parameters in device macro
This enforced the idea that all generics must be specified for the type when using the device macro. It will also come into play later when the Typed macro gets introduced, as the name will be used when generating definitions.
This commit is contained in:
@@ -89,9 +89,9 @@ impl From<StateColorTemperature> for StateBrightness {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Device)]
|
||||
#[device(traits(OnOff for <StateOnOff>, <StateBrightness>, <StateColorTemperature>))]
|
||||
#[device(traits(Brightness for <StateBrightness>, <StateColorTemperature>))]
|
||||
#[device(traits(ColorSetting for <StateColorTemperature>))]
|
||||
#[device(traits(OnOff for LightOnOff, LightBrightness, LightColorTemperature))]
|
||||
#[device(traits(Brightness for LightBrightness, LightColorTemperature))]
|
||||
#[device(traits(ColorSetting for LightColorTemperature))]
|
||||
pub struct Light<T: LightState> {
|
||||
config: Config<T>,
|
||||
|
||||
@@ -144,7 +144,7 @@ impl<T: LightState> Device for Light<T> {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OnMqtt for Light<StateOnOff> {
|
||||
impl OnMqtt for LightOnOff {
|
||||
async fn on_mqtt(&self, message: Publish) {
|
||||
// Check if the message is from the device itself or from a remote
|
||||
if matches(&message.topic, &self.config.mqtt.topic) {
|
||||
@@ -177,7 +177,7 @@ impl OnMqtt for Light<StateOnOff> {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OnMqtt for Light<StateBrightness> {
|
||||
impl OnMqtt for LightBrightness {
|
||||
async fn on_mqtt(&self, message: Publish) {
|
||||
// Check if the message is from the deviec itself or from a remote
|
||||
if matches(&message.topic, &self.config.mqtt.topic) {
|
||||
@@ -216,7 +216,7 @@ impl OnMqtt for Light<StateBrightness> {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OnMqtt for Light<StateColorTemperature> {
|
||||
impl OnMqtt for LightColorTemperature {
|
||||
async fn on_mqtt(&self, message: Publish) {
|
||||
// Check if the message is from the deviec itself or from a remote
|
||||
if matches(&message.topic, &self.config.mqtt.topic) {
|
||||
|
||||
Reference in New Issue
Block a user