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:
@@ -81,7 +81,7 @@ impl From<StatePower> for StateOnOff {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Device)]
|
||||
#[device(traits(OnOff for <StateOnOff>, <StatePower>))]
|
||||
#[device(traits(OnOff for OutletOnOff, OutletPower))]
|
||||
pub struct Outlet<T: OutletState> {
|
||||
config: Config<T>,
|
||||
|
||||
@@ -131,7 +131,7 @@ impl<T: OutletState> Device for Outlet<T> {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OnMqtt for Outlet<StateOnOff> {
|
||||
impl OnMqtt for OutletOnOff {
|
||||
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) {
|
||||
@@ -164,7 +164,7 @@ impl OnMqtt for Outlet<StateOnOff> {
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl OnMqtt for Outlet<StatePower> {
|
||||
impl OnMqtt for OutletPower {
|
||||
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