refactor(async): impl FramedWrite for Frame

This allows to specialize functions that want to simply write_all() with
a Framed.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Marc-André Lureau
2024-09-23 02:25:59 -04:00
committed by Benoît Cortier
parent 3c6b2ef2e2
commit fa10362106
3 changed files with 10 additions and 6 deletions
+7 -3
View File
@@ -209,10 +209,14 @@ where
}
}
impl<S> Framed<S>
impl<S> FramedWrite for Framed<S>
where
S: FramedWrite,
{
type WriteAllFut<'write> = S::WriteAllFut<'write>
where
Self: 'write;
/// Attempts to write an entire buffer into this `Framed`s stream.
///
/// # Cancel safety
@@ -222,8 +226,8 @@ where
/// branch completes first, then the provided buffer may have been
/// partially written, but future calls to `write_all` will start over
/// from the beginning of the buffer.
pub async fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
self.stream.write_all(buf).await
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> Self::WriteAllFut<'a> {
self.stream.write_all(buf)
}
}
+1 -1
View File
@@ -10,7 +10,7 @@ use ironrdp::session::{fast_path, ActiveStage, ActiveStageOutput, GracefulDiscon
use ironrdp::{cliprdr, connector, rdpdr, rdpsnd, session};
use ironrdp_core::WriteBuf;
use ironrdp_rdpsnd_native::cpal;
use ironrdp_tokio::{single_sequence_step_read, split_tokio_framed};
use ironrdp_tokio::{single_sequence_step_read, split_tokio_framed, FramedWrite};
use rdpdr::NoopRdpdrBackend;
use smallvec::SmallVec;
use tokio::net::TcpStream;
+2 -2
View File
@@ -27,7 +27,7 @@ use ironrdp::pdu::rdp::client_info::PerformanceFlags;
use ironrdp::session::image::DecodedImage;
use ironrdp::session::{fast_path, ActiveStage, ActiveStageOutput, GracefulDisconnectReason};
use ironrdp_core::WriteBuf;
use ironrdp_futures::single_sequence_step_read;
use ironrdp_futures::{single_sequence_step_read, FramedWrite};
use rgb::AsPixels as _;
use tap::prelude::*;
use wasm_bindgen::prelude::*;
@@ -958,7 +958,7 @@ async fn connect_rdcleanpath<S>(
pcb: Option<String>,
) -> Result<(ironrdp_futures::Upgraded, Vec<u8>), IronRdpError>
where
S: ironrdp_futures::FramedRead + ironrdp_futures::FramedWrite,
S: ironrdp_futures::FramedRead + FramedWrite,
{
use ironrdp::connector::Sequence as _;
use x509_cert::der::Decode as _;