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 both `async` and `test` features must be enabled or the `all` one
    #[cfg(any(all(feature = "async", feature = "test"), feature = "all"))]
    {
        use cs_utils::{futures::test::test_async_stream, 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");
    }
}