matrix2mqtt: clippy clean
This commit is contained in:
parent
ae4cfbcb09
commit
1180fff5c7
1 changed files with 11 additions and 14 deletions
|
@ -171,7 +171,7 @@ async fn read_single_mapping(
|
||||||
reader.read_line(&mut line).await?;
|
reader.read_line(&mut line).await?;
|
||||||
let splitter = line
|
let splitter = line
|
||||||
.strip_prefix("MP ")
|
.strip_prefix("MP ")
|
||||||
.and_then(|s| Some(s.split_whitespace()))
|
.map(|s| s.split_whitespace())
|
||||||
.ok_or(ParseMatrixPortError)?
|
.ok_or(ParseMatrixPortError)?
|
||||||
.collect::<Vec<&str>>();
|
.collect::<Vec<&str>>();
|
||||||
if splitter.len() != 2 {
|
if splitter.len() != 2 {
|
||||||
|
@ -287,16 +287,16 @@ async fn handle_publish(
|
||||||
matrix_command_tx
|
matrix_command_tx
|
||||||
.send(MatrixCommand::SetOutputCEC(destination, true))
|
.send(MatrixCommand::SetOutputCEC(destination, true))
|
||||||
.await?;
|
.await?;
|
||||||
},
|
}
|
||||||
"OFF" => {
|
"OFF" => {
|
||||||
println!("asked to turn {:#?} off", destination);
|
println!("asked to turn {:#?} off", destination);
|
||||||
matrix_command_tx
|
matrix_command_tx
|
||||||
.send(MatrixCommand::SetOutputCEC(destination, false))
|
.send(MatrixCommand::SetOutputCEC(destination, false))
|
||||||
.await?;
|
.await?;
|
||||||
},
|
}
|
||||||
s => {
|
s => {
|
||||||
println!("asked to set {:#?} to unknown value {}", destination, s)
|
println!("asked to set {:#?} to unknown value {}", destination, s)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
} else if let Some(destination_str) = p
|
} else if let Some(destination_str) = p
|
||||||
.topic
|
.topic
|
||||||
|
@ -400,7 +400,7 @@ where
|
||||||
I: futures::Future<Output = Result<T, E>> + Unpin,
|
I: futures::Future<Output = Result<T, E>> + Unpin,
|
||||||
{
|
{
|
||||||
let mut fvec = futures;
|
let mut fvec = futures;
|
||||||
while fvec.len() > 0 {
|
while !fvec.is_empty() {
|
||||||
let (item_resolved, _, remaining_futures) = future::select_all(fvec).await;
|
let (item_resolved, _, remaining_futures) = future::select_all(fvec).await;
|
||||||
item_resolved?;
|
item_resolved?;
|
||||||
fvec = remaining_futures;
|
fvec = remaining_futures;
|
||||||
|
@ -441,14 +441,11 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||||
loop {
|
loop {
|
||||||
select! {
|
select! {
|
||||||
notification = connection.poll() => {
|
notification = connection.poll() => {
|
||||||
match notification? {
|
if let rumqttc::Event::Incoming(rumqttc::Incoming::Publish(p)) = notification? {
|
||||||
rumqttc::Event::Incoming(rumqttc::Incoming::Publish(p)) => {
|
|
||||||
match handle_publish(&p, &mut mqtt_matrix_command_tx).await {
|
match handle_publish(&p, &mut mqtt_matrix_command_tx).await {
|
||||||
Ok(_) => {},
|
Ok(_) => {},
|
||||||
Err(e) => println!("failed to handle event {:#?}: {}", p, e),
|
Err(e) => println!("failed to handle event {:#?}: {}", p, e),
|
||||||
}
|
}
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Ok(matrix_response) = matrix_response_rx.recv() => {
|
Ok(matrix_response) = matrix_response_rx.recv() => {
|
||||||
|
|
Loading…
Reference in a new issue