Skip to content

Commit a3798db

Browse files
committed
encoder: implement some Debug
Signed-off-by: Marc-André Lureau <[email protected]>
1 parent 81633a1 commit a3798db

File tree

1 file changed

+26
-1
lines changed
  • crates/ironrdp-server/src/encoder

1 file changed

+26
-1
lines changed

crates/ironrdp-server/src/encoder/mod.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod bitmap;
22
pub(crate) mod rfx;
33

4-
use core::{cmp, mem};
4+
use core::{cmp, fmt, mem};
55

66
use anyhow::{Context, Result};
77
use ironrdp_core::{Encode, WriteCursor};
@@ -32,6 +32,14 @@ pub(crate) struct UpdateEncoder {
3232
bitmap_updater: BitmapUpdater,
3333
}
3434

35+
impl fmt::Debug for UpdateEncoder {
36+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
37+
f.debug_struct("UpdateEncoder")
38+
.field("bitmap_update", &self.bitmap_updater)
39+
.finish()
40+
}
41+
}
42+
3543
impl UpdateEncoder {
3644
pub(crate) fn new(surface_flags: CmdFlags, remotefx: Option<(EntropyBits, u8)>) -> Self {
3745
let pdu_encoder = PduEncoder::new();
@@ -118,6 +126,7 @@ impl UpdateEncoder {
118126
}
119127
}
120128

129+
#[derive(Debug)]
121130
enum BitmapUpdater {
122131
None(NoneHandler),
123132
Bitmap(BitmapHandler),
@@ -138,6 +147,7 @@ trait BitmapUpdateHandler {
138147
fn handle<'a>(&mut self, bitmap: BitmapUpdate, encoder: &'a mut PduEncoder) -> Result<UpdateFragmenter<'a>>;
139148
}
140149

150+
#[derive(Debug)]
141151
struct NoneHandler;
142152

143153
impl BitmapUpdateHandler for NoneHandler {
@@ -172,6 +182,12 @@ struct BitmapHandler {
172182
bitmap: BitmapEncoder,
173183
}
174184

185+
impl fmt::Debug for BitmapHandler {
186+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
187+
f.debug_struct("BitmapHandler").finish()
188+
}
189+
}
190+
175191
impl BitmapHandler {
176192
fn new() -> Self {
177193
Self {
@@ -200,6 +216,7 @@ impl BitmapUpdateHandler for BitmapHandler {
200216
}
201217
}
202218

219+
#[derive(Debug)]
203220
struct RemoteFxHandler {
204221
remotefx: RfxEncoder,
205222
codec_id: u8,
@@ -287,6 +304,14 @@ pub(crate) struct UpdateFragmenter<'a> {
287304
data: &'a [u8],
288305
}
289306

307+
impl fmt::Debug for UpdateFragmenter<'_> {
308+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
309+
f.debug_struct("UpdateFragmenter")
310+
.field("len", &self.data.len())
311+
.finish()
312+
}
313+
}
314+
290315
impl<'a> UpdateFragmenter<'a> {
291316
pub(crate) fn new(code: UpdateCode, data: &'a [u8]) -> Self {
292317
Self { code, index: 0, data }

0 commit comments

Comments
 (0)