From 00217a941b2e357327a5c90c9845808913640f75 Mon Sep 17 00:00:00 2001 From: Przemko Robakowski Date: Wed, 16 Aug 2023 22:53:29 +0200 Subject: [PATCH] Make it easier to use IronRDP with Tokio --- crates/ironrdp-async/src/framed.rs | 7 +++++-- crates/ironrdp-futures/src/lib.rs | 5 ++++- crates/ironrdp-pdu/src/lib.rs | 2 +- crates/ironrdp-tokio/src/lib.rs | 13 ++++++++----- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/crates/ironrdp-async/src/framed.rs b/crates/ironrdp-async/src/framed.rs index df7c79542..3d3d83bf8 100644 --- a/crates/ironrdp-async/src/framed.rs +++ b/crates/ironrdp-async/src/framed.rs @@ -11,14 +11,17 @@ pub trait FramedRead { fn read<'a>( &'a mut self, buf: &'a mut BytesMut, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where Self: 'a; } pub trait FramedWrite { /// Writes an entire buffer into this stream. - fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> Pin> + 'a>> + fn write_all<'a>( + &'a mut self, + buf: &'a [u8], + ) -> Pin> + 'a + Send>> where Self: 'a; } diff --git a/crates/ironrdp-futures/src/lib.rs b/crates/ironrdp-futures/src/lib.rs index 567041b59..95485f0c1 100644 --- a/crates/ironrdp-futures/src/lib.rs +++ b/crates/ironrdp-futures/src/lib.rs @@ -61,7 +61,10 @@ impl FramedWrite for FuturesStream where S: Unpin + AsyncWrite, { - fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> Pin> + 'a>> + fn write_all<'a>( + &'a mut self, + buf: &'a [u8], + ) -> Pin> + 'a + Send>> where Self: 'a, { diff --git a/crates/ironrdp-pdu/src/lib.rs b/crates/ironrdp-pdu/src/lib.rs index a6f049d62..a4fc6de33 100644 --- a/crates/ironrdp-pdu/src/lib.rs +++ b/crates/ironrdp-pdu/src/lib.rs @@ -282,7 +282,7 @@ pub fn find_size(bytes: &[u8]) -> PduResult> { } } -pub trait PduHint: core::fmt::Debug { +pub trait PduHint: core::fmt::Debug + Sync { /// Finds next PDU size by reading the next few bytes. fn find_size(&self, bytes: &[u8]) -> PduResult>; } diff --git a/crates/ironrdp-tokio/src/lib.rs b/crates/ironrdp-tokio/src/lib.rs index eb193a08d..a42b5cf86 100644 --- a/crates/ironrdp-tokio/src/lib.rs +++ b/crates/ironrdp-tokio/src/lib.rs @@ -33,14 +33,14 @@ impl StreamWrapper for TokioStream { impl FramedRead for TokioStream where - S: Unpin + AsyncRead, + S: Unpin + AsyncRead + Send, { fn read<'a>( &'a mut self, buf: &'a mut BytesMut, - ) -> Pin> + 'a>> + ) -> Pin> + 'a + Send>> where - Self: 'a, + Self: 'a + Send, { use tokio::io::AsyncReadExt as _; @@ -50,9 +50,12 @@ where impl FramedWrite for TokioStream where - S: Unpin + AsyncWrite, + S: Unpin + AsyncWrite + Send, { - fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> Pin> + 'a>> + fn write_all<'a>( + &'a mut self, + buf: &'a [u8], + ) -> Pin> + 'a + Send>> where Self: 'a, {