From 9b7bad65e559179a0c5cdbe2e463c959f910cc23 Mon Sep 17 00:00:00 2001 From: Isaiah Becker-Mayer Date: Fri, 19 May 2023 13:44:21 +0000 Subject: [PATCH] fix: change `read_pdu` to return `BytesMut` (#143) --- crates/ironrdp-async/src/framed.rs | 8 ++++---- crates/ironrdp-session/src/lib.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ironrdp-async/src/framed.rs b/crates/ironrdp-async/src/framed.rs index 815ef812..df7c7954 100644 --- a/crates/ironrdp-async/src/framed.rs +++ b/crates/ironrdp-async/src/framed.rs @@ -85,10 +85,10 @@ where self.stream.read(&mut self.buf).await } - pub async fn read_exact(&mut self, length: usize) -> io::Result { + pub async fn read_exact(&mut self, length: usize) -> io::Result { loop { if self.buf.len() >= length { - return Ok(self.buf.split_to(length).freeze()); + return Ok(self.buf.split_to(length)); } else { self.buf.reserve(length - self.buf.len()); } @@ -102,7 +102,7 @@ where } } - pub async fn read_pdu(&mut self) -> io::Result<(ironrdp_pdu::Action, Bytes)> { + pub async fn read_pdu(&mut self) -> io::Result<(ironrdp_pdu::Action, BytesMut)> { loop { // Try decoding and see if a frame has been received already match ironrdp_pdu::find_size(self.peek()) { @@ -131,7 +131,7 @@ where .map_err(|e| io::Error::new(io::ErrorKind::Other, e))? { Some(length) => { - return self.read_exact(length).await; + return Ok(self.read_exact(length).await?.freeze()); } None => { let len = self.read().await?; diff --git a/crates/ironrdp-session/src/lib.rs b/crates/ironrdp-session/src/lib.rs index 9830f9e1..4b8bbc2c 100644 --- a/crates/ironrdp-session/src/lib.rs +++ b/crates/ironrdp-session/src/lib.rs @@ -4,14 +4,14 @@ extern crate tracing; #[macro_use] mod macros; +pub mod fast_path; pub mod image; pub mod legacy; pub mod rfx; // FIXME: maybe this module should not be in this crate +pub mod utils; +pub mod x224; mod active_stage; -mod fast_path; -mod utils; -mod x224; use core::fmt;