chore: fix import ordering and formatting in core and client

This commit is contained in:
2026-06-14 04:12:37 +08:00
parent 4e4c9cee65
commit ee65e284c4
6 changed files with 44 additions and 42 deletions

View File

@@ -1,4 +1,3 @@
use serde::{Deserialize, Serialize};
use pipeview_core::frame::{
Endian, Framer,
cobs::CobsFramer,
@@ -15,6 +14,7 @@ use pipeview_core::protocol::{
text::{TextDecoder, TextEncoding},
};
use pipeview_core::transport::TransportConfig;
use serde::{Deserialize, Serialize};
use crate::error::Result;
use crate::lua::codec::{LuaDecoder, LuaFramer};

View File

@@ -2,10 +2,10 @@ use std::fs;
use std::sync::Mutex;
use mlua::{Function, Lua, RegistryKey, Table, Value};
use tracing::warn;
use pipeview_core::frame::Framer;
use pipeview_core::protocol::plot::{PlotFormat, PlotFrame, SampleType};
use pipeview_core::protocol::{DecodedData, ProtocolDecoder};
use tracing::warn;
use crate::error::{Error, Result};

View File

@@ -6,9 +6,9 @@ use std::sync::{
use std::time::Duration;
use mlua::{Function, Lua, LuaSerdeExt, RegistryKey, UserData, UserDataMethods, Value, Variadic};
use pipeview_core::protocol::DecodedData;
use tokio::sync::mpsc;
use tokio::task::JoinHandle;
use pipeview_core::protocol::DecodedData;
use crate::config::SessionConfig;
use crate::lua::LuaRuntime;

View File

@@ -173,22 +173,18 @@ impl Connection {
pub fn set_dtr(&mut self, state: bool) -> Result<()> {
match self {
Connection::Serial(t) => t.set_dtr(state),
Connection::Tcp(_) | Connection::Udp(_) => {
Err(crate::error::Error::ConnectionFailed(
"DTR only supported on Serial connections".into(),
))
}
Connection::Tcp(_) | Connection::Udp(_) => Err(crate::error::Error::ConnectionFailed(
"DTR only supported on Serial connections".into(),
)),
}
}
pub fn set_rts(&mut self, state: bool) -> Result<()> {
match self {
Connection::Serial(t) => t.set_rts(state),
Connection::Tcp(_) | Connection::Udp(_) => {
Err(crate::error::Error::ConnectionFailed(
"RTS only supported on Serial connections".into(),
))
}
Connection::Tcp(_) | Connection::Udp(_) => Err(crate::error::Error::ConnectionFailed(
"RTS only supported on Serial connections".into(),
)),
}
}
}

View File

@@ -1,7 +1,7 @@
use async_trait::async_trait;
use serialport::SerialPort;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
use tokio_serial::{DataBits, FlowControl, Parity, SerialPortBuilderExt, SerialStream, StopBits};
use serialport::SerialPort;
use tracing::{debug, info, warn};
use super::{Transport, TransportType};
@@ -277,10 +277,16 @@ impl Transport for SerialTransport {
// HC-15, HC-05, Bluetooth/UART bridges) need DTR asserted to stay in
// transparent data mode and not fall into AT-command / reset state.
if let Err(e) = port.write_data_terminal_ready(self.dtr) {
warn!("Failed to set DTR({}) on {}: {}", self.dtr, self.port_name, e);
warn!(
"Failed to set DTR({}) on {}: {}",
self.dtr, self.port_name, e
);
}
if let Err(e) = port.write_request_to_send(self.rts) {
warn!("Failed to set RTS({}) on {}: {}", self.rts, self.port_name, e);
warn!(
"Failed to set RTS({}) on {}: {}",
self.rts, self.port_name, e
);
}
debug!("Serial port {} opened successfully", self.port_name);
@@ -331,8 +337,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert_eq!(transport.port_name(), "COM1");
assert_eq!(transport.baud_rate(), 115200);
@@ -347,8 +353,8 @@ mod tests {
SerialParity::Even,
SerialStopBits::Two,
SerialFlowControl::Hardware,
true,
true,
true,
true,
);
assert_eq!(transport.port_name(), "COM3");
assert_eq!(transport.baud_rate(), 9600);
@@ -367,8 +373,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert_eq!(transport.name(), "COM1");
}
@@ -382,8 +388,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert_eq!(transport.transport_type(), TransportType::Serial);
}
@@ -397,8 +403,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert!(!transport.is_connected());
}
@@ -427,8 +433,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
let pinned = Pin::new(&mut transport);
let mut buf_data = [0u8; 16];
@@ -452,8 +458,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
let pinned = Pin::new(&mut transport);
let data = b"hello";
@@ -474,8 +480,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
let pinned = Pin::new(&mut transport);
let waker = noop_waker();
@@ -495,8 +501,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
let pinned = Pin::new(&mut transport);
let waker = noop_waker();
@@ -518,8 +524,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert_eq!(transport.name(), "COM1");
}
@@ -533,8 +539,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert_eq!(transport.transport_type(), TransportType::Serial);
}
@@ -548,8 +554,8 @@ mod tests {
SerialParity::None,
SerialStopBits::One,
SerialFlowControl::None,
true,
true,
true,
true,
);
assert!(!transport.is_connected());
}

View File

@@ -688,8 +688,8 @@ async fn connection_transport_type_dispatch() {
parity: SerialParity::None,
stop_bits: SerialStopBits::One,
flow_control: SerialFlowControl::None,
dtr: false,
rts: false,
dtr: false,
rts: false,
});
let tcp = Connection::new(TransportConfig::Tcp {
addr: "127.0.0.1:8080".into(),