Skip to content

Commit 44f40f2

Browse files
committed
Fix lints
1 parent e1fba3e commit 44f40f2

File tree

7 files changed

+53
-31
lines changed

7 files changed

+53
-31
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,7 @@ dependencies = [
17291729
"bincode",
17301730
"mimalloc",
17311731
"re_crash_handler",
1732+
"re_error",
17321733
"re_log",
17331734
"re_sdk_comms",
17341735
"re_viewer",

examples/rust/custom_callback/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ re_sdk_comms = { path = "../../../crates/store/re_sdk_comms", features = [
2727
] }
2828
re_viewer = { path = "../../../crates/viewer/re_viewer", default-features = false }
2929
re_log = { path = "../../../crates/utils/re_log" }
30+
re_error = { path = "../../../crates/utils/re_error" }
3031
rerun = { path = "../../../crates/top/rerun" }
3132

3233
bincode = "1.3.3"

examples/rust/custom_callback/src/app.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
1414
#[tokio::main]
1515
async fn main() -> Result<(), Box<dyn std::error::Error>> {
1616
let mut app = ControlApp::bind("127.0.0.1:8888").await?.run();
17-
let rec = rerun::RecordingStreamBuilder::new("rerun_control_panel_example").connect_tcp_opts(
18-
"127.0.0.1:9877".to_socket_addrs().unwrap().next().unwrap(),
19-
None,
20-
)?;
17+
let rec = rerun::RecordingStreamBuilder::new("rerun_example_custom_callback")
18+
.connect_tcp_opts(
19+
"127.0.0.1:9877".to_socket_addrs().unwrap().next().unwrap(),
20+
None,
21+
)?;
2122

2223
// Add a handler for incoming messages
2324
let add_rec = rec.clone();

examples/rust/custom_callback/src/comms/app.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ impl ControlApp {
7070
app.handle_connection(socket).await;
7171
});
7272
}
73-
Err(e) => {
74-
re_log::error!("Error accepting connection: {:?}", e);
73+
Err(err) => {
74+
re_log::error!(
75+
"Error accepting connection: {}",
76+
re_error::format_ref(&err)
77+
);
7578
}
7679
}
7780
}
@@ -120,12 +123,15 @@ impl ControlApp {
120123
handler(&message);
121124
}
122125
}
123-
Err(e) => {
124-
re_log::error!("Failed to decode message: {:?}", e);
126+
Err(err) => {
127+
re_log::error!("Failed to decode message: {}", re_error::format_ref(&err));
125128
}
126129
},
127-
Err(e) => {
128-
re_log::error!("Error reading from socket: {:?}", e);
130+
Err(err) => {
131+
re_log::error!(
132+
"Error reading from socket: {:?}",
133+
re_error::format_ref(&err),
134+
);
129135
break;
130136
}
131137
}

examples/rust/custom_callback/src/comms/protocol.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ pub enum Message {
2323

2424
impl Message {
2525
pub fn encode(&self) -> io::Result<Vec<u8>> {
26-
bincode::serialize(self).map_err(|e| io::Error::new(ErrorKind::InvalidData, e))
26+
bincode::serialize(self).map_err(|err| io::Error::new(ErrorKind::InvalidData, err))
2727
}
2828

2929
pub fn encode_into(&self, buffer: &mut [u8]) -> io::Result<()> {
30-
bincode::serialize_into(buffer, self).map_err(|e| io::Error::new(ErrorKind::InvalidData, e))
30+
bincode::serialize_into(buffer, self)
31+
.map_err(|err| io::Error::new(ErrorKind::InvalidData, err))
3132
}
3233

3334
pub fn decode(data: &[u8]) -> io::Result<Self> {
34-
bincode::deserialize(data).map_err(|e| io::Error::new(ErrorKind::InvalidData, e))
35+
bincode::deserialize(data).map_err(|err| io::Error::new(ErrorKind::InvalidData, err))
3536
}
3637
}

examples/rust/custom_callback/src/comms/viewer.rs

+29-17
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ impl ControlViewer {
6262
loop {
6363
match TcpStream::connect(self.address.clone()).await {
6464
Ok(socket) => {
65-
if let Err(e) = socket.set_linger(Some(Duration::from_secs(2))) {
66-
re_log::error!("Failed to set socket linger: {:?}", e);
65+
if let Err(err) = socket.set_linger(Some(Duration::from_secs(2))) {
66+
re_log::error!(
67+
"Failed to set socket linger: {}",
68+
re_error::format_ref(&err)
69+
);
6770
}
6871

6972
re_log::info!("Connected to {}", self.address);
@@ -82,21 +85,25 @@ impl ControlViewer {
8285
// Wait for tasks to complete
8386
tokio::select! {
8487
result = reader_task => {
85-
if let Err(e) = result {
86-
re_log::error!("Reader task ended with error: {:?}", e);
88+
if let Err(err) = result {
89+
re_log::error!("Reader task ended with error: {}", re_error::format_ref(&err));
8790
}
8891
}
8992
result = writer_task => {
90-
if let Err(e) = result {
91-
re_log::error!("Writer task ended with error: {:?}", e);
93+
if let Err(err) = result {
94+
re_log::error!("Writer task ended with error: {}", re_error::format_ref(&err));
9295
}
9396
}
9497
}
9598

9699
re_log::info!("Connection lost. Attempting to reconnect...");
97100
}
98-
Err(e) => {
99-
re_log::error!("Failed to connect to {}: {:?}", self.address, e);
101+
Err(err) => {
102+
re_log::error!(
103+
"Failed to connect to {}: {}",
104+
self.address,
105+
re_error::format_ref(&err)
106+
);
100107
}
101108
}
102109

@@ -134,12 +141,18 @@ impl ControlViewer {
134141
// we received a message from the server, we can process it here if needed
135142
re_log::info!("Received message from server: {:?}", message);
136143
}
137-
Err(e) => {
138-
re_log::error!("Failed to decode message: {:?}", e);
144+
Err(err) => {
145+
re_log::error!(
146+
"Failed to decode message: {:?}",
147+
re_error::format_ref(&err)
148+
);
139149
}
140150
},
141-
Err(e) => {
142-
re_log::error!("Error reading from server: {:?}", e);
151+
Err(err) => {
152+
re_log::error!(
153+
"Error reading from server: {:?}",
154+
re_error::format_ref(&err)
155+
);
143156
break;
144157
}
145158
}
@@ -166,11 +179,10 @@ impl ControlViewer {
166179
}
167180
_ => {
168181
if let Ok(data) = message.encode() {
169-
if let Err(e) = write.write_all(&data).await {
170-
re_log::info!(
171-
"Failed to send message: {:?}, error: {:?}",
172-
message,
173-
e
182+
if let Err(err) = write.write_all(&data).await {
183+
re_log::error!(
184+
"Failed to send message error: {}",
185+
re_error::format_ref(&err)
174186
);
175187
break;
176188
}

examples/rust/custom_callback/src/panel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::time::Instant;
22

3+
use crate::comms::{protocol::Message, viewer::ControlViewerHandle};
34
use re_log::ResultExt;
45
use re_viewer::external::{
56
eframe,
67
egui::{self, ScrollArea},
78
re_ui::{list_item, UiExt},
89
};
910

10-
use crate::comms::{protocol::Message, viewer::ControlViewerHandle};
1111
#[derive(Default)]
1212
pub struct ControlStates {
1313
pub last_resource_update: Option<Instant>,

0 commit comments

Comments
 (0)