Skip to main content

copy_bidirectional

Function copy_bidirectional 

Source
pub async fn copy_bidirectional<A, B>(
    reader: A,
    writer: B,
) -> (Result<u64, Error>, Result<u64, Error>)
Available on crate feature io only.
Expand description

Asynchronously copies data bidirectionally between two pairs of reader and writer.

This function takes two Splittable objects, reader and writer, and splits them into their respective read and write halves. It then concurrently copies data from the read half of reader to the write half of writer, and from the read half of writer to the write half of reader. The function returns a tuple containing the results of both copy operations, which indicate the total number of bytes copied in each direction or any errors that occurred during the copying process.