Address clippy errors
parent
e126e87e47
commit
5fc0e5b3a2
|
@ -52,7 +52,7 @@ pub(crate) async fn run(
|
|||
let send = mqtt.publish("state", "disconnected").await;
|
||||
debug!(?config, ?send, "shutting down modbus connection");
|
||||
}
|
||||
Err(error) => handle_tx.send(Err(error.into())).unwrap(),
|
||||
Err(error) => handle_tx.send(Err(error)).unwrap(),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -243,8 +243,8 @@ impl Connection {
|
|||
// Os { code: 36, kind: Uncategorized, message: "Operation now in progress" }'
|
||||
// Os { code: 35, kind: WouldBlock, message: "Resource temporarily unavailable" }
|
||||
//
|
||||
match &response {
|
||||
Err(error) => match error.kind() {
|
||||
if let Err(error) = &response {
|
||||
match error.kind() {
|
||||
std::io::ErrorKind::UnexpectedEof => {
|
||||
// THIS happening feels like a bug either in how I am using tokio_modbus or in tokio_modbus. It seems
|
||||
// like the underlying buffers get all messed up and restarting doesn't always fix it unless I wait a
|
||||
|
@ -252,8 +252,7 @@ impl Connection {
|
|||
error!(?error, "Connection error, may not be recoverable");
|
||||
}
|
||||
_ => error!(?error),
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// This probably just means that the register task died or is no longer monitoring the response.
|
||||
|
|
|
@ -87,13 +87,13 @@ pub(crate) async fn subscribe(
|
|||
fn to_register(payload: &Payload) -> crate::Result<AddressedRegister> {
|
||||
let Payload { bytes, topic } = payload;
|
||||
let address = topic
|
||||
.rsplit("/")
|
||||
.rsplit('/')
|
||||
.next()
|
||||
.expect("subscribed topic guarantees we have a last segment")
|
||||
.parse()?;
|
||||
Ok(AddressedRegister {
|
||||
address,
|
||||
register: serde_json::from_slice(&bytes)?,
|
||||
register: serde_json::from_slice(bytes)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -101,13 +101,13 @@ pub(crate) async fn subscribe(
|
|||
select! {
|
||||
Some(ref payload) = input_registers.recv() => {
|
||||
match to_register(payload) {
|
||||
Ok(register) => if let Err(_) = tx.send((RegisterType::Input, register)).await { break; },
|
||||
Ok(register) => if (tx.send((RegisterType::Input, register)).await).is_err() { break; },
|
||||
Err(error) => warn!(?error, def=?payload.bytes, "ignoring invalid input register definition"),
|
||||
}
|
||||
},
|
||||
Some(ref payload) = holding_registers.recv() => {
|
||||
match to_register(payload) {
|
||||
Ok(register) => if let Err(_) = tx.send((RegisterType::Holding, register)).await { break; },
|
||||
Ok(register) => if (tx.send((RegisterType::Holding, register)).await).is_err() { break; },
|
||||
Err(error) => warn!(?error, def=?payload.bytes, "ignoring invalid holding register definition"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue