Skip to content

Commit a112331

Browse files
committed
Add and standardize Debug impls
1 parent 4914309 commit a112331

File tree

9 files changed

+32
-9
lines changed

9 files changed

+32
-9
lines changed

crates/backtest/src/exchange.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use std::{
2323
cell::RefCell,
2424
collections::{BinaryHeap, HashMap, VecDeque},
25+
fmt::Debug,
2526
rc::Rc,
2627
};
2728

@@ -121,7 +122,7 @@ pub struct SimulatedExchange {
121122
use_message_queue: bool,
122123
}
123124

124-
impl std::fmt::Debug for SimulatedExchange {
125+
impl Debug for SimulatedExchange {
125126
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
126127
f.debug_struct(stringify!(SimulatedExchange))
127128
.field("id", &self.id)

crates/common/src/actor/data_actor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,15 +2155,15 @@ fn log_error(e: &anyhow::Error) {
21552155

21562156
fn log_not_running<T>(msg: &T)
21572157
where
2158-
T: std::fmt::Debug,
2158+
T: Debug,
21592159
{
21602160
// TODO: Potentially temporary for development? drop level at some stage
21612161
log::warn!("Received message when not running - skipping {msg:?}");
21622162
}
21632163

21642164
fn log_received<T>(msg: &T)
21652165
where
2166-
T: std::fmt::Debug,
2166+
T: Debug,
21672167
{
21682168
log::debug!("{RECV} {msg:?}");
21692169
}

crates/common/src/enums.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
//! Enumerations for common components.
1717
18-
use std::fmt::Debug;
19-
2018
use log::Level;
2119
use serde::{Deserialize, Serialize};
2220
use strum::{Display, EnumIter, EnumString, FromRepr};

crates/common/src/signal.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
//! A user signal type.
1717
18-
use std::fmt::Debug;
19-
2018
use nautilus_core::UnixNanos;
2119
use serde::{Deserialize, Serialize};
2220
use ustr::Ustr;

crates/network/src/http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl From<String> for HttpClientError {
189189
/// support for rate limiting, timeouts, and custom headers. The client is
190190
/// built on top of `reqwest` and can be used for both synchronous and
191191
/// asynchronous HTTP requests.
192-
#[derive(Clone)]
192+
#[derive(Clone, Debug)]
193193
#[cfg_attr(
194194
feature = "python",
195195
pyo3::pyclass(module = "nautilus_trader.core.nautilus_pyo3.network")

crates/network/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#![warn(rustc::all)]
3131
#![deny(unsafe_code)]
3232
#![deny(nonstandard_style)]
33+
#![deny(missing_debug_implementations)]
3334
#![deny(clippy::missing_errors_doc)]
3435
#![deny(clippy::missing_panics_doc)]
3536
#![deny(rustdoc::broken_intra_doc_links)]

crates/network/src/ratelimiter/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ mod nanos;
2222
pub mod quota;
2323

2424
use std::{
25+
fmt::Debug,
2526
hash::Hash,
2627
num::NonZeroU64,
2728
sync::atomic::{AtomicU64, Ordering},
@@ -47,7 +48,7 @@ use self::{
4748
///
4849
/// Internally, the number tracked here is the theoretical arrival time (a GCRA term) in number of
4950
/// nanoseconds since the rate limiter was created.
50-
#[derive(Default)]
51+
#[derive(Debug, Default)]
5152
pub struct InMemoryState(AtomicU64);
5253

5354
impl InMemoryState {
@@ -146,6 +147,16 @@ where
146147
start: C::Instant,
147148
}
148149

150+
impl<K, C> Debug for RateLimiter<K, C>
151+
where
152+
K: Debug,
153+
C: Clock,
154+
{
155+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
156+
f.debug_struct(stringify!(RateLimiter)).finish()
157+
}
158+
}
159+
149160
impl<K> RateLimiter<K, MonotonicClock>
150161
where
151162
K: Eq + Hash,

crates/network/src/socket.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
//! - Controller task manages lifecycle
3030
3131
use std::{
32+
fmt::Debug,
3233
path::Path,
3334
sync::{
3435
Arc,
@@ -537,6 +538,12 @@ pub struct SocketClient {
537538
pub writer_tx: tokio::sync::mpsc::UnboundedSender<WriterCommand>,
538539
}
539540

541+
impl Debug for SocketClient {
542+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
543+
f.debug_struct(stringify!(SocketClient)).finish()
544+
}
545+
}
546+
540547
impl SocketClient {
541548
/// Connect to the server.
542549
///

crates/network/src/websocket.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
//! - Controller task manages lifecycle
3030
3131
use std::{
32+
fmt::Debug,
3233
sync::{
3334
Arc,
3435
atomic::{AtomicU8, Ordering},
@@ -588,6 +589,12 @@ pub struct WebSocketClient {
588589
pub(crate) rate_limiter: Arc<RateLimiter<String, MonotonicClock>>,
589590
}
590591

592+
impl Debug for WebSocketClient {
593+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
594+
f.debug_struct(stringify!(WebSocketClient)).finish()
595+
}
596+
}
597+
591598
impl WebSocketClient {
592599
/// Creates a websocket client that returns a stream for reading messages.
593600
///

0 commit comments

Comments
 (0)