Function connection_utils::test::test_async_stream
source · [−]pub async fn test_async_stream<TAsyncDuplex: AsyncRead + AsyncWrite + Send + Unpin + ?Sized + 'static>(
channel1: Box<TAsyncDuplex>,
channel2: Box<TAsyncDuplex>,
test_data: String
)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};
use cs_utils::random_str_rg;
// create stream to test
let (channel1, channel2) = duplex(4096);
// create test data
let test_data = random_str_rg(1024..=25600);
// test data transfer
test_async_stream(
Box::new(channel1),
Box::new(channel2),
test_data,
).await;
println!("👌 data transfer succeeded");
}
}