Skip to content

Commit bd86bf2

Browse files
committed
cleanup
1 parent f04c0ed commit bd86bf2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/data/shelly/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ pub fn parse<'a, T: Deserialize<'a> + Clone>(msg: &'a Message) -> Result<T> {
3939
Ok(serde_json::from_slice::<T>(msg.payload())?)
4040
}
4141

42-
type SwitchDataMapper = fn(data: &SwitchData) -> Option<WriteType>;
42+
type WriteTypeMapper<T> = fn(&T) -> Option<WriteType>;
4343

44-
const SWITCH_FIELDS: &[(&str, SwitchDataMapper, &str)] = &[
44+
const SWITCH_FIELDS: &[(&str, WriteTypeMapper<SwitchData>, &str)] = &[
4545
(
4646
"output",
4747
|data: &SwitchData| Some(WriteType::Int(data.output as i32)),
@@ -74,8 +74,7 @@ const SWITCH_FIELDS: &[(&str, SwitchDataMapper, &str)] = &[
7474
),
7575
];
7676

77-
type CoverDataMapper = fn(data: &CoverData) -> Option<WriteType>;
78-
const COVER_FIELDS: &[(&str, CoverDataMapper, &str)] = &[
77+
const COVER_FIELDS: &[(&str, WriteTypeMapper<CoverData>, &str)] = &[
7978
(
8079
"position",
8180
|data: &CoverData| data.position.map(WriteType::Int),
@@ -127,7 +126,7 @@ impl CheckMessage for ShellyLogger {
127126
fn handle_message<'a, T: Deserialize<'a> + Clone + Debug + Timestamped + Typenamed>(
128127
msg: &'a Message,
129128
txs: &Vec<SyncSender<WriteQuery>>,
130-
fields: &[(&str, fn(&T) -> Option<WriteType>, &str)],
129+
fields: &[(&str, WriteTypeMapper<T>, &str)],
131130
) {
132131
let location = msg.topic().split("/").nth(1).unwrap();
133132
let channel = msg.topic().split(":").last().unwrap();

0 commit comments

Comments
 (0)