pub async fn test_async_stream<TAsyncDuplex: AsyncRead + AsyncWrite + Send + Unpin + ?Sized + 'static>(
channel1: Box<TAsyncDuplex>,
channel2: Box<TAsyncDuplex>,
options: TestOptions,
) -> (Pin<Box<TAsyncDuplex>>, Pin<Box<TAsyncDuplex>>)
Expand description
Test an AsyncRead + AsyncWrite
stream data transfer
ยงExamples
use tokio::io::duplex;
#[tokio::main]
async fn main() {
// either `test` or the `all` feature must be enabled
#[cfg(any(feature = "test", feature = "all"))]
{
use connection_utils::test::{test_async_stream, TestOptions};
use cs_utils::random_str_rg;
// create stream to test
let (channel1, channel2) = duplex(4096);
// create test data
let options = TestOptions::default()
.with_data_len(4096);
// test data transfer
test_async_stream(
Box::new(channel1),
Box::new(channel2),
options,
).await;
println!("๐ data transfer succeeded");
}
}