Skip to content

Commit 61c4ac8

Browse files
committed
Cargo fmt
1 parent 79d59f8 commit 61c4ac8

3 files changed

Lines changed: 36 additions & 32 deletions

File tree

src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ async fn main() -> Result<()> {
140140
ctrlc::set_handler(move || {
141141
running.store(false, Ordering::SeqCst);
142142
if let Ok(tx_guard) = shutdown_tx.lock()
143-
&& let Some(tx) = tx_guard.as_ref() {
144-
let _ = tx.send(UiMessage::Quit);
145-
}
143+
&& let Some(tx) = tx_guard.as_ref()
144+
{
145+
let _ = tx.send(UiMessage::Quit);
146+
}
146147
})
147148
.expect("Failed to set Ctrl-C handler");
148149
}

src/serial_io.rs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,25 +117,26 @@ impl SerialReader {
117117

118118
async fn write_to_log(&mut self, bytes: &[u8]) {
119119
if let Some(w) = &self.rx_log_writer
120-
&& let Ok(mut lw) = w.lock() {
121-
use std::io::Write;
120+
&& let Ok(mut lw) = w.lock()
121+
{
122+
use std::io::Write;
122123

123-
if self.log_ts {
124-
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
125-
}
124+
if self.log_ts {
125+
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
126+
}
126127

127-
if self.hex_mode {
128-
for (i, b) in bytes.iter().enumerate() {
129-
let separator = if i + 1 == bytes.len() { "" } else { " " };
130-
let _ = write!(lw, "{:02X}{}", b, separator);
131-
}
132-
let _ = writeln!(lw);
133-
} else {
134-
let _ = lw.write_all(bytes);
128+
if self.hex_mode {
129+
for (i, b) in bytes.iter().enumerate() {
130+
let separator = if i + 1 == bytes.len() { "" } else { " " };
131+
let _ = write!(lw, "{:02X}{}", b, separator);
135132
}
136-
137-
let _ = lw.flush();
133+
let _ = writeln!(lw);
134+
} else {
135+
let _ = lw.write_all(bytes);
138136
}
137+
138+
let _ = lw.flush();
139+
}
139140
}
140141
}
141142

src/ui/mod.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,29 +145,31 @@ async fn handle_enter_key(
145145
if !input.is_empty() {
146146
write_bytes_async(port, input.as_bytes()).await?;
147147
if let Some(w) = &ui_config.tx_log
148-
&& let Ok(mut lw) = w.lock() {
149-
use std::io::Write;
150-
if ui_config.log_ts {
151-
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
152-
}
153-
let _ = lw.write_all(input.as_bytes());
154-
let _ = lw.flush();
148+
&& let Ok(mut lw) = w.lock()
149+
{
150+
use std::io::Write;
151+
if ui_config.log_ts {
152+
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
155153
}
154+
let _ = lw.write_all(input.as_bytes());
155+
let _ = lw.flush();
156+
}
156157
}
157158

158159
// Send line ending
159160
let end = ui_config.line_ending.bytes();
160161
if !end.is_empty() {
161162
write_bytes_async(port, end).await?;
162163
if let Some(w) = &ui_config.tx_log
163-
&& let Ok(mut lw) = w.lock() {
164-
use std::io::Write;
165-
if ui_config.log_ts && input.is_empty() {
166-
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
167-
}
168-
let _ = lw.write_all(end);
169-
let _ = lw.flush();
164+
&& let Ok(mut lw) = w.lock()
165+
{
166+
use std::io::Write;
167+
if ui_config.log_ts && input.is_empty() {
168+
let _ = write!(lw, "[{}] ", Utc::now().format("%Y-%m-%d %H:%M:%S%.3f"));
170169
}
170+
let _ = lw.write_all(end);
171+
let _ = lw.flush();
172+
}
171173
}
172174

173175
Ok(())

0 commit comments

Comments
 (0)