Skip to content

Commit fa89695

Browse files
committed
feat(server): implement some Encoder Debug
Signed-off-by: Marc-André Lureau <[email protected]>
1 parent cc2619b commit fa89695

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

+26-1
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;
4+
use core::{cmp, fmt};
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 {
@@ -156,6 +166,12 @@ struct BitmapHandler {
156166
bitmap: BitmapEncoder,
157167
}
158168

169+
impl fmt::Debug for BitmapHandler {
170+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
171+
f.debug_struct("BitmapHandler").finish()
172+
}
173+
}
174+
159175
impl BitmapHandler {
160176
fn new() -> Self {
161177
Self {
@@ -184,6 +200,7 @@ impl BitmapUpdateHandler for BitmapHandler {
184200
}
185201
}
186202

203+
#[derive(Debug)]
187204
struct RemoteFxHandler {
188205
remotefx: RfxEncoder,
189206
codec_id: u8,
@@ -284,6 +301,14 @@ pub(crate) struct UpdateFragmenter<'a> {
284301
data: &'a [u8],
285302
}
286303

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

0 commit comments

Comments
 (0)