Skip to content

Commit 5447491

Browse files
committed
master dechunker debug
1 parent a91615c commit 5447491

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

btp/src/dechunk.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,24 @@ impl Chunk {
8383
}
8484
}
8585

86-
#[derive(Debug, Default)]
86+
#[derive(Default)]
8787
pub struct Dechunker {
8888
chunks: Vec<Option<RawChunk>>,
8989
info: Option<MessageInfo>,
9090
}
9191

92+
impl std::fmt::Debug for Dechunker {
93+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
94+
f.debug_struct("Dechunker")
95+
.field(
96+
"chunks",
97+
&self.chunks.iter().map(|c| if c.is_some() { 1 } else { 0 }),
98+
)
99+
.field("info", &self.info)
100+
.finish()
101+
}
102+
}
103+
92104
#[derive(Debug, Clone, Copy)]
93105
struct MessageInfo {
94106
message_id: u16,
@@ -208,13 +220,14 @@ impl Dechunker {
208220
}
209221
}
210222

223+
#[derive(Debug)]
211224
pub struct MasterDechunker<const N: usize> {
212225
dechunkers: [Option<DechunkerSlot>; N],
213226
counter: u64,
214227
}
215228

216229
#[derive(Debug)]
217-
struct DechunkerSlot {
230+
pub struct DechunkerSlot {
218231
dechunker: Dechunker,
219232
last_used: u64,
220233
}
@@ -229,6 +242,10 @@ impl<const N: usize> Default for MasterDechunker<N> {
229242
}
230243

231244
impl<const N: usize> MasterDechunker<N> {
245+
pub fn dechunkers(&self) -> &[Option<DechunkerSlot>] {
246+
&self.dechunkers
247+
}
248+
232249
pub fn insert_chunk(&mut self, chunk: Chunk) -> Option<Vec<u8>> {
233250
let message_id = chunk.header.message_id;
234251

0 commit comments

Comments
 (0)