Skip to content

Make it easier to use IronRDP with Tokio #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions crates/ironrdp-async/src/framed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ pub trait FramedRead {
fn read<'a>(
&'a mut self,
buf: &'a mut BytesMut,
) -> Pin<Box<dyn std::future::Future<Output = io::Result<usize>> + 'a>>
) -> Pin<Box<dyn std::future::Future<Output = io::Result<usize>> + '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<Box<dyn std::future::Future<Output = io::Result<()>> + 'a>>
fn write_all<'a>(
&'a mut self,
buf: &'a [u8],
) -> Pin<Box<dyn std::future::Future<Output = io::Result<()>> + 'a + Send>>
where
Self: 'a;
}
Expand Down
5 changes: 4 additions & 1 deletion crates/ironrdp-futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ impl<S> FramedWrite for FuturesStream<S>
where
S: Unpin + AsyncWrite,
{
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> Pin<Box<dyn std::future::Future<Output = io::Result<()>> + 'a>>
fn write_all<'a>(
&'a mut self,
buf: &'a [u8],
) -> Pin<Box<dyn std::future::Future<Output = io::Result<()>> + 'a + Send>>
where
Self: 'a,
{
Expand Down
2 changes: 1 addition & 1 deletion crates/ironrdp-pdu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ pub fn find_size(bytes: &[u8]) -> PduResult<Option<PduInfo>> {
}
}

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<Option<usize>>;
}
Expand Down
13 changes: 8 additions & 5 deletions crates/ironrdp-tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ impl<S> StreamWrapper for TokioStream<S> {

impl<S> FramedRead for TokioStream<S>
where
S: Unpin + AsyncRead,
S: Unpin + AsyncRead + Send,
{
fn read<'a>(
&'a mut self,
buf: &'a mut BytesMut,
) -> Pin<Box<dyn std::future::Future<Output = io::Result<usize>> + 'a>>
) -> Pin<Box<dyn std::future::Future<Output = io::Result<usize>> + 'a + Send>>
where
Self: 'a,
Self: 'a + Send,
{
use tokio::io::AsyncReadExt as _;

Expand All @@ -50,9 +50,12 @@ where

impl<S> FramedWrite for TokioStream<S>
where
S: Unpin + AsyncWrite,
S: Unpin + AsyncWrite + Send,
{
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> Pin<Box<dyn std::future::Future<Output = io::Result<()>> + 'a>>
fn write_all<'a>(
&'a mut self,
buf: &'a [u8],
) -> Pin<Box<dyn std::future::Future<Output = io::Result<()>> + 'a + Send>>
where
Self: 'a,
{
Expand Down